diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointSlicesAndNamespaceFilterIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointSlicesAndNamespaceFilterIT.java index 914cc4ab6..a1b5a79cf 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointSlicesAndNamespaceFilterIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointSlicesAndNamespaceFilterIT.java @@ -35,6 +35,8 @@ import org.springframework.context.annotation.Primary; import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.Fabric8CatalogWatchWithEndpointSlicesAndNamespaceFilterIT.TestConfig; +import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.assertLogStatement; +import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.invokeAndAssert; /** * @author wind57 @@ -61,6 +63,7 @@ void beforeEach() { @AfterEach void afterEach() { + // busybox is deleted as part of the test itself, thus not seen here util.deleteNamespace(NAMESPACE_A); util.deleteNamespace(NAMESPACE_B); } @@ -77,8 +80,8 @@ void afterEach() { */ @Test void test(CapturedOutput output) { - TestAssertions.assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointSliceV1CatalogWatch"); - TestAssertions.invokeAndAssert(util, Set.of(NAMESPACE_A, NAMESPACE_B), port, NAMESPACE_A); + assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointSliceV1CatalogWatch"); + invokeAndAssert(util, Set.of(NAMESPACE_A, NAMESPACE_B), port, NAMESPACE_A); } @TestConfiguration diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointSlicesIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointSlicesIT.java index e18b810c7..9ffdcc036 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointSlicesIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointSlicesIT.java @@ -19,6 +19,7 @@ import java.util.Set; import io.fabric8.kubernetes.client.KubernetesClient; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,6 +35,8 @@ import org.springframework.context.annotation.Primary; import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.Fabric8CatalogWatchWithEndpointSlicesIT.TestConfig; +import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.assertLogStatement; +import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.invokeAndAssert; /** * @author wind57 @@ -51,6 +54,12 @@ void beforeEach() { util.busybox(NAMESPACE, Phase.CREATE); } + @AfterEach + void afterEach() { + // empty on purpose + // busybox is deleted as part of the test itself, thus not seen here + } + /** *
* - we deploy a busybox service with 2 replica pods @@ -62,8 +71,8 @@ void beforeEach() { */ @Test void test(CapturedOutput output) { - TestAssertions.assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointSliceV1CatalogWatch"); - TestAssertions.invokeAndAssert(util, Set.of(NAMESPACE), port, NAMESPACE); + assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointSliceV1CatalogWatch"); + invokeAndAssert(util, Set.of(NAMESPACE), port, NAMESPACE); } @TestConfiguration diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointsAndNamespaceFilterIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointsAndNamespaceFilterIT.java index 9eccc8889..cd37be173 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointsAndNamespaceFilterIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointsAndNamespaceFilterIT.java @@ -35,6 +35,8 @@ import org.springframework.context.annotation.Primary; import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.Fabric8CatalogWatchWithEndpointsAndNamespaceFilterIT.TestConfig; +import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.assertLogStatement; +import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.invokeAndAssert; /** * @author wind57 @@ -61,6 +63,7 @@ void beforeEach() { @AfterEach void afterEach() { + // busybox is deleted as part of the assertions, thus not seen here util.deleteNamespace(NAMESPACE_A); util.deleteNamespace(NAMESPACE_B); } @@ -77,8 +80,8 @@ void afterEach() { */ @Test void test(CapturedOutput output) { - TestAssertions.assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointsCatalogWatch"); - TestAssertions.invokeAndAssert(util, Set.of(NAMESPACE_A, NAMESPACE_B), port, NAMESPACE_A); + assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointsCatalogWatch"); + invokeAndAssert(util, Set.of(NAMESPACE_A, NAMESPACE_B), port, NAMESPACE_A); } @TestConfiguration diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointsIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointsIT.java index c8ca4e22f..efed4f5ae 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointsIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointsIT.java @@ -19,6 +19,7 @@ import java.util.Set; import io.fabric8.kubernetes.client.KubernetesClient; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,6 +35,8 @@ import org.springframework.context.annotation.Primary; import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.Fabric8CatalogWatchWithEndpointsIT.TestConfig; +import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.assertLogStatement; +import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.invokeAndAssert; /** * @author wind57 @@ -51,6 +54,12 @@ void beforeEach() { util.busybox(NAMESPACE, Phase.CREATE); } + @AfterEach + void afterEach() { + // empty on purpose + // busybox is deleted as part of the test itself, thus not seen here + } + /** ** - we deploy a busybox service with 2 replica pods @@ -62,8 +71,8 @@ void beforeEach() { */ @Test void test(CapturedOutput output) { - TestAssertions.assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointsCatalogWatch"); - TestAssertions.invokeAndAssert(util, Set.of(NAMESPACE), port, NAMESPACE); + assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointsCatalogWatch"); + invokeAndAssert(util, Set.of(NAMESPACE), port, NAMESPACE); } @TestConfiguration diff --git a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/Commons.java b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/Commons.java index 4fc2136fe..a20374450 100644 --- a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/Commons.java +++ b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/Commons.java @@ -23,6 +23,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import java.time.Duration; import java.util.Arrays; import java.util.List; @@ -159,8 +160,7 @@ public static void loadImage(String image, String tag, String tarName, K3sContai InputStream imageStream = saveImageCmd.withTag(tag).exec(); Path imagePath = Paths.get(TEMP_FOLDER + "/" + tarName + ".tar"); - Files.deleteIfExists(imagePath); - Files.copy(imageStream, imagePath); + Files.copy(imageStream, imagePath, StandardCopyOption.REPLACE_EXISTING); // import image with ctr. this works because TEMP_FOLDER is mounted in the // container await().atMost(Duration.ofMinutes(2)).pollInterval(Duration.ofSeconds(1)).until(() -> {