io.fabric8.kubernetes.api.model.NodeList Java Examples

The following examples show how to use io.fabric8.kubernetes.api.model.NodeList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KubernetesClusterTest.java    From kubernetes-elastic-agents with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldCreateKubernetesClusterObject() throws Exception {
    final KubernetesClient kubernetesClient = mock(KubernetesClient.class);

    NodeOperationsImpl nodes = mock(NodeOperationsImpl.class);
    PodOperationsImpl pods = mock(PodOperationsImpl.class);

    when(nodes.list()).thenReturn(new NodeList());
    when(kubernetesClient.nodes()).thenReturn(nodes);

    when(pods.withLabel(Constants.CREATED_BY_LABEL_KEY, Constants.PLUGIN_ID)).thenReturn(pods);
    when(pods.list()).thenReturn(new PodList());
    when(kubernetesClient.pods()).thenReturn(pods);

    final KubernetesCluster cluster = new KubernetesCluster(kubernetesClient);

    verify(kubernetesClient, times(1)).nodes();
    verify(kubernetesClient, times(1)).pods();
}
 
Example #2
Source File: ClusterStatusReportExecutorTest.java    From kubernetes-elastic-agents with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldBuildStatusReportView() throws Exception {
    NodeOperationsImpl nodes = mock(NodeOperationsImpl.class);
    PodOperationsImpl pods = mock(PodOperationsImpl.class);

    when(nodes.list()).thenReturn(new NodeList());
    when(kubernetesClient.nodes()).thenReturn(nodes);

    when(pods.withLabel(Constants.CREATED_BY_LABEL_KEY, Constants.PLUGIN_ID)).thenReturn(pods);
    when(pods.list()).thenReturn(new PodList());
    when(kubernetesClient.pods()).thenReturn(pods);

    final PluginStatusReportViewBuilder builder = mock(PluginStatusReportViewBuilder.class);
    final Template template = mock(Template.class);

    when(builder.getTemplate("status-report.template.ftlh")).thenReturn(template);
    when(builder.build(eq(template), any(KubernetesCluster.class))).thenReturn("status-report");

    final GoPluginApiResponse response = new ClusterStatusReportExecutor(request, builder, kubernetesClientFactory).execute();

    assertThat(response.responseCode(), is(200));
    assertThat(response.responseBody(), is("{\"view\":\"status-report\"}"));
}
 
Example #3
Source File: NodeTest.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@Test
public void testList() {
 server.expect().withPath("/api/v1/nodes").andReturn(200, new NodeListBuilder().addNewItem().and().build()).once();

  KubernetesClient client = server.getClient();
  NodeList nodeList = client.nodes().list();
  assertNotNull(nodeList);
  assertEquals(1, nodeList.getItems().size());
}
 
Example #4
Source File: NodeOperator.java    From strimzi-kafka-operator with Apache License 2.0 4 votes vote down vote up
@Override
protected NonNamespaceOperation<Node, NodeList, DoneableNode, Resource<Node, DoneableNode>> operation() {
    return client.nodes();
}
 
Example #5
Source File: NodeOperatorIT.java    From strimzi-kafka-operator with Apache License 2.0 4 votes vote down vote up
@Override
protected AbstractNonNamespacedResourceOperator<KubernetesClient,
        Node, NodeList, DoneableNode,
        Resource<Node, DoneableNode>> operator() {
    return new NodeOperator(vertx, client, 10_000);
}
 
Example #6
Source File: NodeOperatorTest.java    From strimzi-kafka-operator with Apache License 2.0 4 votes vote down vote up
@Override
protected AbstractNonNamespacedResourceOperator<KubernetesClient, Node, NodeList,
        DoneableNode, Resource<Node, DoneableNode>> createResourceOperations(
                Vertx vertx, KubernetesClient mockClient) {
    return new NodeOperator(vertx, mockClient, 100);
}
 
Example #7
Source File: AutoAdaptableKubernetesClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public NonNamespaceOperation<Node, NodeList, DoneableNode, Resource<Node, DoneableNode>> nodes() {
  return delegate.nodes();
}
 
Example #8
Source File: DefaultKubernetesClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public NonNamespaceOperation<Node, NodeList, DoneableNode, Resource<Node, DoneableNode>> nodes() {
  return new NodeOperationsImpl(httpClient, getConfiguration());
}
 
Example #9
Source File: ManagedKubernetesClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public NonNamespaceOperation<Node, NodeList, DoneableNode, Resource<Node, DoneableNode>> nodes() {
  return delegate.nodes();
}
 
Example #10
Source File: KubernetesClient.java    From kubernetes-client with Apache License 2.0 2 votes vote down vote up
/**
 * API entrypoint for node related operations in Kubernetes. Node (core/v1)
 *
 * @return NonNamespaceOperation object for Node related operations
 */
NonNamespaceOperation<Node, NodeList, DoneableNode, Resource<Node, DoneableNode>> nodes();