Skip to content

Commit

Permalink
Fix generic watches.
Browse files Browse the repository at this point in the history
  • Loading branch information
brendandburns committed Aug 11, 2020
1 parent dd06710 commit c59623f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,10 @@ public Watchable<ApiType> watch(String namespace, final ListOptions listOptions)
throw new IllegalArgumentException("invalid namespace");
}
Call call =
customObjectsApi.listClusterCustomObjectCall(
customObjectsApi.listNamespacedCustomObjectCall(
this.apiGroup,
this.apiVersion,
namespace,
this.resourcePlural,
null,
listOptions.getContinue(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
import com.google.gson.Gson;
import io.kubernetes.client.custom.V1Patch;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.models.*;
import io.kubernetes.client.util.ClientBuilder;
import io.kubernetes.client.util.Watchable;
import io.kubernetes.client.util.generic.options.ListOptions;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -163,6 +166,20 @@ public void patchNamespacedJobReturningObject() {
verify(1, patchRequestedFor(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1")));
}

@Test
public void watchNamespacedJobReturningObject() throws ApiException {
V1JobList jobList = new V1JobList().kind("JobList").metadata(new V1ListMeta());

stubFor(
get(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs"))
.willReturn(aResponse().withStatus(200).withBody(new Gson().toJson(jobList))));
Watchable<V1Job> jobListWatch = jobClient.watch("default", new ListOptions());
verify(
1,
getRequestedFor(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs"))
.withQueryParam("watch", equalTo("true")));
}

@Test
public void testReadTimeoutShouldThrowException() {
ApiClient apiClient = new ClientBuilder().setBasePath("http://localhost:" + 8181).build();
Expand Down

0 comments on commit c59623f

Please sign in to comment.