Exemple #1
0
def microservice_available_and_healthy(
    name: str, ns: str = "default", label_selector: str = None, secrets: Secrets = None
) -> Union[bool, None]:
    """
    !!!DEPRECATED!!!
    """
    _log_deprecated(
        "microservice_available_and_healthy", "deployment_available_and_healthy"
    )
    deployment_available_and_healthy(name, ns, label_selector, secrets)
Exemple #2
0
def test_expecting_a_healthy_microservice_should_be_reported_when_not(
        cl, client, has_conf):
    has_conf.return_value = False
    result = MagicMock()
    result.items = []

    v1 = MagicMock()
    v1.list_namespaced_deployment.return_value = result
    client.AppsV1beta1Api.return_value = v1

    with pytest.raises(ActivityFailed) as excinfo:
        deployment_available_and_healthy("mysvc")
    assert "Deployment 'mysvc' was not found" in str(excinfo)

    deployment = MagicMock()
    deployment.spec.replicas = 2
    deployment.status.available_replicas = 1
    result.items.append(deployment)

    with pytest.raises(ActivityFailed) as excinfo:
        deployment_available_and_healthy("mysvc")
    assert "Deployment 'mysvc' is not healthy" in str(excinfo)
Exemple #3
0
def test_expecting_a_healthy_microservice(cl, client, has_conf):
    has_conf.return_value = False
    result = MagicMock()
    result.items = []

    v1 = MagicMock()
    v1.list_namespaced_deployment.return_value = result
    client.AppsV1beta1Api.return_value = v1

    deployment = MagicMock()
    deployment.spec.replicas = 2
    deployment.status.available_replicas = 2
    result.items.append(deployment)

    assert deployment_available_and_healthy("mysvc") is True