Search in sources :

Example 1 with RegistrationRequest

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()));
}
Also used : RegistrationRequest(com.thinkbiganalytics.spark.rest.model.RegistrationRequest) Test(org.junit.Test)

Example 2 with RegistrationRequest

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()));
}
Also used : Nonnull(javax.annotation.Nonnull) RegistrationRequest(com.thinkbiganalytics.spark.rest.model.RegistrationRequest) Test(org.junit.Test)

Aggregations

RegistrationRequest (com.thinkbiganalytics.spark.rest.model.RegistrationRequest)2 Test (org.junit.Test)2 Nonnull (javax.annotation.Nonnull)1