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