private void deploy(final Job job, final String host) throws Exception { Futures.addCallback(client.deploy(Deployment.of(job.getId(), START), host), new FutureCallback<JobDeployResponse>() { @Override public void onSuccess(final JobDeployResponse result) { assertEquals(JobDeployResponse.Status.OK, result.getStatus()); } @Override public void onFailure(@NotNull final Throwable th) { fail("deploy failed"); } }, MoreExecutors.directExecutor()); }
private JobId createAndAwaitJobRunning() throws Exception { final CreateJobResponse jobby = client.createJob(job).get(); assertEquals(CreateJobResponse.Status.OK, jobby.getStatus()); final JobId jobId = job.getId(); final JobDeployResponse deployResponse = client.deploy( Deployment.of(jobId, START), TEST_HOST).get(); assertEquals(JobDeployResponse.Status.OK, deployResponse.getStatus()); awaitJobState(client, TEST_HOST, jobId, State.RUNNING, 30, TimeUnit.SECONDS); return jobId; }
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); }
private Map<JobId, Deployment> getTasks(final ZooKeeperClient client, final String host) { final Map<JobId, Deployment> jobs = Maps.newHashMap(); try { final String folder = Paths.configHostJobs(host); final List<String> jobIds; try { jobIds = client.getChildren(folder); } catch (KeeperException.NoNodeException e) { log.warn("Unable to get deployment config for {}", host, e); return ImmutableMap.of(); } for (final String jobIdString : jobIds) { final JobId jobId = JobId.fromString(jobIdString); final String containerPath = Paths.configHostJob(host, jobId); try { final byte[] data = client.getData(containerPath); final Task task = parse(data, Task.class); jobs.put(jobId, Deployment.of(jobId, task.getGoal(), task.getDeployerUser(), task.getDeployerMaster(), task.getDeploymentGroupName())); } catch (KeeperException.NoNodeException ignored) { log.debug("deployment config node disappeared: {}", jobIdString); } } } catch (KeeperException | IOException e) { throw new HeliosRuntimeException("getting deployment config failed", e); } return jobs; }
client.deploy(Deployment.of(jobId, Goal.START), testHost()); awaitJobState(client, testHost(), jobId, RUNNING, LONG_WAIT_SECONDS, SECONDS);
private RollingUpdateOp rollingUpdateDeploy(final ZooKeeperClient client, final RollingUpdateOpFactory opFactory, final DeploymentGroup deploymentGroup, final String host) { final Deployment deployment = Deployment.of(deploymentGroup.getJobId(), Goal.START, Deployment.EMTPY_DEPLOYER_USER, this.name, deploymentGroup.getName()); try { final String token = MoreObjects.firstNonNull( deploymentGroup.getRolloutOptions().getToken(), Job.EMPTY_TOKEN); return opFactory.nextTask(getDeployOperations(client, host, deployment, token)); } catch (JobDoesNotExistException e) { return opFactory.error(e, host, RollingUpdateError.JOB_NOT_FOUND); } catch (TokenVerificationException e) { return opFactory.error(e, host, RollingUpdateError.TOKEN_VERIFICATION_ERROR); } catch (HostNotFoundException e) { return opFactory.error(e, host, RollingUpdateError.HOST_NOT_FOUND); } catch (JobPortAllocationConflictException e) { return opFactory.error(e, host, RollingUpdateError.PORT_CONFLICT); } catch (JobAlreadyDeployedException e) { // Nothing to do return opFactory.nextTask(); } }
/** * Returns the current deployment state of {@code jobId} on {@code host}. */ @Override public Deployment getDeployment(final String host, final JobId jobId) { final String path = Paths.configHostJob(host, jobId); final ZooKeeperClient client = provider.get("getDeployment"); try { final byte[] data = client.getData(path); final Task task = parse(data, Task.class); return Deployment.of(jobId, task.getGoal(), task.getDeployerUser(), task.getDeployerMaster(), task.getDeploymentGroupName()); } catch (KeeperException.NoNodeException e) { return null; } catch (KeeperException | IOException e) { throw new HeliosRuntimeException("getting deployment failed", e); } }
public void assertRamdisk(final JobId jobId) throws Exception { // 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()); final Integer dfPort = taskStatus.getPorts().get("df").getExternalPort(); assert dfPort != null; // If "/much-volatile" mount is present a line starting with tmpfs should be returned final String dfOutput = recvUtf8(dfPort, 5); assertEquals("tmpfs", dfOutput); }
public void assertVolumes(final JobId jobId) throws Exception { // 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()); final Integer randomVolPort = taskStatus.getPorts().get("random").getExternalPort(); final Integer namedVolPort = taskStatus.getPorts().get("named").getExternalPort(); final Integer hostnamePort = taskStatus.getPorts().get("hostname").getExternalPort(); assert randomVolPort != null; assert namedVolPort != null; assert hostnamePort != null; // Read "foo" from /volume/bar and /mnt/my-volume/bar assertEquals("foo", recvUtf8(randomVolPort, 3)); assertEquals("foo", recvUtf8(namedVolPort, 3)); // Read hostname from /hostname final String hostname = getNewDockerClient().info().name(); final String mountedHostname = recvUtf8(hostnamePort, hostname.length()); assertEquals(hostname, mountedHostname); }
final Deployment deployment = Deployment.of(jobId, START); final JobDeployResponse deployed = client.deploy(deployment, host).get(); assertEquals(JobDeployResponse.Status.OK, deployed.getStatus());
assertEquals(CreateJobResponse.Status.OK, created2.getStatus()); final Deployment deployment1 = Deployment.of(job1.getId(), STOP); final JobDeployResponse deployed1 = client.deploy(deployment1, testHost()).get(); assertEquals(JobDeployResponse.Status.OK, deployed1.getStatus()); final Deployment deployment2 = Deployment.of(job2.getId(), STOP); final JobDeployResponse deployed2 = client.deploy(deployment2, testHost()).get(); assertEquals(JobDeployResponse.Status.PORT_CONFLICT, deployed2.getStatus());
final Deployment deployment = Deployment.of(jobId, START); final JobDeployResponse deployed = client.deploy(deployment, testHost()).get(); assertEquals(JobDeployResponse.Status.OK, deployed.getStatus());
final Deployment deployment = Deployment.of(jobId, START); final JobDeployResponse deployed = client.deploy(deployment, testHost()).get(); assertEquals(JobDeployResponse.Status.OK, deployed.getStatus());
@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()); } } }
final Deployment deployment = Deployment.of(jobId, START, TEST_USER); final JobDeployResponse deployed = client.deploy(deployment, testHost()).get(); assertEquals(JobDeployResponse.Status.OK, deployed.getStatus());
final Deployment deployment = Deployment.of(jobId, START); final JobDeployResponse deployed = client.deploy(deployment, host).get(); assertEquals(JobDeployResponse.Status.OK, deployed.getStatus());
assertEquals(CreateJobResponse.Status.OK, created.getStatus()); final Deployment deployment = Deployment.of(jobId, START);
final Deployment deployment = Deployment.of(fooJob.getId(), START); final JobDeployResponse deployed = client.deploy(deployment, testHost()).get(); assertEquals(JobDeployResponse.Status.OK, deployed.getStatus());