Package com.spotify.helios.common.descriptors

Examples of com.spotify.helios.common.descriptors.TaskStatus


                                                    "BAR", "deadbeef"));

      // deploy
      deployJob(jobId, testHost());

      final TaskStatus taskStatus = awaitTaskState(jobId, testHost(), EXITED);

      final LogStream logs = dockerClient.logs(taskStatus.getContainerId(), STDOUT, STDERR);
      final String log = logs.readFully();

      assertThat(log, containsString("pod: PODNAME"));
      assertThat(log, containsString("role: ROLENAME"));
      assertThat(log, containsString("foo: 4711"));
View Full Code Here


    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());

    try (final DockerClient docker = getNewDockerClient()) {

      final ContainerConfig containerConfig =
          docker.inspectContainer(taskStatus.getContainerId()).config();

      assertEquals(MEMORY, containerConfig.memory());
      assertEquals(MEMORY_SWAP, containerConfig.memorySwap());
      assertEquals(CPU_SHARES, containerConfig.cpuShares());
      assertEquals(CPUSET, containerConfig.cpuset());
View Full Code Here

    final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX,
                                  asList("cat", "/etc/resolv.conf"));

    deployJob(jobId, testHost());

    final TaskStatus taskStatus = awaitTaskState(jobId, testHost(), EXITED);
    try (final DockerClient dockerClient = getNewDockerClient()) {
      final LogStream logs = dockerClient.logs(taskStatus.getContainerId(), STDOUT, STDERR);
      final String log = logs.readFully();

      assertThat(log, containsString(server1));
      assertThat(log, containsString(server2));
    }
View Full Code Here

    final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX,
                                  asList("cat", "/etc/resolv.conf"));

    deployJob(jobId, testHost());

    final TaskStatus taskStatus = awaitTaskState(jobId, testHost(), EXITED);
    try (final DockerClient dockerClient = getNewDockerClient()) {
      final LogStream logs = dockerClient.logs(taskStatus.getContainerId(), STDOUT, STDERR);
      final String log = logs.readFully();

      // Verify that a nameserver is set even if we don't specify the --dns param
      assertThat(log, containsString("nameserver"));
    }
View Full Code Here

  public void testAgent() throws Exception {
    final JobId jobId = createAndAwaitJobRunning();

    final byte[] data1 = curator.getData().forPath(Paths.statusHostJob(TEST_HOST, jobId));
    assertNotNull(data1);
    final TaskStatus status = Json.read(data1, TaskStatus.class);
    assertNotNull(status);
    assertEquals(START, status.getGoal());
    assertEquals(RUNNING, status.getState());

    // stop so we can create and maintain the tombstone
    agent.stopAsync().awaitTerminated();

    // create tombstone
    client.undeploy(jobId, TEST_HOST).get();

    final byte[] data2 = curator.getData().forPath(Paths.statusHostJob(TEST_HOST, jobId));
    assertNotNull(data2);
    final TaskStatus status2 = Json.read(data2, TaskStatus.class);
    assertNotNull(status2);
    assertEquals(START, status2.getGoal());
    assertEquals(RUNNING, status2.getState());
  }
View Full Code Here

      final JobId jobId1 = createJob(testJobName + 1, testJobVersion, BUSYBOX, IDLE_COMMAND,
                                     EMPTY_ENV, ports1);

      assertNotNull(jobId1);
      deployJob(jobId1, testHost());
      final TaskStatus firstTaskStatus1 = awaitJobState(client, testHost(), jobId1, RUNNING,
                                                        LONG_WAIT_SECONDS, SECONDS);

      final JobId jobId2 = createJob(testJobName + 2, testJobVersion, BUSYBOX, IDLE_COMMAND,
                                     EMPTY_ENV, ports2);

      assertNotNull(jobId2);
      deployJob(jobId2, testHost());
      final TaskStatus firstTaskStatus2 = awaitJobState(client, testHost(), jobId2, RUNNING,
                                                        LONG_WAIT_SECONDS, SECONDS);

      assertEquals(expectedMapping1, firstTaskStatus1.getPorts());
      assertEquals(expectedMapping2, firstTaskStatus2.getPorts());

      // TODO (dano): the supervisor should report the allocated ports at all times

      // Verify that port allocation is kept across container restarts
      dockerClient.killContainer(firstTaskStatus1.getContainerId());
      final TaskStatus restartedTaskStatus1 = Polling.await(
          LONG_WAIT_SECONDS, SECONDS, new Callable<TaskStatus>() {
        @Override
        public TaskStatus call() throws Exception {
          final HostStatus hostStatus = client.hostStatus(testHost()).get();
          final TaskStatus taskStatus = hostStatus.getStatuses().get(jobId1);
          return (taskStatus != null && taskStatus.getState() == RUNNING &&
                  !Objects.equals(taskStatus.getContainerId(), firstTaskStatus1.getContainerId()))
                 ? taskStatus : null;
        }
      });
      assertEquals(expectedMapping1, restartedTaskStatus1.getPorts());

      // Verify that port allocation is kept across agent restarts
      agent1.stopAsync().awaitTerminated();
      dockerClient.killContainer(firstTaskStatus2.getContainerId());
      startDefaultAgent(testHost());
      final TaskStatus restartedTaskStatus2 = Polling.await(
          LONG_WAIT_SECONDS, SECONDS, new Callable<TaskStatus>() {
        @Override
        public TaskStatus call() throws Exception {
          final HostStatus hostStatus = client.hostStatus(testHost()).get();
          final TaskStatus taskStatus = hostStatus.getStatuses().get(jobId2);
          return (taskStatus != null && taskStatus.getState() == RUNNING &&
                  !Objects.equals(taskStatus.getContainerId(), firstTaskStatus2.getContainerId()))
                 ? taskStatus : null;
        }
      });
      assertEquals(expectedMapping2, restartedTaskStatus2.getPorts());
    }
View Full Code Here

      final JobId jobId = createJob(testJobName + 1, testJobVersion, BUSYBOX,
        asList("sh", "-c", "echo $HELIOS_PORT_bar"), EMPTY_ENV, ports);

      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();
      }
      assertEquals(testHost() + ":" + externalPort1, log.trim());
    }
  }
View Full Code Here

    awaitHostStatus(testHost(), UP, LONG_WAIT_SECONDS, SECONDS);

    // Create job and deploy it
    final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, IDLE_COMMAND);
    deployJob(jobId, testHost());
    final TaskStatus runningStatus = awaitTaskState(jobId, testHost(), RUNNING);
    final String containerId = runningStatus.getContainerId();

    // Delete the config node which contains the cluster ID and all the job definitions
    zk().curator().delete().deletingChildrenIfNeeded().forPath("/config");

    // Sleep for a second so agent has a chance to react to deletion
View Full Code Here

    deployJob(jobId, host);
    awaitTaskState(jobId, host, RUNNING);

    client.setGoal(new Deployment(jobId, Goal.STOP, Deployment.EMTPY_DEPLOYER_USER), host);

    final TaskStatus taskStatus = awaitTaskState(jobId, host, STOPPED);

    final String log;
    try (final DockerClient dockerClient = getNewDockerClient();
         LogStream logs = dockerClient.logs(taskStatus.getContainerId(), STDOUT)) {
      log = logs.readFully();
    }

    // No message expected, since SIGINT should not be sent
    assertEquals("", log);
View Full Code Here

    deployJob(jobId, host);
    awaitTaskState(jobId, host, RUNNING);

    client.setGoal(new Deployment(jobId, Goal.STOP, Deployment.EMTPY_DEPLOYER_USER), host);

    final TaskStatus taskStatus = awaitTaskState(jobId, host, STOPPED);

    final String log;
    try (final DockerClient dockerClient = getNewDockerClient();
         LogStream logs = dockerClient.logs(taskStatus.getContainerId(), STDOUT)) {
      log = logs.readFully();
    }

    // Message expected, because the SIGTERM handler in the script should have run
    assertEquals("term\n", log);
View Full Code Here

TOP

Related Classes of com.spotify.helios.common.descriptors.TaskStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.