Exemplo n.º 1
0
def test_get_pod_usage(monkeypatch, fake_pod_metric_responses):
    mock_client = get_mock_client(fake_pod_metric_responses)
    cluster = Cluster("test-cluster-1", "test-cluster-1",
                      "https://test-cluster-1.example.org", mock_client)
    pods = {('default', 'pod-1'): {'usage': new_resources()}}
    get_pod_usage(cluster, pods)
    assert pods[('default', 'pod-1')]['usage']['cpu'] == 0.05
Exemplo n.º 2
0
def test_get_node_usage(monkeypatch, fake_node_metric_responses):
    mock_client = get_mock_client(fake_node_metric_responses)
    cluster = Cluster("test-cluster-1", "test-cluster-1",
                      "https://test-cluster-1.example.org", mock_client)
    nodes = {'node-1': {'usage': new_resources()}}
    get_node_usage(cluster, nodes)
    assert nodes['node-1']['usage']['cpu'] == 16
Exemplo n.º 3
0
def test_get_pod_usage(monkeypatch, fake_metric_responses):
    monkeypatch.setattr(
        "kube_resource_report.report.request",
        lambda cluster, path: MagicMock(json=lambda: fake_metric_responses.get(
            path)),
    )
    pods = {('default', 'pod-1'): {'usage': new_resources()}}
    get_pod_usage(None, pods)
    assert pods[('default', 'pod-1')]['usage']['cpu'] == 0.05
Exemplo n.º 4
0
def test_get_node_usage(monkeypatch, fake_node_metric_responses):
    mock_client = get_mock_client(fake_node_metric_responses)
    cluster = Cluster(
        "test-cluster-1",
        "test-cluster-1",
        "https://test-cluster-1.example.org",
        mock_client,
    )
    nodes = {"node-1": {"usage": new_resources()}}
    get_node_usage(cluster, nodes, {}, 1.0)
    assert nodes["node-1"]["usage"]["cpu"] == 16
Exemplo n.º 5
0
def test_get_pod_usage(monkeypatch, fake_pod_metric_responses):
    mock_client = get_mock_client(fake_pod_metric_responses)
    cluster = Cluster(
        "test-cluster-1",
        "test-cluster-1",
        "https://test-cluster-1.example.org",
        mock_client,
    )
    pods = {("default", "pod-1"): {"usage": new_resources()}}
    get_pod_usage(cluster, pods, {}, 1.0)
    assert pods[("default", "pod-1")]["usage"]["cpu"] == 0.05