Exemplo n.º 1
0
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"
Exemplo n.º 2
0
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"
Exemplo n.º 3
0
def test_parse_target_pod_metric(parser):
    metric_spec = V2beta2MetricSpec(
        type="Pods",
        pods=V2beta2PodsMetricSource(
            metric=V2beta2MetricIdentifier(name="foo"),
            target=V2beta2MetricTarget(type="AverageValue", average_value=0.5,),
        ),
    )
    status = parser.parse_target(metric_spec)
    assert status["name"] == "foo"
    assert status["target_value"] == "0.5"
Exemplo n.º 4
0
def test_parse_target_external_metric_value(parser):
    metric_spec = V2beta2MetricSpec(
        type="External",
        external=V2beta2ExternalMetricSource(
            metric=V2beta2MetricIdentifier(name="foo"),
            target=V2beta2MetricTarget(type="Value", average_value=12,),
        ),
    )
    status = parser.parse_target(metric_spec)
    assert status["name"] == "foo"
    assert status["target_value"] == "12"
Exemplo n.º 5
0
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"
Exemplo n.º 6
0
def test_parse_target_external_metric_average_value(parser):
    # The parser handles this case, but it's not currently
    # used in kubernetes_tools
    metric_spec = V2beta2MetricSpec(
        type="External",
        external=V2beta2ExternalMetricSource(
            metric=V2beta2MetricIdentifier(name="foo"),
            target=V2beta2MetricTarget(type="AverageValue", average_value=0.5,),
        ),
    )
    status = parser.parse_target(metric_spec)
    assert status["name"] == "foo"
    assert status["target_value"] == "0.5"
Exemplo n.º 7
0
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"
Exemplo n.º 8
0
def test_parse_target_object_metric(parser):
    metric_spec = V2beta2MetricSpec(
        type="Object",
        object=V2beta2ObjectMetricSource(
            metric=V2beta2MetricIdentifier(name="some-metric"),
            described_object=V2beta2CrossVersionObjectReference(
                api_version="apps/v1", kind="Deployment", name="deployment"
            ),
            target=V2beta2MetricTarget(type="Value", value=1,),
        ),
    )
    status = parser.parse_target(metric_spec)
    assert status["name"] == "some-metric"
    assert status["target_value"] == "1"