use of org.apache.samza.metadatastore.InMemoryMetadataStoreFactory in project samza by apache.
the class TestLocalApplicationRunner method testCreateCoordinatorStreamWithoutCoordinatorFactory.
/**
* Underlying coordinator stream should not be created if not using CoordinatorStreamMetadataStoreFactory
*/
@Test
public void testCreateCoordinatorStreamWithoutCoordinatorFactory() throws Exception {
SystemAdmins systemAdmins = mock(SystemAdmins.class);
PowerMockito.whenNew(SystemAdmins.class).withAnyArguments().thenReturn(systemAdmins);
LocalApplicationRunner localApplicationRunner = spy(new LocalApplicationRunner(mockApp, config, new InMemoryMetadataStoreFactory()));
doReturn(false).when(localApplicationRunner).createUnderlyingCoordinatorStream(eq(config));
MetadataStore coordinatorStreamStore = localApplicationRunner.createCoordinatorStreamStore(config);
assertTrue(coordinatorStreamStore instanceof InMemoryMetadataStore);
// creating underlying coordinator stream should not be called for other coordinator stream metadata store types.
verify(localApplicationRunner, never()).createUnderlyingCoordinatorStream(eq(config));
}
use of org.apache.samza.metadatastore.InMemoryMetadataStoreFactory in project samza by apache.
the class TestRunner method run.
/**
* 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
*/
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));
final LocalApplicationRunner runner = new LocalApplicationRunner(app, config, new InMemoryMetadataStoreFactory());
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());
}
}
Aggregations