use of com.thinkbiganalytics.spark.rest.model.RegistrationRequest in project kylo by Teradata.
the class AbstractProcessManagerTest method testSystemReady.
/**
* Verify a successful start of the system process.
*/
@Test
public void testSystemReady() {
// Mock process
final RegistrationRequest registration = new RegistrationRequest();
registration.setHost(CLIENT_HOST);
registration.setPort(CLIENT_PORT);
Mockito.doAnswer(invocation -> {
final Object result = invocation.callRealMethod();
processManager.register(process.getClientId(), registration);
return result;
}).when(process).addListener(Mockito.any(SparkShellProcessListener.class));
// Start system process
processManager = new MockProcessManager(clientProperties, users);
processManager.addListener(listener);
// Try to get system process
Assert.assertEquals(process, processManager.getSystemProcess());
Assert.assertTrue("Process should be ready", process.waitForReady());
Assert.assertEquals("Process hostname should be set", CLIENT_HOST, process.getHostname());
Assert.assertEquals("Process port should be set", CLIENT_PORT, process.getPort());
listener.assertCounts(1, 1, 0);
Assert.assertTrue("User should have been added", users.containsKey(process.getClientId()));
}
use of com.thinkbiganalytics.spark.rest.model.RegistrationRequest in project kylo by Teradata.
the class AbstractProcessManagerTest method testUserReady.
/**
* Verify a successful start of a user process.
*/
@Test
public void testUserReady() throws Exception {
// Create process manager
processManager = new MockProcessManager(clientProperties, users) {
@Nonnull
@Override
public synchronized SparkShellProcess getSystemProcess() {
return Mockito.mock(SparkShellProcess.class);
}
@Override
public void start(@Nonnull String username) {
super.start(username);
final RegistrationRequest registration = new RegistrationRequest();
registration.setHost(CLIENT_HOST);
registration.setPort(CLIENT_PORT);
register(process.getClientId(), registration);
}
};
processManager.addListener(listener);
// Try to get user process
Assert.assertEquals(process, processManager.getProcessForUser(USERNAME));
Assert.assertTrue("Process should be ready", process.waitForReady());
Assert.assertEquals("Process hostname should be set", CLIENT_HOST, process.getHostname());
Assert.assertEquals("Process port should be set", CLIENT_PORT, process.getPort());
listener.assertCounts(1, 1, 0);
Assert.assertTrue("User should have been added", users.containsKey(process.getClientId()));
}
Aggregations