Search in sources :

Example 11 with ClientBuilder

use of io.kubernetes.client.util.ClientBuilder in project java by kubernetes-client.

the class PortForwardTest method setup.

@Before
public void setup() throws IOException {
    client = new ClientBuilder().setBasePath("http://localhost:" + wireMockRule.port()).build();
    namespace = "default";
    podName = "apod";
}
Also used : ClientBuilder(io.kubernetes.client.util.ClientBuilder) Before(org.junit.Before)

Example 12 with ClientBuilder

use of io.kubernetes.client.util.ClientBuilder in project java by kubernetes-client.

the class GenericKubernetesApiForCoreApiTest method setup.

@Before
public void setup() throws IOException {
    ApiClient apiClient = new ClientBuilder().setBasePath("http://localhost:" + 8181).build();
    podClient = new GenericKubernetesApi<>(V1Pod.class, V1PodList.class, "", "v1", "pods", apiClient);
}
Also used : V1PodList(io.kubernetes.client.openapi.models.V1PodList) V1Pod(io.kubernetes.client.openapi.models.V1Pod) ApiClient(io.kubernetes.client.openapi.ApiClient) ClientBuilder(io.kubernetes.client.util.ClientBuilder) Before(org.junit.Before)

Example 13 with ClientBuilder

use of io.kubernetes.client.util.ClientBuilder in project java by kubernetes-client.

the class GenericKubernetesApiForCoreApiTest method testReadTimeoutShouldThrowException.

@Test
public void testReadTimeoutShouldThrowException() {
    ApiClient apiClient = new ClientBuilder().setBasePath("http://localhost:" + 8181).build();
    apiClient.setHttpClient(apiClient.getHttpClient().newBuilder().readTimeout(1, // timeout everytime
    TimeUnit.MILLISECONDS).build());
    stubFor(get(urlEqualTo("/api/v1/namespaces/foo/pods/test")).willReturn(aResponse().withFixedDelay(99999).withStatus(200).withBody("")));
    podClient = new GenericKubernetesApi<>(V1Pod.class, V1PodList.class, "", "v1", "pods", apiClient);
    try {
        KubernetesApiResponse<V1Pod> response = podClient.get("foo", "test");
    } catch (Throwable t) {
        assertTrue(t.getCause() instanceof SocketTimeoutException);
        return;
    }
    fail("no exception happened");
}
Also used : V1PodList(io.kubernetes.client.openapi.models.V1PodList) SocketTimeoutException(java.net.SocketTimeoutException) V1Pod(io.kubernetes.client.openapi.models.V1Pod) ApiClient(io.kubernetes.client.openapi.ApiClient) ClientBuilder(io.kubernetes.client.util.ClientBuilder) Test(org.junit.Test)

Example 14 with ClientBuilder

use of io.kubernetes.client.util.ClientBuilder in project java by kubernetes-client.

the class GenericKubernetesGetApiTest method setup.

@Before
public void setup() {
    ApiClient apiClient = new ClientBuilder().setBasePath("http://localhost:" + 8181).build();
    jobClient = new GenericKubernetesApi<>(V1Job.class, V1JobList.class, "batch", "v1", "jobs", apiClient);
    fooClient = new GenericKubernetesApi<>(FooCustomResource.class, FooCustomResourceList.class, "example.io", "v1", "foos", apiClient);
}
Also used : V1Job(io.kubernetes.client.openapi.models.V1Job) V1JobList(io.kubernetes.client.openapi.models.V1JobList) ApiClient(io.kubernetes.client.openapi.ApiClient) ClientBuilder(io.kubernetes.client.util.ClientBuilder) Before(org.junit.Before)

Example 15 with ClientBuilder

use of io.kubernetes.client.util.ClientBuilder in project java by kubernetes-client.

the class GenericKubernetesApiTest method testReadTimeoutShouldThrowException.

@Test
public void testReadTimeoutShouldThrowException() {
    ApiClient apiClient = new ClientBuilder().setBasePath("http://localhost:" + 8181).build();
    apiClient.setHttpClient(apiClient.getHttpClient().newBuilder().readTimeout(1, // timeout everytime
    TimeUnit.MILLISECONDS).build());
    stubFor(get(urlEqualTo("/apis/batch/v1/namespaces/foo/jobs/test")).willReturn(aResponse().withFixedDelay(99999).withStatus(200).withBody("")));
    jobClient = new GenericKubernetesApi<>(V1Job.class, V1JobList.class, "batch", "v1", "jobs", apiClient);
    try {
        KubernetesApiResponse<V1Job> response = jobClient.get("foo", "test");
    } catch (Throwable t) {
        assertTrue(t.getCause() instanceof SocketTimeoutException);
        return;
    }
    fail("no exception happened");
}
Also used : V1Job(io.kubernetes.client.openapi.models.V1Job) SocketTimeoutException(java.net.SocketTimeoutException) V1JobList(io.kubernetes.client.openapi.models.V1JobList) ApiClient(io.kubernetes.client.openapi.ApiClient) ClientBuilder(io.kubernetes.client.util.ClientBuilder) Test(org.junit.Test)

Aggregations

ClientBuilder (io.kubernetes.client.util.ClientBuilder)18 Before (org.junit.Before)15 ApiClient (io.kubernetes.client.openapi.ApiClient)6 V1Pod (io.kubernetes.client.openapi.models.V1Pod)4 V1PodList (io.kubernetes.client.openapi.models.V1PodList)4 V1Job (io.kubernetes.client.openapi.models.V1Job)3 V1JobList (io.kubernetes.client.openapi.models.V1JobList)3 Test (org.junit.Test)3 SocketTimeoutException (java.net.SocketTimeoutException)2 V1Patch (io.kubernetes.client.custom.V1Patch)1 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)1