Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify a little #1764

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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
}

/**
* <pre>
* - we deploy a busybox service with 2 replica pods
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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
}

/**
* <pre>
* - we deploy a busybox service with 2 replica pods
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(() -> {
Expand Down
Loading