Skip to content

Commit

Permalink
Killing pg-test pod for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ampie committed Feb 3, 2020
1 parent af1c653 commit 4d73be5
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import io.fabric8.kubernetes.api.model.Container;
import io.fabric8.kubernetes.api.model.DoneablePod;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.dsl.PodResource;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.entando.kubernetes.controller.KubeUtils;
import org.entando.kubernetes.controller.app.ComponentManagerDeployableContainer;
import org.entando.kubernetes.controller.app.EntandoAppController;
Expand Down Expand Up @@ -44,9 +47,20 @@ public void cleanup() {
deleteAll(EntandoDatabaseService.class).fromNamespace(EntandoAppIntegrationTestHelper.TEST_NAMESPACE)
.deleteAll(EntandoApp.class).fromNamespace(EntandoAppIntegrationTestHelper.TEST_NAMESPACE)
.deleteAll(EntandoKeycloakServer.class).fromNamespace(KeycloakIntegrationTestHelper.KEYCLOAK_NAMESPACE));
await().atMost(2, TimeUnit.MINUTES).ignoreExceptions().pollInterval(10, TimeUnit.SECONDS).until(this::killPgPod);
registerListeners();
}

private boolean killPgPod() {
PodResource<Pod, DoneablePod> resource = client.pods()
.inNamespace(KeycloakIntegrationTestHelper.KEYCLOAK_NAMESPACE).withName("pg-test");
if (resource.fromServer().get() == null) {
return true;
}
resource.delete();
return false;
}

private void registerListeners() {
if (EntandoOperatorTestConfig.getTestTarget() == TestTarget.K8S) {
helper.entandoApps().listenAndRespondWithImageVersionUnderTest(EntandoAppIntegrationTestHelper.TEST_NAMESPACE);
Expand Down

0 comments on commit 4d73be5

Please sign in to comment.