Skip to content

Commit 74d4cb1

Browse files
committed
cleaned file
1 parent 7c5b81c commit 74d4cb1

File tree

1 file changed

+0
-65
lines changed

1 file changed

+0
-65
lines changed

extended/src/test/java/io/kubernetes/client/extended/kubectl/KubectlDeleteTest.java

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,11 @@
1212
*/
1313

1414
import static com.github.tomakehurst.wiremock.client.WireMock.*;
15-
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
1615
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
17-
import static org.junit.Assert.assertNotNull;
1816
import static org.junit.Assert.assertThrows;
1917

2018
import com.github.tomakehurst.wiremock.junit.WireMockRule;
21-
import com.github.tomakehurst.wiremock.matching.EqualToPattern;
2219
import com.github.tomakehurst.wiremock.stubbing.Scenario;
23-
import io.kubernetes.client.custom.V1Patch;
2420
import io.kubernetes.client.extended.kubectl.Kubectl;
2521
import io.kubernetes.client.extended.kubectl.KubectlDelete;
2622
import io.kubernetes.client.extended.kubectl.exception.KubectlException;
@@ -37,7 +33,6 @@
3733
import java.nio.file.Paths;
3834

3935
import io.kubernetes.client.util.generic.GenericKubernetesApi;
40-
import io.kubernetes.client.util.generic.KubernetesApiResponse;
4136
import org.junit.Before;
4237
import org.junit.Rule;
4338
import org.junit.Test;
@@ -46,9 +41,6 @@ public class KubectlDeleteTest {
4641

4742
private ApiClient apiClient;
4843

49-
private JSON json = new JSON();
50-
private GenericKubernetesApi<V1Job, V1JobList> jobClient;
51-
5244
private static final String DISCOVERY_API =
5345
new File(KubectlDeleteTest.class.getClassLoader().getResource("discovery-api.json").getPath())
5446
.toString();
@@ -70,45 +62,16 @@ public class KubectlDeleteTest {
7062
@Before
7163
public void setup() throws IOException {
7264
apiClient = new ClientBuilder().setBasePath("http://localhost:" + wireMockRule.port()).build();
73-
jobClient =
74-
new GenericKubernetesApi<>(V1Job.class, V1JobList.class, "batch", "v1", "jobs", apiClient);
7565
}
7666

7767
@Test
7868
public void testKubectlDelete() throws KubectlException, IOException, ApiException, InterruptedException {
79-
// wireMockRule.stubFor(
80-
// patch(urlPathEqualTo("/apis/batch/v1/namespaces/foo/jobs/bar"))
81-
// .withHeader(
82-
// "Content-Type", new EqualToPattern(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH))
83-
// .willReturn(
84-
// aResponse()
85-
// .withStatus(200)
86-
// .withBody("{\"metadata\":{\"name\":\"bar\",\"namespace\":\"foo\"}}")));
87-
// V1Status status = new V1Status().kind("Status").code(200).message("good!");
88-
// stubFor(
89-
// delete(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
90-
// .willReturn(aResponse().withStatus(200).withBody(json.serialize(status))));
9169
wireMockRule.stubFor(
9270
post(urlPathEqualTo("/apis/batch/v1/namespaces/foo/jobs"))
93-
// .withHeader(
94-
// "Content-Type", new EqualToPattern("application-json"))
9571
.willReturn(
9672
aResponse()
9773
.withStatus(201)
9874
.withBody("{\"kind\":\"Job\",\"apiVersion\":\"batch/v1\",\"metadata\":{\"name\":\"bar\",\"namespace\":\"foo\",\"uid\":\"7f64e06e-d6a6-4598-b375-7c8773f3b0e7\",\"resourceVersion\":\"46205\",\"generation\":1,\"creationTimestamp\":\"2023-11-23T15:38:18Z\",\"labels\":{\"batch.kubernetes.io/controller-uid\":\"7f64e06e-d6a6-4598-b375-7c8773f3b0e7\",\"batch.kubernetes.io/job-name\":\"bar\",\"controller-uid\":\"7f64e06e-d6a6-4598-b375-7c8773f3b0e7\",\"job-name\":\"bar\"},\"annotations\":{\"batch.kubernetes.io/job-tracking\":\"\"},\"managedFields\":[{\"manager\":\"Kubernetes Java Client\",\"operation\":\"Update\",\"apiVersion\":\"batch/v1\",\"time\":\"2023-11-23T15:38:18Z\",\"fieldsType\":\"FieldsV1\",\"fieldsV1\":{\"f:spec\":{\"f:backoffLimit\":{},\"f:completionMode\":{},\"f:completions\":{},\"f:parallelism\":{},\"f:suspend\":{},\"f:template\":{\"f:spec\":{\"f:containers\":{\"k:{\\\"name\\\":\\\"bar2\\\"}\":{\".\":{},\"f:command\":{},\"f:image\":{},\"f:imagePullPolicy\":{},\"f:name\":{},\"f:resources\":{},\"f:terminationMessagePath\":{},\"f:terminationMessagePolicy\":{}}},\"f:dnsPolicy\":{},\"f:restartPolicy\":{},\"f:schedulerName\":{},\"f:securityContext\":{},\"f:terminationGracePeriodSeconds\":{}}}}}}]},\"spec\":{\"parallelism\":1,\"completions\":1,\"backoffLimit\":6,\"selector\":{\"matchLabels\":{\"batch.kubernetes.io/controller-uid\":\"7f64e06e-d6a6-4598-b375-7c8773f3b0e7\"}},\"template\":{\"metadata\":{\"creationTimestamp\":null,\"labels\":{\"batch.kubernetes.io/controller-uid\":\"7f64e06e-d6a6-4598-b375-7c8773f3b0e7\",\"batch.kubernetes.io/job-name\":\"bar\",\"controller-uid\":\"7f64e06e-d6a6-4598-b375-7c8773f3b0e7\",\"job-name\":\"bar\"}},\"spec\":{\"containers\":[{\"name\":\"bar2\",\"image\":\"busybox\",\"command\":[\"sh\",\"-c\",\"echo Hello World!\"],\"resources\":{},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"Always\"}],\"restartPolicy\":\"Never\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"securityContext\":{},\"schedulerName\":\"default-scheduler\"}},\"completionMode\":\"NonIndexed\",\"suspend\":false},\"status\":{}}")));
99-
// String localVarPath = "/apis/batch/v1/namespaces/{namespace}/jobs"
100-
// .replaceAll("\\{" + "namespace" + "\\}", localVarApiClient.escapeString(namespace.toString()));
101-
102-
103-
// /apis/batch%2Fv1/batch%2Fv1/namespaces/foo/jobs/bar
104-
// /apis/batch/v1/namespaces/foo/jobs/bar
105-
// wireMockRule.stubFor(
106-
// delete(urlPathEqualTo("/apis/batch%2Fv1/batch%2Fv1/namespaces/foo/jobs/bar"))
107-
// .willReturn(
108-
// aResponse()
109-
// .withStatus(200)
110-
// .withBody("{\"kind\":\"Job\",\"apiVersion\":\"batch/v1\",\"metadata\":{\"name\":\"bar\",\"namespace\":\"foo\",\"uid\":\"b862e993-3828-4108-a38f-c19a602d9af6\",\"resourceVersion\":\"82015\",\"generation\":2,\"creationTimestamp\":\"2023-11-24T06:00:49Z\",\"deletionTimestamp\":\"2023-11-24T06:07:44Z\",\"deletionGracePeriodSeconds\":0,\"labels\":{\"batch.kubernetes.io/controller-uid\":\"b862e993-3828-4108-a38f-c19a602d9af6\",\"batch.kubernetes.io/job-name\":\"bar\",\"controller-uid\":\"b862e993-3828-4108-a38f-c19a602d9af6\",\"job-name\":\"bar\"},\"annotations\":{\"batch.kubernetes.io/job-tracking\":\"\"},\"finalizers\":[\"orphan\"],\"managedFields\":[{\"manager\":\"Kubernetes Java Client\",\"operation\":\"Update\",\"apiVersion\":\"batch/v1\",\"time\":\"2023-11-24T06:00:49Z\",\"fieldsType\":\"FieldsV1\",\"fieldsV1\":{\"f:spec\":{\"f:backoffLimit\":{},\"f:completionMode\":{},\"f:completions\":{},\"f:parallelism\":{},\"f:suspend\":{},\"f:template\":{\"f:spec\":{\"f:containers\":{\"k:{\\\"name\\\":\\\"bar2\\\"}\":{\".\":{},\"f:command\":{},\"f:image\":{},\"f:imagePullPolicy\":{},\"f:name\":{},\"f:resources\":{},\"f:terminationMessagePath\":{},\"f:terminationMessagePolicy\":{}}},\"f:dnsPolicy\":{},\"f:restartPolicy\":{},\"f:schedulerName\":{},\"f:securityContext\":{},\"f:terminationGracePeriodSeconds\":{}}}}}},{\"manager\":\"kube-controller-manager\",\"operation\":\"Update\",\"apiVersion\":\"batch/v1\",\"time\":\"2023-11-24T06:00:53Z\",\"fieldsType\":\"FieldsV1\",\"fieldsV1\":{\"f:status\":{\"f:completionTime\":{},\"f:conditions\":{},\"f:ready\":{},\"f:startTime\":{},\"f:succeeded\":{},\"f:uncountedTerminatedPods\":{}}},\"subresource\":\"status\"}]},\"spec\":{\"parallelism\":1,\"completions\":1,\"backoffLimit\":6,\"selector\":{\"matchLabels\":{\"batch.kubernetes.io/controller-uid\":\"b862e993-3828-4108-a38f-c19a602d9af6\"}},\"template\":{\"metadata\":{\"creationTimestamp\":null,\"labels\":{\"batch.kubernetes.io/controller-uid\":\"b862e993-3828-4108-a38f-c19a602d9af6\",\"batch.kubernetes.io/job-name\":\"bar\",\"controller-uid\":\"b862e993-3828-4108-a38f-c19a602d9af6\",\"job-name\":\"bar\"}},\"spec\":{\"containers\":[{\"name\":\"bar2\",\"image\":\"busybox\",\"command\":[\"sh\",\"-c\",\"echo Hello World!\"],\"resources\":{},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"imagePullPolicy\":\"Always\"}],\"restartPolicy\":\"Never\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"securityContext\":{},\"schedulerName\":\"default-scheduler\"}},\"completionMode\":\"NonIndexed\",\"suspend\":false},\"status\":{\"conditions\":[{\"type\":\"Complete\",\"status\":\"True\",\"lastProbeTime\":\"2023-11-24T06:00:53Z\",\"lastTransitionTime\":\"2023-11-24T06:00:53Z\"}],\"startTime\":\"2023-11-24T06:00:49Z\",\"completionTime\":\"2023-11-24T06:00:53Z\",\"succeeded\":1,\"uncountedTerminatedPods\":{},\"ready\":0}}\n")));
111-
//
11275
wireMockRule.stubFor(
11376
delete(urlPathEqualTo("/apis/batch%2Fv1/batch%2Fv1/namespaces/foo/jobs/bar"))
11477
.inScenario("JobDeletionScenario")
@@ -168,18 +131,9 @@ public void testKubectlDelete() throws KubectlException, IOException, ApiExcepti
168131
.kind("Job")
169132
.metadata(new V1ObjectMeta().name("bar"))
170133
.spec(v1JobSpec);
171-
////
172134
BatchV1Api api = new BatchV1Api();
173135
api.setApiClient(apiClient);
174136
api.createNamespacedJob("foo", job, null, null, null, "Strict");
175-
// wireMockRule.stubFor(
176-
// patch(urlPathEqualTo("/apis/batch/v1/namespaces/foo/jobs/bar"))
177-
// .withHeader(
178-
// "Content-Type", new EqualToPattern(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH))
179-
// .willReturn(
180-
// aResponse()
181-
// .withStatus(200)
182-
// .withBody("{\"metadata\":{\"name\":\"bar\",\"namespace\":\"foo\"}}")))
183137
ModelMapper.addModelMap(api.getAPIResources().getGroupVersion(), job.getApiVersion(), job.getKind(), "jobs", true, V1Job.class);
184138

185139
KubectlDelete<V1Job> kubectlDelete = Kubectl.delete(V1Job.class);
@@ -198,24 +152,5 @@ public void testKubectlDelete() throws KubectlException, IOException, ApiExcepti
198152
kubectlDelete2.apiClient(apiClient);
199153
kubectlDelete2.namespace("foo").name("bar").ignoreNotFound(true);
200154
kubectlDelete2.execute();
201-
202-
// jobClient.delete("foo", "bar");
203-
204-
205-
// V1Job foo1 =
206-
// new V1Job().kind("Job").metadata(new V1ObjectMeta().namespace("foo").name("bar"));
207-
//
208-
// stubFor(
209-
// post(urlEqualTo("/apis/batch/v1/namespaces/foo/jobs"))
210-
// .willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
211-
// KubernetesApiResponse<V1Job> jobListResp = jobClient.create(foo1);
212-
// V1Status status = new V1Status().kind("Status").code(200).message("good!");
213-
// stubFor(
214-
// delete(urlEqualTo("/apis/batch/v1/namespaces/foo/jobs/bar"))
215-
// .willReturn(aResponse().withStatus(200).withBody(json.serialize(status))));
216-
//
217-
// KubernetesApiResponse<V1Job> deleteJobResp = jobClient.delete("foo", "bar", null);
218-
// System.out.println(deleteJobResp.isSuccess());
219-
// System.out.println(deleteJobResp.getStatus());
220155
}
221156
}

0 commit comments

Comments
 (0)