Search in sources :

Example 6 with HostNotFoundException

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());
}
Also used : HostNotFoundException(com.spotify.helios.master.HostNotFoundException) Deployment(com.spotify.helios.common.descriptors.Deployment) JobNotDeployedException(com.spotify.helios.master.JobNotDeployedException) Job(com.spotify.helios.common.descriptors.Job) JobStillDeployedException(com.spotify.helios.master.JobStillDeployedException) DeploymentGroupDoesNotExistException(com.spotify.helios.master.DeploymentGroupDoesNotExistException) DeploymentGroupExistsException(com.spotify.helios.master.DeploymentGroupExistsException) HostNotFoundException(com.spotify.helios.master.HostNotFoundException) ExpectedException(org.junit.rules.ExpectedException) JobDoesNotExistException(com.spotify.helios.master.JobDoesNotExistException) JobNotDeployedException(com.spotify.helios.master.JobNotDeployedException) HeliosException(com.spotify.helios.common.HeliosException) JobId(com.spotify.helios.common.descriptors.JobId) Test(org.junit.Test)

Aggregations

HostNotFoundException (com.spotify.helios.master.HostNotFoundException)6 JobId (com.spotify.helios.common.descriptors.JobId)3 JobDoesNotExistException (com.spotify.helios.master.JobDoesNotExistException)3 HeliosRuntimeException (com.spotify.helios.common.HeliosRuntimeException)2 Deployment (com.spotify.helios.common.descriptors.Deployment)2 Job (com.spotify.helios.common.descriptors.Job)2 JobNotDeployedException (com.spotify.helios.master.JobNotDeployedException)2 JobStillDeployedException (com.spotify.helios.master.JobStillDeployedException)2 TokenVerificationException (com.spotify.helios.master.TokenVerificationException)2 ZooKeeperOperation (com.spotify.helios.servicescommon.coordination.ZooKeeperOperation)2 KeeperException (org.apache.zookeeper.KeeperException)2 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)2 Test (org.junit.Test)2 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)1 Timed (com.codahale.metrics.annotation.Timed)1 ImmutableList (com.google.common.collect.ImmutableList)1 HeliosException (com.spotify.helios.common.HeliosException)1 JobStatus (com.spotify.helios.common.descriptors.JobStatus)1 JobDeployResponse (com.spotify.helios.common.protocol.JobDeployResponse)1 DeploymentGroupDoesNotExistException (com.spotify.helios.master.DeploymentGroupDoesNotExistException)1