public void run(Duration timeout) {
    Preconditions.checkNotNull(app);
    Preconditions.checkState(!timeout.isZero() || !timeout.isNegative(), "Timeouts should be positive");
    // Cleaning store directories to ensure current run does not pick up state from previous run
    deleteStoreDirectories();
    Config config = new MapConfig(JobPlanner.generateSingleJobConfig(configs));
    InMemoryMetadataStoreFactory metadataStoreFactory = inMemoryMetadataStoreFactory != null
        ? inMemoryMetadataStoreFactory
        : new InMemoryMetadataStoreFactory();
    final LocalApplicationRunner runner = new LocalApplicationRunner(app, config, metadataStoreFactory);
    runner.run(externalContext);
    if (!runner.waitForFinish(timeout)) {
      throw new SamzaException("Timed out waiting for application to finish");
    }
    ApplicationStatus status = runner.status();
    deleteStoreDirectories();
    if (status.getStatusCode() == ApplicationStatus.StatusCode.UnsuccessfulFinish) {
      throw new SamzaException("Application could not finish successfully", status.getThrowable());
    }
  }
Run the application with the specified timeout

@param timeout time to wait for the application to finish. This timeout does not include
               input stream initialization time or the assertion time over output streams. This timeout just accounts
               for time that samza job takes run. Timeout must be greater than 0.
@throws SamzaException if Samza job fails with exception and returns UnsuccessfulFinish as the statuscode
samza-test/src/main/java/org/apache/samza/test/framework/TestRunner.java