@@ -25,7 +25,7 @@ import io.kubernetes.client.openapi.models.V1ServiceBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1ServicePort;
|
||||
import io.kubernetes.client.openapi.models.V1ServicePortBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1ServiceSpecBuilder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
@@ -116,9 +116,9 @@ class KubernetesClientServiceInstanceMapperTests {
|
||||
List<V1ServicePort> servicePorts = List.of();
|
||||
V1Service service = createService("database", "default", annotations, labels, servicePorts);
|
||||
KubernetesServiceInstance serviceInstance = mapper.map(service);
|
||||
Assertions.assertNull(serviceInstance);
|
||||
Assertions.assertTrue(output.getOut()
|
||||
.contains("service : database does not have any ServicePort(s), will not consider it for load balancing"));
|
||||
Assertions.assertThat(serviceInstance).isNull();
|
||||
Assertions.assertThat(output.getOut()).contains(
|
||||
"service : database does not have any ServicePort(s), will not consider it for load balancing");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,10 +133,10 @@ class KubernetesClientServiceInstanceMapperTests {
|
||||
List<V1ServicePort> servicePorts = List.of(new V1ServicePortBuilder().withName("http").withPort(80).build());
|
||||
V1Service service = createService("database", "default", annotations, labels, servicePorts);
|
||||
KubernetesServiceInstance serviceInstance = mapper.map(service);
|
||||
Assertions.assertNotNull(serviceInstance);
|
||||
Assertions.assertTrue(output.getOut()
|
||||
Assertions.assertThat(serviceInstance).isNotNull();
|
||||
Assertions.assertThat(output.getOut())
|
||||
.contains("single ServicePort found, "
|
||||
+ "will use it as-is (without checking 'spring.cloud.kubernetes.loadbalancer.portName')"));
|
||||
+ "will use it as-is (without checking 'spring.cloud.kubernetes.loadbalancer.portName')");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,10 +151,10 @@ class KubernetesClientServiceInstanceMapperTests {
|
||||
List<V1ServicePort> servicePorts = List.of(new V1ServicePortBuilder().withName("http").withPort(80).build());
|
||||
V1Service service = createService("database", "default", annotations, labels, servicePorts);
|
||||
KubernetesServiceInstance serviceInstance = mapper.map(service);
|
||||
Assertions.assertNotNull(serviceInstance);
|
||||
Assertions.assertTrue(output.getOut()
|
||||
Assertions.assertThat(serviceInstance).isNotNull();
|
||||
Assertions.assertThat(output.getOut())
|
||||
.contains("single ServicePort found, "
|
||||
+ "will use it as-is (without checking 'spring.cloud.kubernetes.loadbalancer.portName')"));
|
||||
+ "will use it as-is (without checking 'spring.cloud.kubernetes.loadbalancer.portName')");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -170,9 +170,9 @@ class KubernetesClientServiceInstanceMapperTests {
|
||||
new V1ServicePortBuilder().withName("https").withPort(443).build());
|
||||
V1Service service = createService("database", "default", annotations, labels, servicePorts);
|
||||
KubernetesServiceInstance serviceInstance = mapper.map(service);
|
||||
Assertions.assertNotNull(serviceInstance);
|
||||
Assertions.assertTrue(output.getOut().contains("found port name that matches : http"));
|
||||
Assertions.assertEquals(serviceInstance.getPort(), 80);
|
||||
Assertions.assertThat(serviceInstance).isNotNull();
|
||||
Assertions.assertThat(output.getOut()).contains("found port name that matches : http");
|
||||
Assertions.assertThat(serviceInstance.getPort()).isEqualTo(80);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -188,10 +188,10 @@ class KubernetesClientServiceInstanceMapperTests {
|
||||
new V1ServicePortBuilder().withName("https").withPort(443).build());
|
||||
V1Service service = createService("database", "default", annotations, labels, servicePorts);
|
||||
KubernetesServiceInstance serviceInstance = mapper.map(service);
|
||||
Assertions.assertNotNull(serviceInstance);
|
||||
Assertions.assertTrue(output.getOut().contains("Did not find a port name that is equal to the value http"));
|
||||
Assertions.assertTrue(output.getOut().contains("Will return 'first' port found, which is non-deterministic"));
|
||||
Assertions.assertTrue(serviceInstance.getPort() == 80 || serviceInstance.getPort() == 443);
|
||||
Assertions.assertThat(serviceInstance).isNotNull();
|
||||
Assertions.assertThat(output.getOut()).contains("Did not find a port name that is equal to the value http");
|
||||
Assertions.assertThat(output.getOut()).contains("Will return 'first' port found, which is non-deterministic");
|
||||
Assertions.assertThat(serviceInstance.getPort()).isIn(80, 443);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -207,10 +207,10 @@ class KubernetesClientServiceInstanceMapperTests {
|
||||
new V1ServicePortBuilder().withName("https").withPort(443).build());
|
||||
V1Service service = createService("database", "default", annotations, labels, servicePorts);
|
||||
KubernetesServiceInstance serviceInstance = mapper.map(service);
|
||||
Assertions.assertNotNull(serviceInstance);
|
||||
Assertions.assertTrue(output.getOut().contains("'spring.cloud.kubernetes.loadbalancer.portName' is not set"));
|
||||
Assertions.assertTrue(output.getOut().contains("Will return 'first' port found, which is non-deterministic"));
|
||||
Assertions.assertTrue(serviceInstance.getPort() == 80 || serviceInstance.getPort() == 443);
|
||||
Assertions.assertThat(serviceInstance).isNotNull();
|
||||
Assertions.assertThat(output.getOut()).contains("'spring.cloud.kubernetes.loadbalancer.portName' is not set");
|
||||
Assertions.assertThat(output.getOut()).contains("Will return 'first' port found, which is non-deterministic");
|
||||
Assertions.assertThat(serviceInstance.getPort()).isIn(80, 443);
|
||||
}
|
||||
|
||||
private V1Service createService(String name, String namespace, Map<String, String> annotations,
|
||||
|
||||
@@ -34,9 +34,9 @@ import io.kubernetes.client.openapi.models.V1ServiceList;
|
||||
import io.kubernetes.client.openapi.models.V1ServicePortBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1ServiceSpecBuilder;
|
||||
import io.kubernetes.client.util.ClientBuilder;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -155,8 +155,8 @@ class KubernetesClientServicesListSupplierTests {
|
||||
services.add(serviceA);
|
||||
|
||||
StepVerifier.create(instances).expectNext(services).verifyComplete();
|
||||
Assertions.assertTrue(output.getOut().contains("serviceID : service-a"));
|
||||
Assertions.assertTrue(output.getOut().contains("discovering services in namespace : default"));
|
||||
Assertions.assertThat(output.getOut()).contains("serviceID : service-a");
|
||||
Assertions.assertThat(output.getOut()).contains("discovering services in namespace : default");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -186,9 +186,9 @@ class KubernetesClientServicesListSupplierTests {
|
||||
List<ServiceInstance> services = List.of();
|
||||
|
||||
StepVerifier.create(instances).expectNext(services).verifyComplete();
|
||||
Assertions.assertTrue(output.getOut().contains("serviceID : service-a"));
|
||||
Assertions.assertTrue(output.getOut().contains("discovering services in namespace : default"));
|
||||
Assertions.assertTrue(output.getOut().contains("Error retrieving service with name service-a"));
|
||||
Assertions.assertThat(output.getOut()).contains("serviceID : service-a");
|
||||
Assertions.assertThat(output.getOut()).contains("discovering services in namespace : default");
|
||||
Assertions.assertThat(output.getOut()).contains("Error retrieving service with name service-a");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -226,7 +226,7 @@ class KubernetesClientServicesListSupplierTests {
|
||||
services.add(serviceATestNamespace);
|
||||
|
||||
StepVerifier.create(instances).expectNext(services).verifyComplete();
|
||||
Assertions.assertTrue(output.getOut().contains("discovering services in all namespaces"));
|
||||
Assertions.assertThat(output.getOut()).contains("discovering services in all namespaces");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -271,10 +271,10 @@ class KubernetesClientServicesListSupplierTests {
|
||||
services.add(serviceATestNamespace);
|
||||
|
||||
StepVerifier.create(instances).expectNext(services).verifyComplete();
|
||||
Assertions.assertTrue(
|
||||
output.getOut().contains("Error retrieving service with name service-a in namespace : no-service"));
|
||||
Assertions.assertTrue(
|
||||
output.getOut().contains("discovering services in selective namespaces : [default, no-service, test]"));
|
||||
Assertions.assertThat(
|
||||
output.getOut()).contains("Error retrieving service with name service-a in namespace : no-service");
|
||||
Assertions.assertThat(
|
||||
output.getOut()).contains("discovering services in selective namespaces : [default, no-service, test]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user