def test_restart_machine_with_no_machines(fetch):
    with pytest.raises(FailedActivity) as x:
        resource_list = []
        fetch.return_value = resource_list
        restart_machines(None, None, None)

    assert "No virtual machines found" in str(x.value)
def test_restart_two_machines(init, fetch):
    client = MagicMock()
    init.return_value = client

    machines = [MACHINE_ALPHA, MACHINE_BETA]
    fetch.return_value = machines

    f = "where resourceGroup=='myresourcegroup' | sample 2"
    restart_machines(f, CONFIG, SECRETS)

    fetch.assert_called_with(f, CONFIG, SECRETS)
    assert client.virtual_machines.restart.call_count == 2
Exemplo n.º 3
0
def restart_node(filter: str = None,
                 configuration: Configuration = None,
                 secrets: Secrets = None):
    """
    Restart a node at random from a managed Azure Kubernetes Service.

    Parameters
    ----------
    filter : str
        Filter the managed AKS. If the filter is omitted all AKS in
        the subscription will be selected as potential chaos candidates.
        Filtering example:
        'where resourceGroup=="myresourcegroup" and name="myresourcename"'
    """
    logger.debug("Start restart_node: configuration='{}', filter='{}'".format(
        configuration, filter))

    query = node_resource_group_query(filter, configuration, secrets)
    restart_machines(query, configuration, secrets)