io.fabric8.kubernetes.api.model.apps.DeploymentStatus Java Examples

The following examples show how to use io.fabric8.kubernetes.api.model.apps.DeploymentStatus. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KubernetesHandlerTest.java    From apollo with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeploymentMonitor() throws JSONException {
    // We need to wait at least 2 iterations of the monitoring thread + 1 buffer
    Common.waitABit(5);

    Deployment currentNotFinishedDeployment = deploymentDao.getDeployment(notFinishedDeployment.getDeployment().getId());
    Deployment currentFinishedDeployment = deploymentDao.getDeployment(finishedDeployment.getDeployment().getId());
    Deployment currentNotFinishedCanceledDeployment = deploymentDao.getDeployment(notFinishedCanceledDeployment.getDeployment().getId());
    Deployment currentFinishedCanceledDeployment = deploymentDao.getDeployment(finishedCanceledDeployment.getDeployment().getId());
    Deployment currentGroupWithScalingFactorZeroDeployment = deploymentDao.getDeployment(groupWithScalingFactorZeroDeployment.getDeployment().getId());

    assertThat(currentNotFinishedDeployment.getStatus()).isEqualTo(Deployment.DeploymentStatus.STARTED);
    assertThat(currentFinishedDeployment.getStatus()).isEqualTo(Deployment.DeploymentStatus.DONE);
    assertThat(currentNotFinishedCanceledDeployment.getStatus()).isEqualTo(Deployment.DeploymentStatus.CANCELING);
    assertThat(currentFinishedCanceledDeployment.getStatus()).isEqualTo(Deployment.DeploymentStatus.CANCELED);
    assertThat(currentGroupWithScalingFactorZeroDeployment.getStatus()).isEqualTo(Deployment.DeploymentStatus.DONE);

    // Test envStatus
    JSONObject envStatusFromObjectJson = new JSONObject(currentFinishedDeployment.getEnvStatus().replaceAll("\\\\", ""));
    JSONObject expectedEnvStatusJson = new JSONObject(getExpectedEnvStatus(currentFinishedDeployment));

    JSONAssert.assertEquals(expectedEnvStatusJson, envStatusFromObjectJson, false);
}
 
Example #2
Source File: Readiness.java    From kubernetes-client with Apache License 2.0 6 votes vote down vote up
public static boolean isDeploymentReady(Deployment d) {
  Utils.checkNotNull(d, "Deployment can't be null.");
  DeploymentSpec spec = d.getSpec();
  DeploymentStatus status = d.getStatus();

  if (status == null || status.getReplicas() == null || status.getAvailableReplicas() == null) {
    return false;
  }

  //Can be true in testing, so handle it to make test writing easier.
  if (spec == null || spec.getReplicas() == null) {
    return false;
  }

  return spec.getReplicas().intValue() == status.getReplicas() &&
    spec.getReplicas().intValue() <= status.getAvailableReplicas();
}