bumping kubernetes client to 11.0.0
This commit is contained in:
@@ -60,11 +60,11 @@ public class KubernetesClientServicesListSupplier extends KubernetesServicesList
|
||||
try {
|
||||
if (discoveryProperties.isAllNamespaces()) {
|
||||
services = coreV1Api.listServiceForAllNamespaces(null, null, "metadata.name=" + this.getServiceId(),
|
||||
null, null, null, null, null, null).getItems();
|
||||
null, null, null, null, null, null, null).getItems();
|
||||
}
|
||||
else {
|
||||
services = coreV1Api.listNamespacedService(kubernetesClientProperties.getNamespace(), null, null, null,
|
||||
"metadata.name=" + this.getServiceId(), null, null, null, null, null).getItems();
|
||||
"metadata.name=" + this.getServiceId(), null, null, null, null, null, null).getItems();
|
||||
}
|
||||
services.forEach(service -> result.add(mapper.map(service)));
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.cloud.client.DefaultServiceInstance;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
@@ -38,11 +37,9 @@ import org.springframework.cloud.kubernetes.client.discovery.KubernetesInformerD
|
||||
import org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.mock.http.client.MockClientHttpResponse;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@@ -58,17 +55,17 @@ import static org.mockito.Mockito.when;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
||||
classes = KubernetesClientLoadBalancerPodModeTests.App.class,
|
||||
properties = { "spring.cloud.kubernetes.client.namespace=default" })
|
||||
classes = KubernetesClientLoadBalancerPodModeTests.App.class,
|
||||
properties = {"spring.cloud.kubernetes.client.namespace=default"})
|
||||
public class KubernetesClientLoadBalancerPodModeTests {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate rest;
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
public void testLoadBalancer() {
|
||||
ResponseEntity<String> map = rest.getForEntity("/servicea", String.class);
|
||||
assertThat(map.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
String resp = restTemplate.getForObject("http://servicea-wiremock", String.class);
|
||||
assertThat(resp).isEqualTo("hello");
|
||||
}
|
||||
|
||||
@RestController
|
||||
@@ -114,11 +111,6 @@ public class KubernetesClientLoadBalancerPodModeTests {
|
||||
return new RestTemplateBuilder().build();
|
||||
}
|
||||
|
||||
@GetMapping("/servicea")
|
||||
public String greeting() {
|
||||
return restTemplate().getForObject("http://servicea-wiremock", String.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||
@@ -44,11 +43,9 @@ import org.springframework.cloud.kubernetes.client.discovery.KubernetesInformerD
|
||||
import org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.mock.http.client.MockClientHttpResponse;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@@ -83,12 +80,12 @@ public class KubernetesClientLoadBalancerServiceModeTests {
|
||||
.build();
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate rest;
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
public void testLoadBalancer() {
|
||||
ResponseEntity<String> map = rest.getForEntity("/servicea", String.class);
|
||||
assertThat(map.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
String resp = restTemplate.getForObject("http://servicea-wiremock", String.class);
|
||||
assertThat(resp).isEqualTo("hello");
|
||||
}
|
||||
|
||||
@RestController
|
||||
@@ -109,8 +106,8 @@ public class KubernetesClientLoadBalancerServiceModeTests {
|
||||
CoreV1Api coreV1Api = mock(CoreV1Api.class);
|
||||
try {
|
||||
when(coreV1Api.listNamespacedService(eq("default"), eq(null), eq(null), eq(null),
|
||||
eq("metadata.name=servicea-wiremock"), eq(null), eq(null), eq(null), eq(null), eq(null)))
|
||||
.thenReturn(SERVICE_LIST);
|
||||
eq("metadata.name=servicea-wiremock"), eq(null), eq(null), eq(null), eq(null), eq(null),
|
||||
eq(null))).thenReturn(SERVICE_LIST);
|
||||
}
|
||||
catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
@@ -147,11 +144,6 @@ public class KubernetesClientLoadBalancerServiceModeTests {
|
||||
return new RestTemplateBuilder().build();
|
||||
}
|
||||
|
||||
@GetMapping("/servicea")
|
||||
public String greeting() {
|
||||
return restTemplate().getForObject("http://servicea-wiremock", String.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user