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);
}
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);
}
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);
}
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();
}
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);
}
}
Aggregations