@Test
 public void testDeletePod() throws Exception {
   if (log.isDebugEnabled()) {
     log.debug("Deleting a Pod " + pod);
   }
   getClient().createPod(pod);
   getClient().deletePod(pod.getId());
   assertNull(getClient().getPod(pod.getId()));
 }
  @Test
  public void testCreatePod() throws Exception {
    log.info("Testing Pods ....");

    if (log.isDebugEnabled()) {
      log.debug("Creating a Pod " + pod);
    }
    Pod createPod = getClient().createPod(pod);
    assertEquals(pod.getId(), createPod.getId());
    assertNotNull(getClient().getPod(pod.getId()));
    assertEquals("Waiting", createPod.getCurrentState().getStatus());

    ExecutorService executor = Executors.newSingleThreadExecutor();
    Future<Pod> future =
        executor.submit(
            new Callable<Pod>() {
              public Pod call() throws Exception {
                Pod newPod;
                do {
                  log.info("Waiting for Pod to be ready: " + pod.getId());
                  Thread.sleep(1000);
                  newPod = getClient().getPod(pod.getId());
                  StateInfo info = newPod.getCurrentState().getInfo("master");
                  if (info.getState("waiting") != null) {
                    throw new RuntimeException("Pod is waiting due to " + info.getState("waiting"));
                  }
                } while (!"Running".equals(newPod.getCurrentState().getStatus()));
                return newPod;
              }
            });

    try {
      createPod = future.get(90, TimeUnit.SECONDS);
    } finally {
      executor.shutdownNow();
    }
    assertNotNull(createPod.getCurrentState().getInfo("master").getState("running"));
    assertNotNull(createPod.getCurrentState().getNetInfo().getState("running"));

    // test recreation from same id
    try {
      getClient().createPod(pod);
      fail("Should have thrown exception");
    } catch (Exception e) {
      // ignore
    }
    assertNotNull(getClient().getPod(pod.getId()));
  }
 @Test
 public void testGetAllPods() throws Exception {
   if (log.isDebugEnabled()) {
     log.debug("Get all Pods ");
   }
   getClient().createPod(pod);
   PodList podList = getClient().getAllPods();
   assertNotNull(podList);
   List<Pod> currentPods;
   assertNotNull(currentPods = podList.getItems());
   boolean match = false;
   for (Pod pod2 : currentPods) {
     if (pod.getId().equals(pod2.getId())) {
       match = true;
       break;
     }
   }
   assertEquals(true, match);
 }
 private Pod getPod() {
   Pod pod = new Pod();
   pod.setId("kubernetes-test-pod");
   pod.setLabels(ImmutableMap.of("name", "kubernetes-test-pod-label", "label1", "value1"));
   State desiredState = new State();
   Manifest m = new Manifest();
   m.setId(pod.getId());
   Container c = new Container();
   c.setName("master");
   c.setImage(dockerImage);
   c.setCommand("tail", "-f", "/dev/null");
   Port p = new Port(8379, new Random().nextInt((65535 - 49152) + 1) + 49152, "0.0.0.0");
   c.setPorts(Collections.singletonList(p));
   m.setContainers(Collections.singletonList(c));
   desiredState.setManifest(m);
   pod.setDesiredState(desiredState);
   return pod;
 }