Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -60,8 +60,9 @@ protected static void beforeAll() {
util = new Util(K3S);
}

protected static KubernetesDiscoveryProperties discoveryProperties(boolean useEndpointSlices) {
return new KubernetesDiscoveryProperties(true, false, Set.of(NAMESPACE, NAMESPACE_A), true, 60, false, null,
protected static KubernetesDiscoveryProperties discoveryProperties(boolean useEndpointSlices,
Set<String> discoveryNamespaces) {
return new KubernetesDiscoveryProperties(true, false, discoveryNamespaces, true, 60, false, null,
Set.of(443, 8443), Map.of(), null, KubernetesDiscoveryProperties.Metadata.DEFAULT, 0, useEndpointSlices,
false, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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.Fabric8CatalogWatchEndpointSlicesFilterIT.TestConfig;
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.assertLogStatement;
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.invokeAndAssert;

Expand All @@ -43,7 +43,7 @@
*/
@SpringBootTest(classes = { KubernetesCatalogWatchAutoConfiguration.class, TestConfig.class, Application.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class Fabric8CatalogWatchWithEndpointSlicesAndNamespaceFilterIT extends Fabric8CatalogWatchBase {
class Fabric8CatalogWatchEndpointSlicesFilterIT extends Fabric8CatalogWatchBase {

@LocalServerPort
private int port;
Expand Down Expand Up @@ -96,7 +96,7 @@ KubernetesClient kubernetesClient() {
@Bean
@Primary
KubernetesDiscoveryProperties kubernetesDiscoveryProperties() {
return discoveryProperties(true);
return discoveryProperties(true, Set.of(NAMESPACE, NAMESPACE_A));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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.Fabric8CatalogWatchEndpointsIT.TestConfig;
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.assertLogStatement;
import static org.springframework.cloud.kubernetes.fabric8.catalog.watch.TestAssertions.invokeAndAssert;

Expand All @@ -43,7 +43,7 @@
*/
@SpringBootTest(classes = { KubernetesCatalogWatchAutoConfiguration.class, TestConfig.class, Application.class },
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class Fabric8CatalogWatchWithEndpointsAndNamespaceFilterIT extends Fabric8CatalogWatchBase {
class Fabric8CatalogWatchEndpointsIT extends Fabric8CatalogWatchBase {

@LocalServerPort
private int port;
Expand Down Expand Up @@ -96,7 +96,7 @@ KubernetesClient kubernetesClient() {
@Bean
@Primary
KubernetesDiscoveryProperties kubernetesDiscoveryProperties() {
return discoveryProperties(false);
return discoveryProperties(false, Set.of(NAMESPACE, NAMESPACE_A));
}

}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.web.server.LocalManagementPort;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.kubernetes.integration.tests.commons.Images;
import org.springframework.cloud.kubernetes.integration.tests.commons.Phase;
import org.springframework.test.context.TestPropertySource;

import static org.springframework.cloud.kubernetes.fabric8.client.discovery.TestAssertions.assertBlockingConfiguration;
import static org.springframework.cloud.kubernetes.fabric8.client.discovery.TestAssertions.assertPodMetadata;

/**
* @author wind57
Expand All @@ -39,6 +42,9 @@ class Fabric8DiscoveryBlockingIT extends Fabric8DiscoveryBase {
@LocalManagementPort
private int port;

@Autowired
private DiscoveryClient discoveryClient;

@BeforeEach
void beforeEach() {
Images.loadBusybox(K3S);
Expand All @@ -51,8 +57,20 @@ void afterEach() {
}

@Test
void test(CapturedOutput output) {
void test(CapturedOutput output) throws Exception {

String[] busyboxPods = K3S.execInContainer("sh", "-c", "kubectl get pods -l app=busybox -o=name --no-headers")
.getStdout()
.split("\n");

String podOne = busyboxPods[0].split("/")[1];
String podTwo = busyboxPods[1].split("/")[1];

K3S.execInContainer("sh", "-c", "kubectl label pods " + podOne + " my-label=my-value");
K3S.execInContainer("sh", "-c", "kubectl annotate pods " + podTwo + " my-annotation=my-value");

assertBlockingConfiguration(output, port);
assertPodMetadata(discoveryClient);
}

}

This file was deleted.

Loading
Loading