use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class KubectlGetTest method testGetAllNodes.
@Test
public void testGetAllNodes() throws KubectlException {
V1NodeList nodeList = new V1NodeList().items(Arrays.asList(new V1Node().metadata(new V1ObjectMeta().name("foo1")), new V1Node().metadata(new V1ObjectMeta().name("foo2"))));
wireMockRule.stubFor(get(urlPathEqualTo("/api/v1/nodes")).willReturn(aResponse().withStatus(200).withBody(apiClient.getJSON().serialize(nodeList))));
List<V1Node> nodes = Kubectl.get(V1Node.class).apiClient(apiClient).skipDiscovery().execute();
wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/api/v1/nodes")));
assertEquals(2, nodes.size());
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class KubectlGetTest method testGetOneNode.
@Test
public void testGetOneNode() throws KubectlException {
V1Node node = new V1Node().metadata(new V1ObjectMeta().name("foo1"));
wireMockRule.stubFor(get(urlPathEqualTo("/api/v1/nodes/foo1")).willReturn(aResponse().withStatus(200).withBody(apiClient.getJSON().serialize(node))));
V1Node getNode = Kubectl.get(V1Node.class).apiClient(apiClient).skipDiscovery().name("foo1").execute();
wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/api/v1/nodes/foo1")));
assertEquals(node, getNode);
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class KubectlGetTest method testGetDefaultNamespaceOnePod.
@Test
public void testGetDefaultNamespaceOnePod() throws KubectlException {
V1Pod pod = new V1Pod().metadata(new V1ObjectMeta().namespace("default").name("foo1"));
wireMockRule.stubFor(get(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1")).willReturn(aResponse().withStatus(200).withBody(apiClient.getJSON().serialize(pod))));
Kubectl.get(V1Pod.class).apiClient(apiClient).skipDiscovery().namespace("default").name("foo1").execute();
Kubectl.get(V1Pod.class).apiClient(apiClient).skipDiscovery().name("foo1").namespace("default").execute();
wireMockRule.verify(2, getRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1")));
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class KubectlGetTest method testGetAllNamespacePods.
@Test
public void testGetAllNamespacePods() throws KubectlException {
V1PodList podList = new V1PodList().items(Arrays.asList(new V1Pod().metadata(new V1ObjectMeta().namespace("default").name("foo1")), new V1Pod().metadata(new V1ObjectMeta().namespace("default").name("foo2"))));
wireMockRule.stubFor(get(urlPathEqualTo("/api/v1/pods")).willReturn(aResponse().withStatus(200).withBody(apiClient.getJSON().serialize(podList))));
List<V1Pod> pods = Kubectl.get(V1Pod.class).apiClient(apiClient).skipDiscovery().execute();
wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/api/v1/pods")));
assertEquals(2, pods.size());
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project java by kubernetes-client.
the class KubernetesInformerCreatorTest method testInformerInjection.
@Test
public void testInformerInjection() throws InterruptedException {
assertNotNull(podInformer);
assertNotNull(configMapInformer);
Semaphore getCount = new Semaphore(2);
Semaphore watchCount = new Semaphore(2);
Parameters getParams = new Parameters();
Parameters watchParams = new Parameters();
getParams.put("semaphore", getCount);
watchParams.put("semaphore", watchCount);
V1Pod foo1 = new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
V1ConfigMap bar1 = new V1ConfigMap().kind("ConfigMap").metadata(new V1ObjectMeta().namespace("default").name("bar1"));
wireMockRule.stubFor(get(urlMatching("^/api/v1/pods.*")).withPostServeAction("semaphore", getParams).withQueryParam("watch", equalTo("false")).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(new V1PodList().metadata(new V1ListMeta().resourceVersion("0")).items(Arrays.asList(foo1))))));
wireMockRule.stubFor(get(urlMatching("^/api/v1/pods.*")).withPostServeAction("semaphore", watchParams).withQueryParam("watch", equalTo("true")).willReturn(aResponse().withStatus(200).withBody("{}")));
wireMockRule.stubFor(get(urlMatching("^/api/v1/namespaces/default/configmaps.*")).withPostServeAction("semaphore", getParams).withQueryParam("watch", equalTo("false")).willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(new V1ConfigMapList().metadata(new V1ListMeta().resourceVersion("0")).items(Arrays.asList(bar1))))));
wireMockRule.stubFor(get(urlMatching("^/api/v1/namespaces/default/configmaps.*")).withPostServeAction("semaphore", watchParams).withQueryParam("watch", equalTo("true")).willReturn(aResponse().withStatus(200).withBody("{}")));
// These will be released for each web call above.
getCount.acquire(2);
watchCount.acquire(2);
informerFactory.startAllRegisteredInformers();
// Wait for the GETs to complete and the watches to start.
getCount.acquire(2);
watchCount.acquire(2);
verify(1, getRequestedFor(urlPathEqualTo("/api/v1/pods")).withQueryParam("watch", equalTo("false")));
verify(getRequestedFor(urlPathEqualTo("/api/v1/pods")).withQueryParam("watch", equalTo("true")));
verify(1, getRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/configmaps")).withQueryParam("watch", equalTo("false")));
verify(getRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/configmaps")).withQueryParam("watch", equalTo("true")));
assertEquals(1, new Lister<>(podInformer.getIndexer()).list().size());
assertEquals(1, new Lister<>(configMapInformer.getIndexer()).list().size());
}
Aggregations