Search in sources :

Example 51 with Job

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

the class JobValidatorTest method testIdMismatchFails.

@Test
public void testIdMismatchFails() throws Exception {
    final Job job = new Job(JobId.fromString("foo:bar:badf00d"), "bar", EMPTY_HOSTNAME, EMPTY_CREATED, EMPTY_COMMAND, EMPTY_ENV, EMPTY_RESOURCES, EMPTY_PORTS, EMPTY_REGISTRATION, EMPTY_GRACE_PERIOD, EMPTY_VOLUMES, EMPTY_EXPIRES, EMPTY_REGISTRATION_DOMAIN, EMPTY_CREATING_USER, EMPTY_TOKEN, EMPTY_HEALTH_CHECK, EMPTY_SECURITY_OPT, DEFAULT_NETWORK_MODE, EMPTY_METADATA, EMPTY_CAPS, EMPTY_CAPS, EMPTY_SECONDS_TO_WAIT);
    final JobId recomputedId = job.toBuilder().build().getId();
    assertEquals(ImmutableSet.of("Id hash mismatch: " + job.getId().getHash() + " != " + recomputedId.getHash()), validator.validate(job));
}
Also used : Job(com.spotify.helios.common.descriptors.Job) JobId(com.spotify.helios.common.descriptors.JobId) Test(org.junit.Test)

Example 52 with Job

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

the class JobValidatorTest method testInvalidVolumesFail.

@Test
public void testInvalidVolumesFail() {
    final Job j = Job.newBuilder().setName("foo").setVersion("1").setImage("foobar").build();
    assertEquals(newHashSet("Invalid volume path: /"), validator.validate(j.toBuilder().addVolume("/").build()));
    assertEquals(newHashSet("Invalid volume path: /foo:"), validator.validate(j.toBuilder().addVolume("/foo:", "/bar").build()));
    assertEquals(newHashSet("Volume path is not absolute: foo"), validator.validate(j.toBuilder().addVolume("foo").build()));
    assertEquals(newHashSet("Volume path is not absolute: foo"), validator.validate(j.toBuilder().addVolume("foo", "/bar").build()));
    assertEquals(newHashSet("Volume source is not absolute: bar"), validator.validate(j.toBuilder().addVolume("/foo", "bar").build()));
}
Also used : Job(com.spotify.helios.common.descriptors.Job) Test(org.junit.Test)

Example 53 with Job

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

the class JobValidatorTest method testImageNameWithManyNameComponents.

@Test
public void testImageNameWithManyNameComponents() {
    final Job job = VALID_JOB.toBuilder().setImage("b.gcr.io/cloudsql-docker/and/more/components/gce-proxy:1.05").build();
    assertThat(validator.validate(job), is(empty()));
}
Also used : Job(com.spotify.helios.common.descriptors.Job) Test(org.junit.Test)

Example 54 with Job

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

the class JobValidatorTest method testImageNameInvalidTag.

@Test
public void testImageNameInvalidTag() {
    final Job job = VALID_JOB.toBuilder().setImage("foo/bar:a b c").build();
    assertThat(validator.validate(job), contains(containsString("Illegal tag: \"a b c\"")));
}
Also used : Job(com.spotify.helios.common.descriptors.Job) Test(org.junit.Test)

Example 55 with Job

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

the class TerminationTest method testTermOnExit.

@Test
public void testTermOnExit() throws Exception {
    startDefaultMaster();
    final String host = testHost();
    startDefaultAgent(host);
    final HeliosClient client = defaultClient();
    awaitHostStatus(client, host, UP, LONG_WAIT_SECONDS, SECONDS);
    // Note: signal 15 is SIGTERM
    final Job jobToInterrupt = Job.newBuilder().setName(testJobName).setVersion(testJobVersion).setImage(BUSYBOX).setCommand(asList("/bin/sh", "-c", "trap handle 15; handle() { echo term; exit 0; }; " + "while true; do sleep 1; done")).build();
    final JobId jobId = createJob(jobToInterrupt);
    deployJob(jobId, host);
    awaitTaskState(jobId, host, RUNNING);
    client.setGoal(new Deployment(jobId, Goal.STOP, Deployment.EMTPY_DEPLOYER_USER, Deployment.EMPTY_DEPLOYER_MASTER, Deployment.EMPTY_DEPLOYMENT_GROUP_NAME), host);
    final TaskStatus taskStatus = awaitTaskState(jobId, host, STOPPED);
    final String log;
    try (final DockerClient dockerClient = getNewDockerClient();
        LogStream logs = dockerClient.logs(taskStatus.getContainerId(), stdout())) {
        log = logs.readFully();
    }
    // Message expected, because the SIGTERM handler in the script should have run
    assertEquals("term\n", log);
}
Also used : DockerClient(com.spotify.docker.client.DockerClient) Deployment(com.spotify.helios.common.descriptors.Deployment) LogStream(com.spotify.docker.client.LogStream) HeliosClient(com.spotify.helios.client.HeliosClient) Job(com.spotify.helios.common.descriptors.Job) TaskStatus(com.spotify.helios.common.descriptors.TaskStatus) JobId(com.spotify.helios.common.descriptors.JobId) 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