@Test
  public void test() throws Exception {
    startDefaultMaster();
    final HeliosClient client = defaultClient();

    final CreateJobResponse createIdMismatch =
        client
            .createJob(
                new Job(
                    JobId.fromString("bad:job:deadbeef"),
                    BUSYBOX,
                    EMPTY_HOSTNAME,
                    IDLE_COMMAND,
                    EMPTY_ENV,
                    EMPTY_RESOURCES,
                    EMPTY_PORTS,
                    EMPTY_REGISTRATION,
                    EMPTY_GRACE_PERIOD,
                    EMPTY_VOLUMES,
                    EMPTY_EXPIRES,
                    EMPTY_REGISTRATION_DOMAIN,
                    EMPTY_CREATING_USER,
                    EMPTY_TOKEN,
                    EMPTY_HEALTH_CHECK,
                    EMPTY_SECURITY_OPT,
                    EMPTY_NETWORK_MODE))
            .get();

    // TODO (dano): Maybe this should be ID_MISMATCH but then JobValidator must become able to
    // TODO (dano): communicate that
    assertEquals(CreateJobResponse.Status.INVALID_JOB_DEFINITION, createIdMismatch.getStatus());
  }
  @Test
  public void test() throws Exception {
    startDefaultMaster();
    startDefaultAgent(testHost());

    final HeliosClient client = defaultClient();

    // Create a job using an image exposing port 11211 but without mapping it
    final Job job1 =
        Job.newBuilder()
            .setName(testTag + "memcached")
            .setVersion("v1")
            .setImage("rohan/memcached-mini")
            .build();
    final JobId jobId1 = job1.getId();
    client.createJob(job1).get();

    // Create a job using an image exposing port 11211 and map it to a specific external port
    final Job job2 =
        Job.newBuilder()
            .setName(testTag + "memcached")
            .setVersion("v2")
            .setImage("rohan/memcached-mini")
            .setPorts(ImmutableMap.of("tcp", PortMapping.of(11211, externalPort)))
            .build();
    final JobId jobId2 = job2.getId();
    client.createJob(job2).get();

    // Wait for agent to come up
    awaitHostRegistered(client, testHost(), LONG_WAIT_MINUTES, MINUTES);
    awaitHostStatus(client, testHost(), UP, LONG_WAIT_MINUTES, MINUTES);

    // Deploy the jobs on the agent
    client.deploy(Deployment.of(jobId1, START), testHost()).get();
    client.deploy(Deployment.of(jobId2, START), testHost()).get();

    // Wait for the jobs to run
    awaitJobState(client, testHost(), jobId1, RUNNING, LONG_WAIT_MINUTES, MINUTES);
    awaitJobState(client, testHost(), jobId2, RUNNING, LONG_WAIT_MINUTES, MINUTES);
  }
Exemplo n.º 3
0
 @Test
 public void testClient() throws Exception {
   final CreateJobResponse created = client.createJob(job).get();
   assertEquals(CreateJobResponse.Status.OK, created.getStatus());
   assertVolumes(job.getId());
 }