shorten IT: wait conditions parallelly (#695)

This commit is contained in:
Min Kim
2021-01-15 02:02:06 +08:00
committed by GitHub
parent 3f928ae2af
commit 9b6cb38f81
4 changed files with 33 additions and 24 deletions

View File

@@ -103,15 +103,12 @@ public class ActuatorRefreshIT {
this.k8SUtils = new K8SUtils(api, appsApi);
deployWiremock();
deployConfigWatcher();
// Check to make sure the wiremock deployment is ready
k8SUtils.waitForDeployment(CONFIG_WATCHER_WIREMOCK_DEPLOYMENT_NAME, NAMESPACE);
// Check to see if endpoint is ready
k8SUtils.waitForEndpointReady(CONFIG_WATCHER_WIREMOCK_APP_NAME, NAMESPACE);
deployConfigWatcher();
// Check to make sure the controller deployment is ready
k8SUtils.waitForDeployment(SPRING_CLOUD_K8S_CONFIG_WATCHER_DEPLOYMENT_NAME, NAMESPACE);
}
@@ -152,6 +149,9 @@ public class ActuatorRefreshIT {
api.deleteNamespacedConfigMap(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, NAMESPACE, null, null, null, null, null,
null);
api.deleteNamespacedConfigMap(CONFIG_WATCHER_WIREMOCK_APP_NAME, NAMESPACE, null, null, null, null, null, null);
// Check to make sure the controller deployment is deleted
k8SUtils.waitForDeploymentToBeDeleted(SPRING_CLOUD_K8S_CONFIG_WATCHER_DEPLOYMENT_NAME, NAMESPACE);
k8SUtils.waitForDeploymentToBeDeleted(CONFIG_WATCHER_WIREMOCK_DEPLOYMENT_NAME, NAMESPACE);
}
private void deployConfigWatcher() throws Exception {

View File

@@ -111,20 +111,14 @@ public class ActuatorRefreshKafkaIT {
this.k8SUtils = new K8SUtils(api, appsApi);
deployZookeeper();
k8SUtils.waitForDeployment(ZOOKEEPER_DEPLOYMENT, NAMESPACE);
deployKafka();
k8SUtils.waitForDeployment(KAFKA_BROKER, NAMESPACE);
deployTestApp();
k8SUtils.waitForDeployment(SPRING_CLOUD_K8S_CONFIG_WATCHER_IT_DEPLOYMENT_NAME, NAMESPACE);
deployConfigWatcher();
// Check to make sure the controller deployment is ready
k8SUtils.waitForDeployment(ZOOKEEPER_DEPLOYMENT, NAMESPACE);
k8SUtils.waitForDeployment(KAFKA_BROKER, NAMESPACE);
k8SUtils.waitForDeployment(SPRING_CLOUD_K8S_CONFIG_WATCHER_IT_DEPLOYMENT_NAME, NAMESPACE);
k8SUtils.waitForDeployment(SPRING_CLOUD_K8S_CONFIG_WATCHER_DEPLOYMENT_NAME, NAMESPACE);
}
@@ -168,6 +162,11 @@ public class ActuatorRefreshKafkaIT {
null);
api.deleteNamespacedConfigMap(CONFIG_WATCHER_IT_IMAGE, NAMESPACE, null, null, null, null, null, null);
// Check to make sure the controller deployment is deleted
k8SUtils.waitForDeploymentToBeDeleted(KAFKA_BROKER, NAMESPACE);
k8SUtils.waitForDeploymentToBeDeleted(ZOOKEEPER_DEPLOYMENT, NAMESPACE);
k8SUtils.waitForDeploymentToBeDeleted(SPRING_CLOUD_K8S_CONFIG_WATCHER_DEPLOYMENT_NAME, NAMESPACE);
k8SUtils.waitForDeploymentToBeDeleted(SPRING_CLOUD_K8S_CONFIG_WATCHER_IT_DEPLOYMENT_NAME, NAMESPACE);
}
private void deployTestApp() throws Exception {

View File

@@ -83,16 +83,12 @@ public class ActuatorRefreshRabbitMQIT {
this.k8SUtils = new K8SUtils(api, appsApi);
deployRabbitMQ();
k8SUtils.waitForReplicationController(RABBIT_MQ_CONTROLLER_NAME, NAMESPACE);
deployTestApp();
k8SUtils.waitForDeployment(SPRING_CLOUD_K8S_CONFIG_WATCHER_IT_DEPLOYMENT_NAME, NAMESPACE);
deployConfigWatcher();
// Check to make sure the controller deployment is ready
k8SUtils.waitForReplicationController(RABBIT_MQ_CONTROLLER_NAME, NAMESPACE);
k8SUtils.waitForDeployment(SPRING_CLOUD_K8S_CONFIG_WATCHER_IT_DEPLOYMENT_NAME, NAMESPACE);
k8SUtils.waitForDeployment(SPRING_CLOUD_K8S_CONFIG_WATCHER_DEPLOYMENT_NAME, NAMESPACE);
}
@@ -144,6 +140,10 @@ public class ActuatorRefreshRabbitMQIT {
null);
api.deleteNamespacedConfigMap(CONFIG_WATCHER_IT_IMAGE, NAMESPACE, null, null, null, null, null, null);
// Check to make sure the controller deployment is deleted
k8SUtils.waitForDeploymentToBeDeleted(SPRING_CLOUD_K8S_CONFIG_WATCHER_DEPLOYMENT_NAME, NAMESPACE);
k8SUtils.waitForDeploymentToBeDeleted(SPRING_CLOUD_K8S_CONFIG_WATCHER_IT_DEPLOYMENT_NAME, NAMESPACE);
}
private void deployTestApp() throws Exception {

View File

@@ -20,6 +20,7 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.time.Duration;
import java.util.Collection;
@@ -172,11 +173,20 @@ public class K8SUtils {
public void waitForDeploymentToBeDeleted(String deploymentName, String namespace) {
await().timeout(
Duration.ofSeconds(90)).until(
() -> appsApi
.listNamespacedDeployment(namespace, null, null, null,
"metadata.name=" + deploymentName, null, null, null, null, null)
.getItems().isEmpty());
Duration.ofSeconds(90)).until(
() -> {
try {
appsApi
.readNamespacedDeployment(deploymentName, namespace, null, null, null);
return false;
}
catch (ApiException e) {
if (e.getCode() == HttpURLConnection.HTTP_NOT_FOUND) {
return true;
}
throw new RuntimeException(e);
}
});
}
public boolean isDeployentReady(String deploymentName, String namespace) throws ApiException {