use of com.spotify.helios.common.protocol.CreateJobResponse in project helios by spotify.
the class IdMismatchJobCreateTest method test.
@Test
public void test() throws Exception {
startDefaultMaster();
final HeliosClient client = defaultClient();
final CreateJobResponse createIdMismatch = client.createJob(new Job(JobId.fromString("bad:job:deadbeef"), BUSYBOX, EMPTY_HOSTNAME, EMPTY_CREATED, IDLE_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)).get();
// TODO (dano): Maybe this should be ID_MISMATCH but then JobValidator must become able to
// TODO (dano): communicate that
assertEquals(CreateJobResponse.Status.INVALID_JOB_DEFINITION, createIdMismatch.getStatus());
}
use of com.spotify.helios.common.protocol.CreateJobResponse in project helios by spotify.
the class NamespaceTest method test.
@Test
public void test() throws Exception {
startDefaultMaster();
final String id = "test-" + Integer.toHexString(new SecureRandom().nextInt());
final String namespace = "helios-" + id;
final HeliosClient client = defaultClient();
startDefaultAgent(testHost(), "--id=" + id);
// Create a job
final Job job = Job.newBuilder().setName(testJobName).setVersion(testJobVersion).setImage(BUSYBOX).setCommand(IDLE_COMMAND).build();
final JobId jobId = job.getId();
final CreateJobResponse created = client.createJob(job).get();
assertEquals(CreateJobResponse.Status.OK, created.getStatus());
// Wait for agent to come up
awaitHostRegistered(client, testHost(), LONG_WAIT_SECONDS, SECONDS);
awaitHostStatus(client, testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
// Deploy the job on the agent
final Deployment deployment = Deployment.of(jobId, START);
final JobDeployResponse deployed = client.deploy(deployment, testHost()).get();
assertEquals(JobDeployResponse.Status.OK, deployed.getStatus());
awaitJobState(client, testHost(), jobId, RUNNING, LONG_WAIT_SECONDS, SECONDS);
try (final DockerClient docker = getNewDockerClient()) {
final List<Container> containers = docker.listContainers();
Container jobContainer = null;
for (final Container container : containers) {
for (final String name : container.names()) {
if (name.startsWith("/" + namespace)) {
jobContainer = container;
}
}
}
assertNotNull(jobContainer);
}
}
use of com.spotify.helios.common.protocol.CreateJobResponse in project helios by spotify.
the class NetworkModeTest method test.
@Test
public void test() throws Exception {
final CreateJobResponse created = client.createJob(job).get();
assertEquals(CreateJobResponse.Status.OK, created.getStatus());
final JobId jobId = job.getId();
// Wait for agent to come up
awaitHostRegistered(client, testHost(), LONG_WAIT_SECONDS, SECONDS);
awaitHostStatus(client, testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
// Deploy the job on the agent
final Deployment deployment = Deployment.of(jobId, START);
final JobDeployResponse deployed = client.deploy(deployment, testHost()).get();
assertEquals(JobDeployResponse.Status.OK, deployed.getStatus());
// Wait for the job to run
final TaskStatus taskStatus = awaitJobState(client, testHost(), jobId, RUNNING, LONG_WAIT_SECONDS, SECONDS);
try (final DockerClient docker = getNewDockerClient()) {
final HostConfig hostConfig = docker.inspectContainer(taskStatus.getContainerId()).hostConfig();
assertEquals(NETWORK_MODE, hostConfig.networkMode());
}
}
use of com.spotify.helios.common.protocol.CreateJobResponse in project helios by spotify.
the class QueryFailureTest method testJobStatusHostFilter.
@Test
public void testJobStatusHostFilter() throws Exception {
startDefaultMaster();
final HeliosClient client = defaultClient();
startDefaultAgent(testHost());
// Create a job
final Job job = Job.newBuilder().setName(testJobName).setVersion(testJobVersion).setImage(BUSYBOX).setCommand(IDLE_COMMAND).setPorts(EMPTY_PORTS).build();
final CreateJobResponse created = client.createJob(job).get();
assertEquals(CreateJobResponse.Status.OK, created.getStatus());
final String result = cli("status", "--host", "framazama");
assertThat(result, containsString("There are no jobs deployed to hosts with the host pattern"));
}
use of com.spotify.helios.common.protocol.CreateJobResponse in project helios by spotify.
the class ZooKeeperHeliosFailoverTest method deploy.
private void deploy(final Job job) throws Exception {
final JobId jobId = job.getId();
final CreateJobResponse created = client.createJob(job).get();
assertEquals(CreateJobResponse.Status.OK, created.getStatus());
final Deployment deployment = Deployment.of(jobId, START);
final JobDeployResponse deployed = client.deploy(deployment, testHost()).get();
assertEquals(JobDeployResponse.Status.OK, deployed.getStatus());
// Wait for the job to run
awaitJobState(client, testHost(), jobId, RUNNING, LONG_WAIT_SECONDS, SECONDS);
}
Aggregations