update kubernetes-client to 5.5.0 (#836)
* update kubernetes-client to 5.5.0
This commit is contained in:
@@ -35,9 +35,9 @@
|
||||
<arquillian.version>1.6.0.Final</arquillian.version>
|
||||
<arquillian-cube.version>1.15.2</arquillian-cube.version>
|
||||
<hoverfly.version>0.13.0</hoverfly.version>
|
||||
<kubernetes-client.version>4.13.3</kubernetes-client.version>
|
||||
<kubernetes-java-client.version>11.0.2</kubernetes-java-client.version>
|
||||
<istio-client.version>1.5.5</istio-client.version>
|
||||
<kubernetes-client.version>5.5.0</kubernetes-client.version>
|
||||
<kubernetes-java-client.version>13.0.0</kubernetes-java-client.version>
|
||||
<istio-client.version>1.7.7.1</istio-client.version>
|
||||
<mockwebserver.version>0.1.2</mockwebserver.version>
|
||||
<okhttp.version>3.14.4</okhttp.version>
|
||||
<wiremock.version>2.26.3</wiremock.version>
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.DoneablePod;
|
||||
import io.fabric8.kubernetes.api.model.Pod;
|
||||
import io.fabric8.kubernetes.api.model.PodList;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
@@ -63,12 +62,11 @@ public class Fabric8PodUtilsTest {
|
||||
|
||||
private final File certFile = Mockito.mock(File.class);
|
||||
|
||||
private final MixedOperation<Pod, PodList, DoneablePod, PodResource<Pod, DoneablePod>> mixed = Mockito
|
||||
.mock(MixedOperation.class);
|
||||
private final MixedOperation<Pod, PodList, PodResource<Pod>> mixed = Mockito.mock(MixedOperation.class);
|
||||
|
||||
private final Pod pod = Mockito.mock(Pod.class);
|
||||
|
||||
private final PodResource<Pod, DoneablePod> podResource = Mockito.mock(PodResource.class);
|
||||
private final PodResource<Pod> podResource = Mockito.mock(PodResource.class);
|
||||
|
||||
private MockedStatic<EnvReader> envReader;
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ import javax.annotation.PreDestroy;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMap;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.KubernetesClientException;
|
||||
import io.fabric8.kubernetes.client.Watch;
|
||||
import io.fabric8.kubernetes.client.Watcher;
|
||||
import io.fabric8.kubernetes.client.WatcherException;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties;
|
||||
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationChangeDetector;
|
||||
@@ -76,7 +76,7 @@ public class EventBasedConfigMapChangeDetector extends ConfigurationChangeDetect
|
||||
String name = "config-maps-watch-event";
|
||||
this.watches.put(name, this.kubernetesClient.configMaps().watch(new Watcher<ConfigMap>() {
|
||||
@Override
|
||||
public void eventReceived(Action action, ConfigMap configMap) {
|
||||
public void eventReceived(Watcher.Action action, ConfigMap configMap) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(name + " received event for ConfigMap " + configMap.getMetadata().getName());
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class EventBasedConfigMapChangeDetector extends ConfigurationChangeDetect
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(KubernetesClientException e) {
|
||||
public void onClose(WatcherException e) {
|
||||
}
|
||||
}));
|
||||
activated = true;
|
||||
|
||||
@@ -24,9 +24,9 @@ import javax.annotation.PreDestroy;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.Secret;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.KubernetesClientException;
|
||||
import io.fabric8.kubernetes.client.Watch;
|
||||
import io.fabric8.kubernetes.client.Watcher;
|
||||
import io.fabric8.kubernetes.client.WatcherException;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties;
|
||||
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationChangeDetector;
|
||||
@@ -85,7 +85,7 @@ public class EventBasedSecretsChangeDetector extends ConfigurationChangeDetector
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(KubernetesClientException e) {
|
||||
public void onClose(WatcherException e) {
|
||||
}
|
||||
}));
|
||||
activated = true;
|
||||
|
||||
@@ -37,11 +37,14 @@ public class ConfigMapsTest {
|
||||
|
||||
@Test
|
||||
public void testConfigMapList() {
|
||||
mockClient.configMaps().inNamespace("ns1").createNew();
|
||||
mockClient.configMaps().inNamespace("ns1")
|
||||
.create(new ConfigMapBuilder().withNewMetadata().withName("empty").endMetadata().build());
|
||||
|
||||
ConfigMapList configMapList = mockClient.configMaps().inNamespace("ns1").list();
|
||||
assertThat(configMapList).isNotNull();
|
||||
assertThat(configMapList.getItems().size()).isEqualTo(0);
|
||||
// metadata is an element
|
||||
assertThat(configMapList.getItems().size()).isEqualTo(1);
|
||||
assertThat(configMapList.getItems().get(0).getData()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,7 +81,7 @@ public class ConfigMapsTest {
|
||||
|
||||
@Test
|
||||
public void testConfigMapFromSingleApplicationYaml() {
|
||||
String configMapName = "app-properties-test";
|
||||
String configMapName = "app-yaml-test";
|
||||
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName(configMapName).endMetadata()
|
||||
.addToData("application.yaml", ConfigMapTestUtil.readResourceFile("application.yaml")).build();
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.cloud.kubernetes.fabric8.config;
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMap;
|
||||
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
|
||||
@@ -68,8 +69,8 @@ public class ConfigMapsTests {
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("bean.greeting", "Hello ConfigMap, %s!");
|
||||
mockClient.configMaps().inNamespace("test").createNew().withNewMetadata().withName(APPLICATION_NAME)
|
||||
.endMetadata().addToData(data).done();
|
||||
mockClient.configMaps().inNamespace("test").create(new ConfigMapBuilder().withNewMetadata()
|
||||
.withName(APPLICATION_NAME).endMetadata().addToData(data).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.kubernetes.fabric8.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
|
||||
@@ -71,13 +72,13 @@ public class ConfigMapsWithActiveProfilesNameTests {
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("application.yml", readResourceFile("application-with-profiles.yaml"));
|
||||
mockClient.configMaps().inNamespace("test").createNew().withNewMetadata().withName(APPLICATION_NAME)
|
||||
.endMetadata().addToData(data).done();
|
||||
mockClient.configMaps().inNamespace("test").create(new ConfigMapBuilder().withNewMetadata()
|
||||
.withName(APPLICATION_NAME).endMetadata().addToData(data).build());
|
||||
|
||||
HashMap<String, String> dataWithName = new HashMap<>();
|
||||
dataWithName.put("application.yml", readResourceFile("application-with-active-profiles-name.yaml"));
|
||||
mockClient.configMaps().inNamespace("test").createNew().withNewMetadata()
|
||||
.withName(APPLICATION_NAME + "-development").endMetadata().addToData(dataWithName).done();
|
||||
mockClient.configMaps().inNamespace("test").create(new ConfigMapBuilder().withNewMetadata()
|
||||
.withName(APPLICATION_NAME + "-development").endMetadata().addToData(dataWithName).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.kubernetes.fabric8.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
|
||||
@@ -65,8 +66,8 @@ public class ConfigMapsWithProfileExpressionTests {
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("application.yml", ConfigMapTestUtil.readResourceFile("application-with-profiles.yaml"));
|
||||
mockClient.configMaps().inNamespace("test").createNew().withNewMetadata().withName(APPLICATION_NAME)
|
||||
.endMetadata().addToData(data).done();
|
||||
mockClient.configMaps().inNamespace("test").create(new ConfigMapBuilder().withNewMetadata()
|
||||
.withName(APPLICATION_NAME).endMetadata().addToData(data).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.kubernetes.fabric8.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
|
||||
@@ -65,8 +66,8 @@ public class ConfigMapsWithProfilesNoActiveProfileTests {
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("application.yml", readResourceFile("application-with-profiles.yaml"));
|
||||
mockClient.configMaps().inNamespace("test").createNew().withNewMetadata().withName(APPLICATION_NAME)
|
||||
.endMetadata().addToData(data).done();
|
||||
mockClient.configMaps().inNamespace("test").create(new ConfigMapBuilder().withNewMetadata()
|
||||
.withName(APPLICATION_NAME).endMetadata().addToData(data).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.kubernetes.fabric8.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
|
||||
@@ -67,8 +68,8 @@ public class ConfigMapsWithProfilesTests {
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("application.yml", ConfigMapTestUtil.readResourceFile("application-with-profiles.yaml"));
|
||||
mockClient.configMaps().inNamespace("test").createNew().withNewMetadata().withName(APPLICATION_NAME)
|
||||
.endMetadata().addToData(data).done();
|
||||
mockClient.configMaps().inNamespace("test").create(new ConfigMapBuilder().withNewMetadata()
|
||||
.withName(APPLICATION_NAME).endMetadata().addToData(data).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.kubernetes.fabric8.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
|
||||
@@ -61,8 +62,8 @@ public class ConfigMapsWithoutProfilesTests {
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("application.yml", ConfigMapTestUtil.readResourceFile("application-without-profiles.yaml"));
|
||||
mockClient.configMaps().inNamespace("test").createNew().withNewMetadata().withName(APPLICATION_NAME)
|
||||
.endMetadata().addToData(data).done();
|
||||
mockClient.configMaps().inNamespace("test").create(new ConfigMapBuilder().withNewMetadata()
|
||||
.withName(APPLICATION_NAME).endMetadata().addToData(data).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.cloud.kubernetes.fabric8.config;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
|
||||
import io.fabric8.kubernetes.api.model.SecretBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
@@ -62,14 +64,14 @@ public class CoreTest {
|
||||
|
||||
Map<String, String> data1 = new HashMap<>();
|
||||
data1.put("spring.kubernetes.test.value", "value1");
|
||||
mockClient.configMaps().inNamespace("testns").createNew().withNewMetadata().withName("testapp").endMetadata()
|
||||
.addToData(data1).done();
|
||||
mockClient.configMaps().inNamespace("testns").create(
|
||||
new ConfigMapBuilder().withNewMetadata().withName("testapp").endMetadata().addToData(data1).build());
|
||||
|
||||
Map<String, String> data2 = new HashMap<>();
|
||||
data2.put("amq.user", "YWRtaW4K");
|
||||
data2.put("amq.pwd", "MWYyZDFlMmU2N2Rm");
|
||||
mockClient.secrets().inNamespace("testns").createNew().withNewMetadata().withName("testapp").endMetadata()
|
||||
.addToData(data2).done();
|
||||
mockClient.secrets().inNamespace("testns").create(
|
||||
new SecretBuilder().withNewMetadata().withName("testapp").endMetadata().addToData(data2).build());
|
||||
|
||||
// Configure the kubernetes master url to point to the mock server
|
||||
System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl());
|
||||
|
||||
@@ -66,7 +66,8 @@ public class Fabric8SecretsPropertySourceTest {
|
||||
System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, NAMESPACE);
|
||||
System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true");
|
||||
|
||||
Secret secret = new SecretBuilder().withNewMetadata().withLabels(singletonMap("foo", "bar")).endMetadata()
|
||||
Secret secret = new SecretBuilder().withNewMetadata().withName("test-secret")
|
||||
.withLabels(singletonMap("foo", "bar")).endMetadata()
|
||||
.addToData("secretName", Base64.getEncoder().encodeToString(SECRET_VALUE.getBytes())).build();
|
||||
mockClient.secrets().inNamespace(NAMESPACE).create(secret);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.cloud.kubernetes.fabric8.config;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
|
||||
@@ -81,8 +82,8 @@ public class MultipleConfigMapsTests {
|
||||
private static void createConfigmap(KubernetesClient client, String configMapName, String namespace,
|
||||
Map<String, String> data) {
|
||||
|
||||
client.configMaps().inNamespace(namespace).createNew().withNewMetadata().withName(configMapName).endMetadata()
|
||||
.addToData(data).done();
|
||||
client.configMaps().inNamespace(namespace).create(
|
||||
new ConfigMapBuilder().withNewMetadata().withName(configMapName).endMetadata().addToData(data).build());
|
||||
}
|
||||
|
||||
// the last confimap defined in 'multiplecms.yml' has the highest priority, so
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Map;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMap;
|
||||
import io.fabric8.kubernetes.api.model.ConfigMapList;
|
||||
import io.fabric8.kubernetes.api.model.DoneableConfigMap;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.dsl.MixedOperation;
|
||||
import io.fabric8.kubernetes.client.dsl.Resource;
|
||||
@@ -55,9 +54,8 @@ public class EventBasedConfigurationChangeDetectorTests {
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("foo", "bar");
|
||||
configMap.setData(data);
|
||||
MixedOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> mixedOperation = mock(
|
||||
MixedOperation.class);
|
||||
Resource<ConfigMap, DoneableConfigMap> resource = mock(Resource.class);
|
||||
MixedOperation<ConfigMap, ConfigMapList, Resource<ConfigMap>> mixedOperation = mock(MixedOperation.class);
|
||||
Resource<ConfigMap> resource = mock(Resource.class);
|
||||
when(resource.get()).thenReturn(configMap);
|
||||
when(mixedOperation.withName(eq("myconfigmap"))).thenReturn(resource);
|
||||
when(k8sClient.configMaps()).thenReturn(mixedOperation);
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.function.Function;
|
||||
import io.fabric8.kubernetes.api.model.Service;
|
||||
import io.fabric8.kubernetes.api.model.ServiceList;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.Watch;
|
||||
import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
|
||||
|
||||
/**
|
||||
@@ -43,6 +42,6 @@ import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
|
||||
* @author Georgios Andrianakis
|
||||
*/
|
||||
public interface KubernetesClientServicesFunction
|
||||
extends Function<KubernetesClient, FilterWatchListDeletable<Service, ServiceList, Boolean, Watch>> {
|
||||
extends Function<KubernetesClient, FilterWatchListDeletable<Service, ServiceList>> {
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.DoneableEndpoints;
|
||||
import io.fabric8.kubernetes.api.model.EndpointAddress;
|
||||
import io.fabric8.kubernetes.api.model.EndpointSubset;
|
||||
import io.fabric8.kubernetes.api.model.Endpoints;
|
||||
@@ -69,7 +68,7 @@ public class KubernetesCatalogWatchTest {
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
@Mock
|
||||
private MixedOperation<Endpoints, EndpointsList, DoneableEndpoints, Resource<Endpoints, DoneableEndpoints>> endpointsOperation;
|
||||
private MixedOperation<Endpoints, EndpointsList, Resource<Endpoints>> endpointsOperation;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<HeartbeatEvent> heartbeatEventArgumentCaptor;
|
||||
|
||||
@@ -21,8 +21,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.DoneableEndpoints;
|
||||
import io.fabric8.kubernetes.api.model.DoneableService;
|
||||
import io.fabric8.kubernetes.api.model.EndpointPort;
|
||||
import io.fabric8.kubernetes.api.model.EndpointPortBuilder;
|
||||
import io.fabric8.kubernetes.api.model.Endpoints;
|
||||
@@ -35,7 +33,6 @@ import io.fabric8.kubernetes.api.model.ServiceList;
|
||||
import io.fabric8.kubernetes.api.model.ServicePort;
|
||||
import io.fabric8.kubernetes.api.model.ServicePortBuilder;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.Watch;
|
||||
import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
|
||||
import io.fabric8.kubernetes.client.dsl.MixedOperation;
|
||||
import io.fabric8.kubernetes.client.dsl.Resource;
|
||||
@@ -74,19 +71,19 @@ public class KubernetesDiscoveryClientFilterMetadataTest {
|
||||
private KubernetesDiscoveryProperties.Metadata metadata;
|
||||
|
||||
@Mock
|
||||
private MixedOperation<Service, ServiceList, DoneableService, ServiceResource<Service, DoneableService>> serviceOperation;
|
||||
private MixedOperation<Service, ServiceList, ServiceResource<Service>> serviceOperation;
|
||||
|
||||
@Mock
|
||||
private MixedOperation<Endpoints, EndpointsList, DoneableEndpoints, Resource<Endpoints, DoneableEndpoints>> endpointsOperation;
|
||||
private MixedOperation<Endpoints, EndpointsList, Resource<Endpoints>> endpointsOperation;
|
||||
|
||||
@Mock
|
||||
private ServiceResource<Service, DoneableService> serviceResource;
|
||||
private ServiceResource<Service> serviceResource;
|
||||
|
||||
@Mock
|
||||
private Resource<Endpoints, DoneableEndpoints> endpointsResource;
|
||||
private Resource<Endpoints> endpointsResource;
|
||||
|
||||
@Mock
|
||||
FilterWatchListDeletable<Endpoints, EndpointsList, Boolean, Watch> filter;
|
||||
FilterWatchListDeletable<Endpoints, EndpointsList> filter;
|
||||
|
||||
@InjectMocks
|
||||
private KubernetesDiscoveryClient underTest;
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.DoneableService;
|
||||
import io.fabric8.kubernetes.api.model.ObjectMeta;
|
||||
import io.fabric8.kubernetes.api.model.Service;
|
||||
import io.fabric8.kubernetes.api.model.ServiceList;
|
||||
@@ -50,7 +49,7 @@ public class KubernetesDiscoveryClientFilterTest {
|
||||
private KubernetesClientServicesFunction kubernetesClientServicesFunction = KubernetesClient::services;
|
||||
|
||||
@Mock
|
||||
private MixedOperation<Service, ServiceList, DoneableService, ServiceResource<Service, DoneableService>> serviceOperation;
|
||||
private MixedOperation<Service, ServiceList, ServiceResource<Service>> serviceOperation;
|
||||
|
||||
private KubernetesDiscoveryClient underTest;
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.cloud.kubernetes.fabric8.leader;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMap;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.KubernetesClientException;
|
||||
import io.fabric8.kubernetes.client.Watch;
|
||||
import io.fabric8.kubernetes.client.Watcher;
|
||||
import io.fabric8.kubernetes.client.WatcherException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -86,7 +86,7 @@ public class Fabric8LeaderRecordWatcher
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(KubernetesClientException cause) {
|
||||
public void onClose(WatcherException cause) {
|
||||
if (cause != null) {
|
||||
synchronized (this.lock) {
|
||||
LOGGER.warn("Watcher stopped unexpectedly, will restart", cause);
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.fabric8.leader;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.DoneablePod;
|
||||
import io.fabric8.kubernetes.api.model.Pod;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.KubernetesClientException;
|
||||
import io.fabric8.kubernetes.client.Watch;
|
||||
import io.fabric8.kubernetes.client.Watcher;
|
||||
import io.fabric8.kubernetes.client.WatcherException;
|
||||
import io.fabric8.kubernetes.client.dsl.PodResource;
|
||||
import io.fabric8.kubernetes.client.internal.readiness.Readiness;
|
||||
import org.slf4j.Logger;
|
||||
@@ -61,7 +60,7 @@ public class Fabric8PodReadinessWatcher implements PodReadinessWatcher, Watcher<
|
||||
synchronized (this.lock) {
|
||||
if (this.watch == null) {
|
||||
LOGGER.debug("Starting pod readiness watcher for '{}'", this.podName);
|
||||
PodResource<Pod, DoneablePod> podResource = this.kubernetesClient.pods().withName(this.podName);
|
||||
PodResource<Pod> podResource = this.kubernetesClient.pods().withName(this.podName);
|
||||
this.previousState = podResource.isReady();
|
||||
this.watch = podResource.watch(this);
|
||||
}
|
||||
@@ -98,7 +97,7 @@ public class Fabric8PodReadinessWatcher implements PodReadinessWatcher, Watcher<
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(KubernetesClientException cause) {
|
||||
public void onClose(WatcherException cause) {
|
||||
if (cause != null) {
|
||||
synchronized (this.lock) {
|
||||
LOGGER.warn("Watcher stopped unexpectedly, will restart", cause);
|
||||
|
||||
@@ -18,11 +18,10 @@ package org.springframework.cloud.kubernetes.fabric8.leader;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMap;
|
||||
import io.fabric8.kubernetes.api.model.ConfigMapList;
|
||||
import io.fabric8.kubernetes.api.model.DoneableConfigMap;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.KubernetesClientException;
|
||||
import io.fabric8.kubernetes.client.Watch;
|
||||
import io.fabric8.kubernetes.client.Watcher;
|
||||
import io.fabric8.kubernetes.client.WatcherException;
|
||||
import io.fabric8.kubernetes.client.dsl.MixedOperation;
|
||||
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
|
||||
import io.fabric8.kubernetes.client.dsl.Resource;
|
||||
@@ -54,13 +53,13 @@ public class Fabric8LeaderRecordWatcherTest {
|
||||
private KubernetesClient mockKubernetesClient;
|
||||
|
||||
@Mock
|
||||
private MixedOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> mockConfigMapsOperation;
|
||||
private MixedOperation<ConfigMap, ConfigMapList, Resource<ConfigMap>> mockConfigMapsOperation;
|
||||
|
||||
@Mock
|
||||
private NonNamespaceOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> mockInNamespaceOperation;
|
||||
private NonNamespaceOperation<ConfigMap, ConfigMapList, Resource<ConfigMap>> mockInNamespaceOperation;
|
||||
|
||||
@Mock
|
||||
private Resource<ConfigMap, DoneableConfigMap> mockWithNameResource;
|
||||
private Resource<ConfigMap> mockWithNameResource;
|
||||
|
||||
@Mock
|
||||
private Watch mockWatch;
|
||||
@@ -69,7 +68,7 @@ public class Fabric8LeaderRecordWatcherTest {
|
||||
private ConfigMap mockConfigMap;
|
||||
|
||||
@Mock
|
||||
private KubernetesClientException mockKubernetesClientException;
|
||||
private WatcherException mockKubernetesClientException;
|
||||
|
||||
private Fabric8LeaderRecordWatcher watcher;
|
||||
|
||||
|
||||
@@ -16,14 +16,13 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.fabric8.leader;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.DoneablePod;
|
||||
import io.fabric8.kubernetes.api.model.Pod;
|
||||
import io.fabric8.kubernetes.api.model.PodList;
|
||||
import io.fabric8.kubernetes.api.model.PodStatus;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.KubernetesClientException;
|
||||
import io.fabric8.kubernetes.client.Watch;
|
||||
import io.fabric8.kubernetes.client.Watcher;
|
||||
import io.fabric8.kubernetes.client.WatcherException;
|
||||
import io.fabric8.kubernetes.client.dsl.MixedOperation;
|
||||
import io.fabric8.kubernetes.client.dsl.PodResource;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -51,10 +50,10 @@ public class Fabric8PodReadinessWatcherTest {
|
||||
private KubernetesClient mockKubernetesClient;
|
||||
|
||||
@Mock
|
||||
private MixedOperation<Pod, PodList, DoneablePod, PodResource<Pod, DoneablePod>> mockPodsOperation;
|
||||
private MixedOperation<Pod, PodList, PodResource<Pod>> mockPodsOperation;
|
||||
|
||||
@Mock
|
||||
private PodResource<Pod, DoneablePod> mockPodResource;
|
||||
private PodResource<Pod> mockPodResource;
|
||||
|
||||
@Mock
|
||||
private Pod mockPod;
|
||||
@@ -66,7 +65,7 @@ public class Fabric8PodReadinessWatcherTest {
|
||||
private Watch mockWatch;
|
||||
|
||||
@Mock
|
||||
private KubernetesClientException mockKubernetesClientException;
|
||||
private WatcherException mockKubernetesClientException;
|
||||
|
||||
private Fabric8PodReadinessWatcher watcher;
|
||||
|
||||
|
||||
@@ -18,12 +18,10 @@ package org.springframework.cloud.kubernetes.fabric8.loadbalancer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.DoneableService;
|
||||
import io.fabric8.kubernetes.api.model.Service;
|
||||
import io.fabric8.kubernetes.api.model.ServiceBuilder;
|
||||
import io.fabric8.kubernetes.api.model.ServiceList;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.Watch;
|
||||
import io.fabric8.kubernetes.client.dsl.FilterWatchListMultiDeletable;
|
||||
import io.fabric8.kubernetes.client.dsl.MixedOperation;
|
||||
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
|
||||
@@ -56,16 +54,16 @@ class KubernetesServiceListSupplierTests {
|
||||
KubernetesClient client;
|
||||
|
||||
@Mock
|
||||
MixedOperation<Service, ServiceList, DoneableService, ServiceResource<Service, DoneableService>> serviceOperation;
|
||||
MixedOperation<Service, ServiceList, ServiceResource<Service>> serviceOperation;
|
||||
|
||||
@Mock
|
||||
NonNamespaceOperation<Service, ServiceList, DoneableService, ServiceResource<Service, DoneableService>> namespaceOperation;
|
||||
NonNamespaceOperation<Service, ServiceList, ServiceResource<Service>> namespaceOperation;
|
||||
|
||||
@Mock
|
||||
ServiceResource<Service, DoneableService> serviceResource;
|
||||
ServiceResource<Service> serviceResource;
|
||||
|
||||
@Mock
|
||||
FilterWatchListMultiDeletable<Service, ServiceList, Boolean, Watch> multiDeletable;
|
||||
FilterWatchListMultiDeletable<Service, ServiceList> multiDeletable;
|
||||
|
||||
@Test
|
||||
void testPositiveMatch() {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.fabric8.loadbalancer;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.EndpointsBuilder;
|
||||
import io.fabric8.kubernetes.api.model.ServiceBuilder;
|
||||
import io.fabric8.kubernetes.api.model.ServicePortBuilder;
|
||||
import io.fabric8.kubernetes.api.model.ServiceSpecBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
@@ -63,15 +65,16 @@ class LoadBalancerAllNamespacesTests {
|
||||
}
|
||||
|
||||
private void createTestData(String name, String namespace) {
|
||||
client.services().inNamespace(namespace).createNew().withNewMetadata().withName(name).withNamespace(namespace)
|
||||
.endMetadata()
|
||||
client.services().inNamespace(namespace).create(new ServiceBuilder().withNewMetadata().withName(name)
|
||||
.withNamespace(namespace).endMetadata()
|
||||
.withSpec(new ServiceSpecBuilder()
|
||||
.withPorts(new ServicePortBuilder().withProtocol("TCP").withPort(randomServerPort).build())
|
||||
.build())
|
||||
.done();
|
||||
client.endpoints().inNamespace(namespace).createNew().withNewMetadata().withName("service-a")
|
||||
.withNamespace(namespace).endMetadata().addNewSubset().addNewAddress().withIp("localhost").endAddress()
|
||||
.addNewPort().withName("http").withPort(randomServerPort).endPort().endSubset().done();
|
||||
.build());
|
||||
client.endpoints().inNamespace(namespace)
|
||||
.create(new EndpointsBuilder().withNewMetadata().withName("service-a").withNamespace(namespace)
|
||||
.endMetadata().addNewSubset().addNewAddress().withIp("localhost").endAddress().addNewPort()
|
||||
.withName("http").withPort(randomServerPort).endPort().endSubset().build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.fabric8.loadbalancer;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.EndpointsBuilder;
|
||||
import io.fabric8.kubernetes.api.model.ServiceBuilder;
|
||||
import io.fabric8.kubernetes.api.model.ServicePortBuilder;
|
||||
import io.fabric8.kubernetes.api.model.ServiceSpecBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
@@ -68,14 +70,16 @@ class LoadBalancerTests {
|
||||
}
|
||||
|
||||
private void createTestData(String name, String namespace) {
|
||||
client.services().inNamespace(namespace).createNew().withNewMetadata().withName(name).endMetadata()
|
||||
client.services().inNamespace(namespace).create(new ServiceBuilder().withNewMetadata().withName(name)
|
||||
.endMetadata()
|
||||
.withSpec(new ServiceSpecBuilder()
|
||||
.withPorts(new ServicePortBuilder().withProtocol("TCP").withPort(randomServerPort).build())
|
||||
.build())
|
||||
.done();
|
||||
client.endpoints().inNamespace(namespace).createNew().withNewMetadata().withName("service-a").endMetadata()
|
||||
.addNewSubset().addNewAddress().withIp("localhost").endAddress().addNewPort().withName("http")
|
||||
.withPort(randomServerPort).endPort().endSubset().done();
|
||||
.build());
|
||||
client.endpoints().inNamespace(namespace)
|
||||
.create(new EndpointsBuilder().withNewMetadata().withName("service-a").endMetadata().addNewSubset()
|
||||
.addNewAddress().withIp("localhost").endAddress().addNewPort().withName("http")
|
||||
.withPort(randomServerPort).endPort().endSubset().build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.kubernetes.fabric8.loadbalancer;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ServiceBuilder;
|
||||
import io.fabric8.kubernetes.api.model.ServicePortBuilder;
|
||||
import io.fabric8.kubernetes.api.model.ServiceSpecBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
@@ -94,11 +95,12 @@ class LoadBalancerWithServiceTests {
|
||||
}
|
||||
|
||||
private void createTestData(String name, String namespace) {
|
||||
client.services().inNamespace(namespace).createNew().withNewMetadata().withName(name).endMetadata()
|
||||
client.services().inNamespace(namespace).create(new ServiceBuilder().withNewMetadata().withName(name)
|
||||
.endMetadata()
|
||||
.withSpec(new ServiceSpecBuilder()
|
||||
.withPorts(new ServicePortBuilder().withProtocol("TCP").withPort(randomServerPort).build())
|
||||
.build())
|
||||
.done();
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user