use of com.spotify.helios.common.descriptors.JobId 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.descriptors.JobId 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.descriptors.JobId in project helios by spotify.
the class VolumeTest method testCli.
@Test
public void testCli() throws Exception {
final JobId jobId = createJob(job);
assertVolumes(jobId);
}
use of com.spotify.helios.common.descriptors.JobId 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);
}
use of com.spotify.helios.common.descriptors.JobId in project helios by spotify.
the class ResourcesTest method testClient.
@Test
public void testClient() throws Exception {
// Doesn't work on CircleCI because their lxc-driver can't set cpus
// See output of `docker run --cpuset-cpus 0-1 spotify/busybox:latest true`
assumeFalse(isCircleCi());
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);
assertJobEquals(job, taskStatus.getJob());
try (final DockerClient docker = getNewDockerClient()) {
final HostConfig hostConfig = docker.inspectContainer(taskStatus.getContainerId()).hostConfig();
assertEquals(CPU_SHARES, hostConfig.cpuShares());
assertEquals(CPUSET_CPUS, hostConfig.cpusetCpus());
final Info info = docker.info();
final Iterable<String> split = Splitter.on(".").split(docker.version().apiVersion());
//noinspection ConstantConditions
final int major = Integer.parseInt(Iterables.get(split, 0, "0"));
//noinspection ConstantConditions
final int minor = Integer.parseInt(Iterables.get(split, 1, "0"));
// TODO (dxia) This doesn't work on docker < 1.7 ie docker API < 1.19 for some reason.
if (major >= 1 && minor >= 19) {
if (info.memoryLimit()) {
assertEquals(MEMORY, hostConfig.memory());
}
if (info.swapLimit()) {
assertEquals(MEMORY_SWAP, hostConfig.memorySwap());
}
}
}
}
Aggregations