use of com.spotify.helios.common.descriptors.JobId in project helios by spotify.
the class Agent method startUp.
@Override
protected void startUp() throws Exception {
for (final Entry<JobId, Execution> entry : executions.get().entrySet()) {
final Execution execution = entry.getValue();
final Job job = execution.getJob();
if (execution.getPorts() != null) {
createSupervisor(job, execution.getPorts());
}
}
model.addListener(modelListener);
reactor.startAsync().awaitRunning();
reactor.signal();
}
use of com.spotify.helios.common.descriptors.JobId in project helios by spotify.
the class JobListCommandTest method setUp.
@Before
public void setUp() {
// use a real, dummy Subparser impl to avoid having to mock out every single call
final ArgumentParser parser = ArgumentParsers.newArgumentParser("test");
final Subparser subparser = parser.addSubparsers().addParser("list");
command = new JobListCommand(subparser);
when(client.jobs()).thenReturn(Futures.immediateFuture(jobs));
final Map<JobId, JobStatus> statuses = new HashMap<>();
for (final JobId jobId : jobs.keySet()) {
// pretend each job is deployed
final JobStatus status = JobStatus.newBuilder().setDeployments(ImmutableMap.of("host", Deployment.of(jobId, Goal.START))).build();
statuses.put(jobId, status);
}
when(client.jobStatuses(jobs.keySet())).thenReturn(Futures.immediateFuture(statuses));
}
use of com.spotify.helios.common.descriptors.JobId in project helios by spotify.
the class ExpiredJobReaperTest method testExpiredJobReaper.
@Test
public void testExpiredJobReaper() throws Exception {
when(mockClock.now()).thenReturn(new Instant(CURRENT_TS));
when(masterModel.getJobs()).thenReturn(JOBS);
when(masterModel.getJobStatus(any(JobId.class))).then(new Answer<JobStatus>() {
@Override
public JobStatus answer(final InvocationOnMock invocation) throws Throwable {
final JobId jobId = (JobId) invocation.getArguments()[0];
final Map<String, Deployment> deployments = ImmutableMap.of("hostA", Deployment.of(jobId, Goal.START), "hostB", Deployment.of(jobId, Goal.START));
return JobStatus.newBuilder().setJob(JOBS.get(jobId)).setDeployments(deployments).build();
}
});
ExpiredJobReaper.newBuilder().setClock(mockClock).setMasterModel(masterModel).build().runOneIteration();
// Make sure that the expiring job was removed, but that the non-expiring job
// and the job that expires far in the future were not.
verify(masterModel).undeployJob(eq("hostA"), eq(EXPIRING_JOB_ID), eq(""));
verify(masterModel).undeployJob(eq("hostB"), eq(EXPIRING_JOB_ID), eq(""));
verify(masterModel).removeJob(eq(EXPIRING_JOB_ID), eq(""));
verifyNoMoreInteractions(ignoreStubs(masterModel));
}
use of com.spotify.helios.common.descriptors.JobId in project helios by spotify.
the class CliDeploymentTest method testUndeployingNonexistantHostJson.
@Test
public void testUndeployingNonexistantHostJson() throws Exception {
startDefaultMaster();
// Wait for master to come up
Polling.await(LONG_WAIT_SECONDS, SECONDS, new Callable<String>() {
@Override
public String call() throws Exception {
final String output = cli("masters");
return output.contains(masterName()) ? output : null;
}
});
// Create job
final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, IDLE_COMMAND);
// Verify that undeploying a nonexistent job from a host fails
final String output = cli("undeploy", "--json", jobId.toString(), BOGUS_HOST);
final JobDeployResponse jobDeployResponse = Json.read(output, JobDeployResponse.class);
assertEquals(JobDeployResponse.Status.HOST_NOT_FOUND, jobDeployResponse.getStatus());
}
use of com.spotify.helios.common.descriptors.JobId in project helios by spotify.
the class ContainerHostNameTest method testValidHostname.
@Test
public void testValidHostname() throws Exception {
startDefaultMaster();
startDefaultAgent(testHost());
awaitHostStatus(testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
try (final DockerClient dockerClient = getNewDockerClient()) {
final List<String> command = asList("hostname", "-f");
// Create job
final JobId jobId = createJob(Job.newBuilder().setName(testJobName).setVersion(testJobVersion).setImage(BUSYBOX).setHostname(testHost()).setCommand(command).build());
// deploy
deployJob(jobId, testHost());
final TaskStatus taskStatus = awaitTaskState(jobId, testHost(), EXITED);
final String log;
try (final LogStream logs = dockerClient.logs(taskStatus.getContainerId(), stdout(), stderr())) {
log = logs.readFully();
}
assertThat(log, containsString(testHost()));
}
}
Aggregations