Search in sources :

Example 6 with AgentMain

use of com.spotify.helios.agent.AgentMain in project helios by spotify.

the class DeregisterTest method testRegistrationResolution.

@Test
public void testRegistrationResolution() throws Exception {
    startDefaultMaster();
    final String host = testHost();
    final AgentMain agent = startDefaultAgent(host, "--labels", "num=1");
    final HeliosClient client = defaultClient();
    // Wait for agent to come up
    awaitHostRegistered(client, host, LONG_WAIT_SECONDS, SECONDS);
    // Wait for agent to be UP and report HostInfo
    awaitHostStatusWithHostInfo(client, host, UP, LONG_WAIT_SECONDS, SECONDS);
    // Kill off agent
    agent.stopAsync().awaitTerminated();
    awaitHostStatus(client, host, DOWN, LONG_WAIT_SECONDS, SECONDS);
    // Start a new agent with the same hostname but have it generate a different ID
    resetAgentStateDir();
    startDefaultAgent(host, "--zk-registration-ttl", "0", "--labels", "num=2");
    // Check that the new host is registered
    awaitHostRegistered(client, host, LONG_WAIT_SECONDS, SECONDS);
}
Also used : AgentMain(com.spotify.helios.agent.AgentMain) HeliosClient(com.spotify.helios.client.HeliosClient) Test(org.junit.Test)

Example 7 with AgentMain

use of com.spotify.helios.agent.AgentMain in project helios by spotify.

the class DeregisterTest method testRegistrationResolutionTtlNotExpired.

@Test(expected = TimeoutException.class)
public void testRegistrationResolutionTtlNotExpired() throws Exception {
    startDefaultMaster();
    final String host = testHost();
    final AgentMain agent = startDefaultAgent(host);
    final HeliosClient client = defaultClient();
    // Wait for agent to come up
    awaitHostRegistered(client, host, LONG_WAIT_SECONDS, SECONDS);
    // Wait for agent to be UP and report HostInfo
    awaitHostStatusWithHostInfo(client, host, UP, LONG_WAIT_SECONDS, SECONDS);
    // Kill off agent
    agent.stopAsync().awaitTerminated();
    awaitHostStatus(client, host, DOWN, LONG_WAIT_SECONDS, SECONDS);
    // Start a new agent with the same hostname but have it generate a different ID
    resetAgentStateDir();
    // instead check for the TimeoutException while polling for it being UP.
    try {
        startDefaultAgent(host, "--zk-registration-ttl", "9999");
    } catch (IllegalStateException ignored) {
    // ignored
    }
    awaitHostStatus(client, host, UP, 10, SECONDS);
}
Also used : AgentMain(com.spotify.helios.agent.AgentMain) HeliosClient(com.spotify.helios.client.HeliosClient) Test(org.junit.Test)

Example 8 with AgentMain

use of com.spotify.helios.agent.AgentMain in project helios by spotify.

the class DeregisterTest method testJobsArePreservedWhenReregistering.

@Test
public void testJobsArePreservedWhenReregistering() throws Exception {
    startDefaultMaster();
    final String host = testHost();
    final AgentMain agent = startDefaultAgent(host, "--labels", "num=1");
    final HeliosClient client = defaultClient();
    awaitHostStatus(client, host, UP, LONG_WAIT_SECONDS, SECONDS);
    // Deploy a job and wait for it to be running
    final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, IDLE_COMMAND);
    deployJob(jobId, host);
    awaitJobState(client, host, jobId, RUNNING, LONG_WAIT_SECONDS, SECONDS);
    // Kill off agent
    agent.stopAsync().awaitTerminated();
    awaitHostStatus(client, host, DOWN, LONG_WAIT_SECONDS, SECONDS);
    // Start a new agent with the same hostname but have it generate a different ID
    resetAgentStateDir();
    startDefaultAgent(host, "--zk-registration-ttl", "0", "--labels", "num=2");
    // Check that the new host is registered
    awaitHostRegistered(client, host, LONG_WAIT_SECONDS, SECONDS);
    awaitHostStatusWithLabels(client, host, UP, ImmutableMap.of("num", "2"));
    // Check that the job we previously deployed is preserved
    awaitJobState(client, host, jobId, RUNNING, WAIT_TIMEOUT_SECONDS, SECONDS);
}
Also used : AgentMain(com.spotify.helios.agent.AgentMain) HeliosClient(com.spotify.helios.client.HeliosClient) JobId(com.spotify.helios.common.descriptors.JobId) Test(org.junit.Test)

Example 9 with AgentMain

use of com.spotify.helios.agent.AgentMain in project helios by spotify.

the class CliHostListTest method initialize.

@Before
public void initialize() throws Exception {
    startDefaultMaster();
    // Wait for master to come up
    Polling.await(LONG_WAIT_SECONDS, SECONDS, new Callable<String>() {

        @Override
        public String call() throws Exception {
            final String output = cli("masters");
            return output.contains(masterName()) ? output : null;
        }
    });
    hostname1 = testHost() + "a";
    hostname2 = testHost() + "b";
    startDefaultAgent(hostname1);
    final AgentMain agent2 = startDefaultAgent(hostname2);
    // Wait for both agents to come up
    awaitHostRegistered(hostname1, LONG_WAIT_SECONDS, SECONDS);
    awaitHostStatus(hostname2, UP, LONG_WAIT_SECONDS, SECONDS);
    // Stop agent2
    agent2.stopAsync().awaitTerminated();
}
Also used : AgentMain(com.spotify.helios.agent.AgentMain) ArgumentParserException(net.sourceforge.argparse4j.inf.ArgumentParserException) Before(org.junit.Before)

Example 10 with AgentMain

use of com.spotify.helios.agent.AgentMain in project helios by spotify.

the class ClusterDeploymentTest method verifyCanDeployOnSeveralHosts.

@Test
public void verifyCanDeployOnSeveralHosts() throws Exception {
    final CreateJobResponse created = client.createJob(job).get();
    assertEquals(CreateJobResponse.Status.OK, created.getStatus());
    final List<AgentMain> agents = Lists.newArrayList();
    for (int i = 0; i < HOSTS; i++) {
        final AgentMain agent = startDefaultAgent(host(i), "--no-http", "--no-metrics");
        agents.add(agent);
    }
    for (final AgentMain agent : agents) {
        agent.awaitRunning();
    }
    for (int i = 0; i < HOSTS; i++) {
        awaitHostStatus(client, host(i), UP, LONG_WAIT_SECONDS, SECONDS);
    }
    for (int i = 0; i < HOSTS; i++) {
        deploy(job, host(i));
    }
    for (int i = 0; i < HOSTS; i++) {
        awaitJobState(client, host(i), job.getId(), RUNNING, LONG_WAIT_SECONDS, SECONDS);
    }
    for (int i = 0; i < HOSTS; i++) {
        undeploy(job.getId(), host(i));
    }
    for (int i = 0; i < HOSTS; i++) {
        awaitTaskGone(client, host(i), job.getId(), LONG_WAIT_SECONDS, SECONDS);
    }
}
Also used : CreateJobResponse(com.spotify.helios.common.protocol.CreateJobResponse) AgentMain(com.spotify.helios.agent.AgentMain) Test(org.junit.Test)

Aggregations

AgentMain (com.spotify.helios.agent.AgentMain)13 Test (org.junit.Test)11 HeliosClient (com.spotify.helios.client.HeliosClient)8 JobId (com.spotify.helios.common.descriptors.JobId)7 Deployment (com.spotify.helios.common.descriptors.Deployment)5 CreateJobResponse (com.spotify.helios.common.protocol.CreateJobResponse)4 JobDeployResponse (com.spotify.helios.common.protocol.JobDeployResponse)4 DockerClient (com.spotify.docker.client.DockerClient)3 HostStatus (com.spotify.helios.common.descriptors.HostStatus)3 Job (com.spotify.helios.common.descriptors.Job)3 TaskStatus (com.spotify.helios.common.descriptors.TaskStatus)3 HostDeregisterResponse (com.spotify.helios.common.protocol.HostDeregisterResponse)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 JobStatus (com.spotify.helios.common.descriptors.JobStatus)1 PortMapping (com.spotify.helios.common.descriptors.PortMapping)1 State (com.spotify.helios.common.descriptors.TaskStatus.State)1 JobDeleteResponse (com.spotify.helios.common.protocol.JobDeleteResponse)1 JobUndeployResponse (com.spotify.helios.common.protocol.JobUndeployResponse)1 SetGoalResponse (com.spotify.helios.common.protocol.SetGoalResponse)1 MasterMain (com.spotify.helios.master.MasterMain)1