simplify a little (#1764)

This commit is contained in:
erabii
2024-10-16 02:28:19 +03:00
committed by GitHub
parent a27bf65c55
commit 8d02d1a1b6
5 changed files with 34 additions and 10 deletions

View File

@@ -35,6 +35,8 @@ import org.springframework.context.annotation.Bean;
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 @@ class Fabric8CatalogWatchWithEndpointSlicesAndNamespaceFilterIT extends Fabric8C
@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 @@ class Fabric8CatalogWatchWithEndpointSlicesAndNamespaceFilterIT extends Fabric8C
*/
@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

View File

@@ -19,6 +19,7 @@ package org.springframework.cloud.kubernetes.fabric8.catalog.watch;
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.Bean;
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 @@ class Fabric8CatalogWatchWithEndpointSlicesIT extends Fabric8CatalogWatchBase {
util.busybox(NAMESPACE, Phase.CREATE);
}
@AfterEach
void afterEach() {
// empty on purpose
// busybox is deleted as part of the test itself, thus not seen here
}
/**
* <pre>
* - we deploy a busybox service with 2 replica pods
@@ -62,8 +71,8 @@ class Fabric8CatalogWatchWithEndpointSlicesIT extends Fabric8CatalogWatchBase {
*/
@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

View File

@@ -35,6 +35,8 @@ import org.springframework.context.annotation.Bean;
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 @@ class Fabric8CatalogWatchWithEndpointsAndNamespaceFilterIT extends Fabric8Catalo
@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 @@ class Fabric8CatalogWatchWithEndpointsAndNamespaceFilterIT extends Fabric8Catalo
*/
@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

View File

@@ -19,6 +19,7 @@ package org.springframework.cloud.kubernetes.fabric8.catalog.watch;
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.Bean;
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 @@ class Fabric8CatalogWatchWithEndpointsIT extends Fabric8CatalogWatchBase {
util.busybox(NAMESPACE, Phase.CREATE);
}
@AfterEach
void afterEach() {
// empty on purpose
// busybox is deleted as part of the test itself, thus not seen here
}
/**
* <pre>
* - we deploy a busybox service with 2 replica pods
@@ -62,8 +71,8 @@ class Fabric8CatalogWatchWithEndpointsIT extends Fabric8CatalogWatchBase {
*/
@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

View File

@@ -23,6 +23,7 @@ import java.nio.charset.StandardCharsets;
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 final class Commons {
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(() -> {