use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class GenericKubernetesApiForCoreApiTest method patchNamespacedPodReturningObject.
@Test
public void patchNamespacedPodReturningObject() {
V1Patch v1Patch = new V1Patch("{}");
V1Pod foo1 = new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
stubFor(patch(urlEqualTo("/api/v1/namespaces/default/pods/foo1")).withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH)).willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Pod> podPatchResp = podClient.patch("default", "foo1", V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH, v1Patch);
assertTrue(podPatchResp.isSuccess());
assertEquals(foo1, podPatchResp.getObject());
assertNull(podPatchResp.getStatus());
verify(1, patchRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1")));
}
use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class GenericKubernetesApiForCoreApiTest method deleteNamespacedPodReturningDeletedObject.
@Test
public void deleteNamespacedPodReturningDeletedObject() {
V1Pod foo1 = new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
stubFor(delete(urlEqualTo("/api/v1/namespaces/default/pods/foo1")).willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Pod> deletePodResp = podClient.delete("default", "foo1");
assertTrue(deletePodResp.isSuccess());
assertEquals(foo1, deletePodResp.getObject());
assertNull(deletePodResp.getStatus());
verify(1, deleteRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1")));
}
use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class GenericKubernetesApiForCoreApiTest method patchNamespacedPodWithApiPrefix.
@Test
public void patchNamespacedPodWithApiPrefix() {
V1Patch v1Patch = new V1Patch("{}");
V1Pod foo1 = new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
// add api prefix
String prefix = "/k8s/clusters/c-7q988";
stubFor(patch(urlEqualTo(prefix + "/api/v1/namespaces/default/pods/foo1")).withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH)).willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
GenericKubernetesApi<V1Pod, V1PodList> rancherPodClient = new GenericKubernetesApi<>(V1Pod.class, V1PodList.class, "", "v1", "pods", new ClientBuilder().setBasePath("http://localhost:" + 8181 + prefix).build());
KubernetesApiResponse<V1Pod> podPatchResp = rancherPodClient.patch("default", "foo1", V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH, v1Patch);
assertTrue(podPatchResp.isSuccess());
assertEquals(foo1, podPatchResp.getObject());
assertNull(podPatchResp.getStatus());
verify(1, patchRequestedFor(urlPathEqualTo(prefix + "/api/v1/namespaces/default/pods/foo1")));
}
use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class GenericKubernetesApiForCoreApiTest method updateNamespacedPodReturningObject.
@Test
public void updateNamespacedPodReturningObject() {
V1Pod foo1 = new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
stubFor(put(urlEqualTo("/api/v1/namespaces/default/pods/foo1")).willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Pod> podListResp = podClient.update(foo1);
assertTrue(podListResp.isSuccess());
assertEquals(foo1, podListResp.getObject());
assertNull(podListResp.getStatus());
verify(1, putRequestedFor(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1")));
}
use of io.kubernetes.client.openapi.models.V1Pod in project java by kubernetes-client.
the class LabelsTest method testAddMultipleLabels.
@Test
public void testAddMultipleLabels() {
V1Pod pod = new V1Pod().metadata(new V1ObjectMeta());
Map<String, String> newLabels = new HashMap<>();
newLabels.put("foo1", "bar1");
newLabels.put("foo2", "bar2");
Labels.addLabels(pod, newLabels);
assertEquals(pod.getMetadata().getLabels().get("foo1"), "bar1");
assertEquals(pod.getMetadata().getLabels().get("foo2"), "bar2");
}
Aggregations