use of com.spotify.helios.master.HostNotFoundException in project helios by spotify.
the class ZooKeeperMasterModelIntegrationTest method testUpdateDeploy.
@Test
public void testUpdateDeploy() throws Exception {
try {
stopJob(model, JOB);
fail("should have thrown JobNotDeployedException");
} catch (JobNotDeployedException e) {
assertTrue(true);
} catch (Exception e) {
fail("Should have thrown an JobNotDeployedException, got " + e.getClass());
}
model.addJob(JOB);
try {
stopJob(model, JOB);
fail("should have thrown exception");
} catch (HostNotFoundException e) {
assertTrue(true);
} catch (Exception e) {
fail("Should have thrown an HostNotFoundException");
}
model.registerHost(HOST, "foo");
final List<String> hosts = model.listHosts();
assertThat(hosts, hasItem(HOST));
try {
stopJob(model, JOB);
fail("should have thrown exception");
} catch (JobNotDeployedException e) {
assertTrue(true);
} catch (Exception e) {
fail("Should have thrown an JobNotDeployedException");
}
model.deployJob(HOST, Deployment.newBuilder().setGoal(Goal.START).setJobId(JOB.getId()).build());
final Map<JobId, Job> jobsOnHost = model.getJobs();
assertEquals(1, jobsOnHost.size());
final Job descriptor = jobsOnHost.get(JOB.getId());
assertEquals(JOB, descriptor);
// should succeed this time!
stopJob(model, JOB);
final Deployment jobCfg = model.getDeployment(HOST, JOB.getId());
assertEquals(Goal.STOP, jobCfg.getGoal());
}
Aggregations