Search in sources :

Example 1 with Job

use of com.spotify.helios.common.descriptors.Job in project helios by spotify.

the class JobValidatorTest method testPortMappingCollisionFails.

@Test
public void testPortMappingCollisionFails() throws Exception {
    final Job job = Job.newBuilder().setName("foo").setVersion("1").setImage("bar").setPorts(ImmutableMap.of("1", PortMapping.of(1, 1), "2", PortMapping.of(2, 1))).build();
    assertEquals(ImmutableSet.of("Duplicate external port mapping: 1"), validator.validate(job));
}
Also used : Job(com.spotify.helios.common.descriptors.Job) Test(org.junit.Test)

Example 2 with Job

use of com.spotify.helios.common.descriptors.Job in project helios by spotify.

the class JobValidatorTest method testExpiry.

@Test
public void testExpiry() {
    // make a date that's 24 hours behind
    final java.util.Date d = new java.util.Date(System.currentTimeMillis() - (86400 * 1000));
    final Job j = Job.newBuilder().setName("foo").setVersion("1").setImage("foobar").setExpires(d).build();
    assertEquals(newHashSet("Job expires in the past"), validator.validate(j));
}
Also used : Job(com.spotify.helios.common.descriptors.Job) Test(org.junit.Test)

Example 3 with Job

use of com.spotify.helios.common.descriptors.Job in project helios by spotify.

the class JobValidatorTest method testValidNetworkModesPass.

@Test
public void testValidNetworkModesPass() {
    Job job = Job.newBuilder().setName("foo").setVersion("1").setImage("foobar").setNetworkMode("bridge").build();
    assertEquals(0, validator.validate(job).size());
    job = Job.newBuilder().setName("foo").setVersion("1").setImage("foobar").setNetworkMode("host").build();
    assertEquals(0, validator.validate(job).size());
    job = Job.newBuilder().setName("foo").setVersion("1").setImage("foobar").setNetworkMode("container:foo").build();
    assertEquals(0, validator.validate(job).size());
}
Also used : Job(com.spotify.helios.common.descriptors.Job) Test(org.junit.Test)

Example 4 with Job

use of com.spotify.helios.common.descriptors.Job in project helios by spotify.

the class MultipleHostsTest method testFilteringJobAndHostStatuses.

@Test
public void testFilteringJobAndHostStatuses() throws Exception {
    final String aHost = testHost() + "a";
    final String bHost = testHost() + "b";
    startDefaultMaster();
    startDefaultAgent(aHost);
    startDefaultAgent(bHost);
    awaitHostStatus(aHost, UP, LONG_WAIT_SECONDS, SECONDS);
    awaitHostStatus(bHost, UP, LONG_WAIT_SECONDS, SECONDS);
    final HeliosClient client = defaultClient();
    final Job job = Job.newBuilder().setName(testJobName + "I_WANT_THIS_ONE").setVersion(testJobVersion).setImage(BUSYBOX).setCommand(IDLE_COMMAND).setCreatingUser(TEST_USER).build();
    final JobId jobId = job.getId();
    client.createJob(job).get();
    final Job job2 = Job.newBuilder().setName(testJobName).setVersion(testJobVersion).setImage(BUSYBOX).setCommand(IDLE_COMMAND).setCreatingUser(TEST_USER).build();
    final JobId jobId2 = job2.getId();
    client.createJob(job2).get();
    final Deployment deployment = Deployment.of(jobId, Goal.START);
    client.deploy(deployment, aHost);
    client.deploy(deployment, bHost);
    client.deploy(Deployment.of(jobId2, Goal.START), aHost);
    awaitJobState(client, aHost, jobId, State.RUNNING, LONG_WAIT_SECONDS, TimeUnit.SECONDS);
    awaitJobState(client, bHost, jobId, State.RUNNING, LONG_WAIT_SECONDS, TimeUnit.SECONDS);
    awaitJobState(client, aHost, jobId2, State.RUNNING, LONG_WAIT_SECONDS, TimeUnit.SECONDS);
    final Map<JobId, JobStatus> cliStatuses = new ObjectMapper().readValue(cli("status", "--job", "I_WANT_THIS_ONE", "--host", aHost, "--json"), new TypeReference<Map<JobId, JobStatus>>() {
    });
    assertEquals("status should only have one job", 1, cliStatuses.size());
    assertTrue(cliStatuses.containsKey(jobId));
    final JobStatus status = cliStatuses.get(jobId);
    assertEquals("deployments should have only one item", 1, status.getDeployments().size());
    assertTrue("should only have deployment info for aHost", status.getDeployments().containsKey(aHost));
    assertEquals("Task statuses should only have one item", 1, status.getTaskStatuses().size());
    assertTrue("should only have status info for aHost", status.getTaskStatuses().containsKey(aHost));
}
Also used : JobStatus(com.spotify.helios.common.descriptors.JobStatus) Deployment(com.spotify.helios.common.descriptors.Deployment) HeliosClient(com.spotify.helios.client.HeliosClient) Job(com.spotify.helios.common.descriptors.Job) Map(java.util.Map) JobId(com.spotify.helios.common.descriptors.JobId) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 5 with Job

use of com.spotify.helios.common.descriptors.Job in project helios by spotify.

the class HealthCheckTest method testTcp.

@Test
public void testTcp() throws Exception {
    startDefaultMaster();
    final HeliosClient client = defaultClient();
    startDefaultAgent(testHost(), "--service-registry=" + registryAddress);
    awaitHostStatus(client, testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
    final HealthCheck healthCheck = TcpHealthCheck.of("health");
    final Job job = pokeJob(healthCheck);
    assertContainerRegistersAfterPoke(client, job);
}
Also used : HttpHealthCheck(com.spotify.helios.common.descriptors.HttpHealthCheck) HealthCheck(com.spotify.helios.common.descriptors.HealthCheck) ExecHealthCheck(com.spotify.helios.common.descriptors.ExecHealthCheck) TcpHealthCheck(com.spotify.helios.common.descriptors.TcpHealthCheck) HeliosClient(com.spotify.helios.client.HeliosClient) Job(com.spotify.helios.common.descriptors.Job) Test(org.junit.Test)

Aggregations

Job (com.spotify.helios.common.descriptors.Job)79 Test (org.junit.Test)57 JobId (com.spotify.helios.common.descriptors.JobId)38 HeliosClient (com.spotify.helios.client.HeliosClient)25 Deployment (com.spotify.helios.common.descriptors.Deployment)21 CreateJobResponse (com.spotify.helios.common.protocol.CreateJobResponse)16 TaskStatus (com.spotify.helios.common.descriptors.TaskStatus)15 JobStatus (com.spotify.helios.common.descriptors.JobStatus)12 JobDeployResponse (com.spotify.helios.common.protocol.JobDeployResponse)11 ZooKeeperClient (com.spotify.helios.servicescommon.coordination.ZooKeeperClient)10 KeeperException (org.apache.zookeeper.KeeperException)10 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)10 PortMapping (com.spotify.helios.common.descriptors.PortMapping)9 HeliosRuntimeException (com.spotify.helios.common.HeliosRuntimeException)8 ServiceEndpoint (com.spotify.helios.common.descriptors.ServiceEndpoint)8 Matchers.containsString (org.hamcrest.Matchers.containsString)8 DockerClient (com.spotify.docker.client.DockerClient)7 ZooKeeperOperation (com.spotify.helios.servicescommon.coordination.ZooKeeperOperation)7 IOException (java.io.IOException)7 ServicePorts (com.spotify.helios.common.descriptors.ServicePorts)6