Esempio n. 1
0
def test_parse_current_empty_string_metric(parser):
    metric_status = V2beta2MetricStatus(
        type="",
    )

    status = parser.parse_current(metric_status)
    assert status is None
Esempio n. 2
0
def test_parse_current_resource_metric(parser):
    metric_status = V2beta2MetricStatus(
        type="Resource",
        resource=V2beta2ResourceMetricStatus(
            current=V2beta2MetricValueStatus(average_utilization=0.4,), name="cpu",
        ),
    )
    status = parser.parse_current(metric_status)
    assert status["name"] == "cpu"
    assert status["current_value"] == "0.4"
def test_parse_current_pod_metric(parser):
    metric_status = V2beta2MetricStatus(
        type="Pods",
        pods=V2beta2PodsMetricStatus(
            current=V2beta2MetricValueStatus(average_value=0.4, ),
            metric=V2beta2MetricIdentifier(name="foo"),
        ),
    )
    status = parser.parse_current(metric_status)
    assert status["name"] == "foo"
    assert status["current_value"] == "0.4"
def test_parse_current_external_metric_value(parser):
    metric_status = V2beta2MetricStatus(
        type="External",
        external=V2beta2ExternalMetricStatus(
            current=V2beta2MetricValueStatus(value=4, ),
            metric=V2beta2MetricIdentifier(name="foo"),
        ),
    )
    status = parser.parse_current(metric_status)
    assert status["name"] == "foo"
    assert status["current_value"] == "4"
def test_parse_current_external_metric_average_value(parser):
    # The parser handles this case, but it's not currently
    # used in kubernetes_tools
    metric_status = V2beta2MetricStatus(
        type="External",
        external=V2beta2ExternalMetricStatus(
            current=V2beta2MetricValueStatus(average_value=0.4, ),
            metric=V2beta2MetricIdentifier(name="foo"),
        ),
    )
    status = parser.parse_current(metric_status)
    assert status["name"] == "foo"
    assert status["current_value"] == "0.4"
def test_parse_current_object_metric(parser):
    metric_status = V2beta2MetricStatus(
        type="Object",
        object=V2beta2ObjectMetricStatus(
            current=V2beta2MetricValueStatus(value=0.1),
            metric=V2beta2MetricIdentifier(name="some-metric"),
            described_object=V2beta2CrossVersionObjectReference(
                api_version="apps/v1", kind="Deployment", name="deployment"),
        ),
    )

    status = parser.parse_current(metric_status)
    assert status["name"] == "some-metric"
    assert status["current_value"] == "0.1"