@Override public int hashCode() { return status != null ? status.hashCode() : 0; } }
@Override public int hashCode() { return status != null ? status.hashCode() : 0; } }
@Override public int hashCode() { return status != null ? status.hashCode() : 0; } }
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; }
@Test public void testJsonVersion() throws Exception { startDefaultMaster(); final VersionResponse version = getVersion("version", "--json", "-z", masterEndpoint()); assertEquals("wrong client version", POM_VERSION, version.getClientVersion()); assertEquals("wrong master version", POM_VERSION, version.getMasterVersion()); }
@Override public void onSuccess(final JobDeployResponse result) { assertEquals(JobDeployResponse.Status.OK, result.getStatus()); }
@Override public void onSuccess(final JobUndeployResponse result) { assertEquals(JobUndeployResponse.Status.OK, result.getStatus()); }
@Test public void testTemplateUnknownJobJsonOutput() throws Exception { // Trying to create a job with a non-existant job as a template should return JSON with // UNKNOWN_JOB final String output = cli("create", "--json", "--template", "non-existant-job", testJobNameAndVersion, BUSYBOX); final CreateJobResponse createJobResponse = Json.read(output, CreateJobResponse.class); assertEquals(CreateJobResponse.Status.UNKNOWN_JOB, createJobResponse.getStatus()); }
private void remove(final String token, final JobDeleteResponse.Status status) throws Exception { final List<String> args = buildArgs(token, "--yes", testJobNameAndVersion); final JobDeleteResponse response = cliJson(JobDeleteResponse.class, "remove", args); assertThat(response.getStatus(), equalTo(status)); }
private void stop(final String token, final SetGoalResponse.Status status) throws Exception { final List<String> args = buildArgs(token, testJobNameAndVersion, testHost()); final SetGoalResponse response = cliJson(SetGoalResponse.class, "stop", args); assertThat(response.getStatus(), equalTo(status)); }
@Test public void testStatusNoRollingUpdate() throws Exception { cli("create-deployment-group", "--json", TEST_GROUP, "foo=bar", "baz=qux"); assertEquals(DeploymentGroupStatusResponse.Status.IDLE, OBJECT_MAPPER.readValue(cli("deployment-group-status", "--json", TEST_GROUP), DeploymentGroupStatusResponse.class).getStatus()); }
@Test public void testRollingUpdateGroupNotFound() throws Exception { cli("create-deployment-group", "--json", TEST_GROUP, "foo=bar", "baz=qux"); cli("create", "my_job:2", "my_image"); assertEquals(RollingUpdateResponse.Status.DEPLOYMENT_GROUP_NOT_FOUND, OBJECT_MAPPER.readValue(cli("rolling-update", "--json", "--async", "my_job:2", "oops"), RollingUpdateResponse.class).getStatus()); }
@Override public Object call() throws Exception { final TaskStatusEvents jobHistory = getOrNull(client.jobHistory(jobId)); for (final TaskStatusEvent event : jobHistory.getEvents()) { if (event.getStatus().getState() == FAILED) { return true; } } return null; } });
@Override public int hashCode() { int result = deploymentGroup != null ? deploymentGroup.hashCode() : 0; result = 31 * result + (status != null ? status.hashCode() : 0); result = 31 * result + (error != null ? error.hashCode() : 0); result = 31 * result + (hostStatuses != null ? hostStatuses.hashCode() : 0); result = 31 * result + (deploymentGroupStatus != null ? deploymentGroupStatus.hashCode() : 0); return result; } }
@Override public ListenableFuture<VersionResponse> apply(@NotNull Response reply) throws Exception { final String masterVersion = reply == null ? "Unable to connect to master" : reply.status() == HTTP_OK ? Json.read(reply.payload(), String.class) : "Master replied with error code " + reply.status(); return immediateFuture(new VersionResponse(Version.POM_VERSION, masterVersion)); } }, MoreExecutors.directExecutor());
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); }
@Test public void testVersionWithServerError() throws Exception { startDefaultMaster(); // If master returns with an error, we should still get the correct client version, and a // nice error message instead of master version. Specify bogus path to make this happen. final VersionResponse version = getVersion("version", "--json", "-z", masterEndpoint() + "/badPath"); assertEquals("wrong client version", POM_VERSION, version.getClientVersion()); assertEquals("wrong master version", "Master replied with error code 404", version.getMasterVersion()); }
private void deploy(final String token, final JobDeployResponse.Status status) throws Exception { final List<String> args = buildArgs(token, testJobNameAndVersion, testHost()); final JobDeployResponse response = cliJson(JobDeployResponse.class, "deploy", args); assertThat(response.getStatus(), equalTo(status)); }
private void undeploy(final String token, final JobUndeployResponse.Status status) throws Exception { final List<String> args = buildArgs(token, testJobNameAndVersion, testHost()); final JobUndeployResponse response = cliJson(JobUndeployResponse.class, "undeploy", args); assertThat(response.getStatus(), equalTo(status)); }
@Test public void testTemplateAmbiguousJobJsonOutput() throws Exception { // Create two jobs cli("create", testJobNameAndVersion, BUSYBOX); cli("create", testJobNameAndVersion + "1", BUSYBOX); // Trying to create a job with an ambiguous template reference should return JSON with // AMBIGUOUS_JOB_REFERENCE final String output = cli("create", "--json", "--template", testJobNameAndVersion, testJobNameAndVersion, BUSYBOX); final CreateJobResponse createJobResponse = Json.read(output, CreateJobResponse.class); assertEquals(CreateJobResponse.Status.AMBIGUOUS_JOB_REFERENCE, createJobResponse.getStatus()); }