Skip to content

Commit 8d02d1a

Browse files
authored
simplify a little (#1764)
1 parent a27bf65 commit 8d02d1a

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointSlicesAndNamespaceFilterIT.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import org.springframework.context.annotation.Primary;
3636

3737
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.Fabric8CatalogWatchWithEndpointSlicesAndNamespaceFilterIT.TestConfig;
38+
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.assertLogStatement;
39+
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.invokeAndAssert;
3840

3941
/**
4042
* @author wind57
@@ -61,6 +63,7 @@ void beforeEach() {
6163

6264
@AfterEach
6365
void afterEach() {
66+
// busybox is deleted as part of the test itself, thus not seen here
6467
util.deleteNamespace(NAMESPACE_A);
6568
util.deleteNamespace(NAMESPACE_B);
6669
}
@@ -77,8 +80,8 @@ void afterEach() {
7780
*/
7881
@Test
7982
void test(CapturedOutput output) {
80-
TestAssertions.assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointSliceV1CatalogWatch");
81-
TestAssertions.invokeAndAssert(util, Set.of(NAMESPACE_A, NAMESPACE_B), port, NAMESPACE_A);
83+
assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointSliceV1CatalogWatch");
84+
invokeAndAssert(util, Set.of(NAMESPACE_A, NAMESPACE_B), port, NAMESPACE_A);
8285
}
8386

8487
@TestConfiguration

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointSlicesIT.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.Set;
2020

2121
import io.fabric8.kubernetes.client.KubernetesClient;
22+
import org.junit.jupiter.api.AfterEach;
2223
import org.junit.jupiter.api.BeforeEach;
2324
import org.junit.jupiter.api.Test;
2425

@@ -34,6 +35,8 @@
3435
import org.springframework.context.annotation.Primary;
3536

3637
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.Fabric8CatalogWatchWithEndpointSlicesIT.TestConfig;
38+
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.assertLogStatement;
39+
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.invokeAndAssert;
3740

3841
/**
3942
* @author wind57
@@ -51,6 +54,12 @@ void beforeEach() {
5154
util.busybox(NAMESPACE, Phase.CREATE);
5255
}
5356

57+
@AfterEach
58+
void afterEach() {
59+
// empty on purpose
60+
// busybox is deleted as part of the test itself, thus not seen here
61+
}
62+
5463
/**
5564
* <pre>
5665
* - we deploy a busybox service with 2 replica pods
@@ -62,8 +71,8 @@ void beforeEach() {
6271
*/
6372
@Test
6473
void test(CapturedOutput output) {
65-
TestAssertions.assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointSliceV1CatalogWatch");
66-
TestAssertions.invokeAndAssert(util, Set.of(NAMESPACE), port, NAMESPACE);
74+
assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointSliceV1CatalogWatch");
75+
invokeAndAssert(util, Set.of(NAMESPACE), port, NAMESPACE);
6776
}
6877

6978
@TestConfiguration

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointsAndNamespaceFilterIT.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import org.springframework.context.annotation.Primary;
3636

3737
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.Fabric8CatalogWatchWithEndpointsAndNamespaceFilterIT.TestConfig;
38+
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.assertLogStatement;
39+
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.invokeAndAssert;
3840

3941
/**
4042
* @author wind57
@@ -61,6 +63,7 @@ void beforeEach() {
6163

6264
@AfterEach
6365
void afterEach() {
66+
// busybox is deleted as part of the assertions, thus not seen here
6467
util.deleteNamespace(NAMESPACE_A);
6568
util.deleteNamespace(NAMESPACE_B);
6669
}
@@ -77,8 +80,8 @@ void afterEach() {
7780
*/
7881
@Test
7982
void test(CapturedOutput output) {
80-
TestAssertions.assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointsCatalogWatch");
81-
TestAssertions.invokeAndAssert(util, Set.of(NAMESPACE_A, NAMESPACE_B), port, NAMESPACE_A);
83+
assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointsCatalogWatch");
84+
invokeAndAssert(util, Set.of(NAMESPACE_A, NAMESPACE_B), port, NAMESPACE_A);
8285
}
8386

8487
@TestConfiguration

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchWithEndpointsIT.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.Set;
2020

2121
import io.fabric8.kubernetes.client.KubernetesClient;
22+
import org.junit.jupiter.api.AfterEach;
2223
import org.junit.jupiter.api.BeforeEach;
2324
import org.junit.jupiter.api.Test;
2425

@@ -34,6 +35,8 @@
3435
import org.springframework.context.annotation.Primary;
3536

3637
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.Fabric8CatalogWatchWithEndpointsIT.TestConfig;
38+
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.assertLogStatement;
39+
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.invokeAndAssert;
3740

3841
/**
3942
* @author wind57
@@ -51,6 +54,12 @@ void beforeEach() {
5154
util.busybox(NAMESPACE, Phase.CREATE);
5255
}
5356

57+
@AfterEach
58+
void afterEach() {
59+
// empty on purpose
60+
// busybox is deleted as part of the test itself, thus not seen here
61+
}
62+
5463
/**
5564
* <pre>
5665
* - we deploy a busybox service with 2 replica pods
@@ -62,8 +71,8 @@ void beforeEach() {
6271
*/
6372
@Test
6473
void test(CapturedOutput output) {
65-
TestAssertions.assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointsCatalogWatch");
66-
TestAssertions.invokeAndAssert(util, Set.of(NAMESPACE), port, NAMESPACE);
74+
assertLogStatement(output, "stateGenerator is of type: Fabric8EndpointsCatalogWatch");
75+
invokeAndAssert(util, Set.of(NAMESPACE), port, NAMESPACE);
6776
}
6877

6978
@TestConfiguration

spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/Commons.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.nio.file.Files;
2424
import java.nio.file.Path;
2525
import java.nio.file.Paths;
26+
import java.nio.file.StandardCopyOption;
2627
import java.time.Duration;
2728
import java.util.Arrays;
2829
import java.util.List;
@@ -159,8 +160,7 @@ public static void loadImage(String image, String tag, String tarName, K3sContai
159160
InputStream imageStream = saveImageCmd.withTag(tag).exec();
160161

161162
Path imagePath = Paths.get(TEMP_FOLDER + "/" + tarName + ".tar");
162-
Files.deleteIfExists(imagePath);
163-
Files.copy(imageStream, imagePath);
163+
Files.copy(imageStream, imagePath, StandardCopyOption.REPLACE_EXISTING);
164164
// import image with ctr. this works because TEMP_FOLDER is mounted in the
165165
// container
166166
await().atMost(Duration.ofMinutes(2)).pollInterval(Duration.ofSeconds(1)).until(() -> {

0 commit comments

Comments
 (0)