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());
}
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());
}
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");
}
Aggregations