Search in sources :

Example 1 with NodeMetricsListBuilder

use of io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsListBuilder in project kubernetes-client by fabric8io.

the class MetricsTest method testNodeMetricWithLabels.

@Test
void testNodeMetricWithLabels() {
    // Given
    server.expect().get().withPath("/apis/metrics.k8s.io/v1beta1/nodes?labelSelector=" + Utils.toUrlEncoded("ss=true,cs=true")).andReturn(200, new NodeMetricsListBuilder().withItems(getNodeMetric()).build()).once();
    Map<String, Object> lablesMap = new HashMap<>();
    lablesMap.put("ss", "true");
    lablesMap.put("cs", "true");
    // When
    NodeMetricsList nodeMetricList = client.top().nodes().metrics(lablesMap);
    // Then
    assertEquals(1, nodeMetricList.getItems().size());
}
Also used : NodeMetricsListBuilder(io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsListBuilder) NodeMetricsList(io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsList) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 2 with NodeMetricsListBuilder

use of io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsListBuilder in project kubernetes-client by fabric8io.

the class MetricsTest method testAllNodeMetrics.

@Test
void testAllNodeMetrics() {
    server.expect().get().withPath("/apis/metrics.k8s.io/v1beta1/nodes").andReturn(200, new NodeMetricsListBuilder().withItems(getNodeMetric()).build()).once();
    NodeMetricsList nodeMetricsList = client.top().nodes().metrics();
    assertEquals(1, nodeMetricsList.getItems().size());
    assertEquals("foo", nodeMetricsList.getItems().get(0).getMetadata().getName());
}
Also used : NodeMetricsListBuilder(io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsListBuilder) NodeMetricsList(io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsList) Test(org.junit.jupiter.api.Test)

Example 3 with NodeMetricsListBuilder

use of io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsListBuilder in project kubernetes-client by fabric8io.

the class NodeMetricsTest method testMetrics.

@Test
void testMetrics() {
    // Given
    server.expect().withPath("/apis/metrics.k8s.io/v1beta1/nodes/the-node").andReturn(HTTP_OK, new NodeMetricsListBuilder().addToItems(new NodeMetricsBuilder().withNewMetadata().withName("the-metric").endMetadata().build()).build()).once();
    // When
    final NodeMetricsList result = client.top().nodes().withName("the-node").metrics();
    // Then
    assertThat(result).extracting(NodeMetricsList::getItems).asList().singleElement().hasFieldOrPropertyWithValue("Kind", "NodeMetrics").hasFieldOrPropertyWithValue("metadata.name", "the-metric");
}
Also used : NodeMetricsListBuilder(io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsListBuilder) NodeMetricsList(io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsList) NodeMetricsBuilder(io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

NodeMetricsList (io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsList)3 NodeMetricsListBuilder (io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsListBuilder)3 Test (org.junit.jupiter.api.Test)3 NodeMetricsBuilder (io.fabric8.kubernetes.api.model.metrics.v1beta1.NodeMetricsBuilder)1 HashMap (java.util.HashMap)1