Search in sources :

Example 31 with CreateJobResponse

use of com.spotify.helios.common.protocol.CreateJobResponse in project helios by spotify.

the class ApiTest method testHashLessJobCreation.

/**
   * Verify that the Helios master generates and returns a hash if the submitted job creation
   * request does not include one.
   */
@Test
public void testHashLessJobCreation() throws Exception {
    startDefaultMaster();
    final Job job = Job.newBuilder().setName(testJobName).setVersion(testJobVersion).setImage(BUSYBOX).setCommand(IDLE_COMMAND).setCreatingUser(TEST_USER).build();
    // Remove the hash from the id in the json serialized job
    final ObjectNode json = (ObjectNode) Json.reader().readTree(Json.asString(job));
    json.set("id", TextNode.valueOf(testJobName + ":" + testJobVersion));
    final HttpURLConnection req = post("/jobs?user=" + TEST_USER, Json.asBytes(json));
    assertEquals(req.getResponseCode(), 200);
    final CreateJobResponse res = Json.read(toByteArray(req.getInputStream()), CreateJobResponse.class);
    assertEquals(OK, res.getStatus());
    assertTrue(res.getErrors().isEmpty());
    assertEquals(job.getId().toString(), res.getId());
}
Also used : HttpURLConnection(java.net.HttpURLConnection) CreateJobResponse(com.spotify.helios.common.protocol.CreateJobResponse) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Job(com.spotify.helios.common.descriptors.Job) Test(org.junit.Test)

Aggregations

CreateJobResponse (com.spotify.helios.common.protocol.CreateJobResponse)31 Test (org.junit.Test)24 Job (com.spotify.helios.common.descriptors.Job)16 JobDeployResponse (com.spotify.helios.common.protocol.JobDeployResponse)16 HeliosClient (com.spotify.helios.client.HeliosClient)14 Deployment (com.spotify.helios.common.descriptors.Deployment)14 JobId (com.spotify.helios.common.descriptors.JobId)13 TaskStatus (com.spotify.helios.common.descriptors.TaskStatus)7 DockerClient (com.spotify.docker.client.DockerClient)6 AgentMain (com.spotify.helios.agent.AgentMain)4 JobUndeployResponse (com.spotify.helios.common.protocol.JobUndeployResponse)4 HostStatus (com.spotify.helios.common.descriptors.HostStatus)3 JobDeleteResponse (com.spotify.helios.common.protocol.JobDeleteResponse)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Container (com.spotify.docker.client.messages.Container)2 HostConfig (com.spotify.docker.client.messages.HostConfig)2 PortMapping (com.spotify.helios.common.descriptors.PortMapping)2 HostDeregisterResponse (com.spotify.helios.common.protocol.HostDeregisterResponse)2 Integer.toHexString (java.lang.Integer.toHexString)2 List (java.util.List)2