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

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

    machines = [MACHINE_ALPHA]
    fetch.return_value = machines

    f = "where resourceGroup=='myresourcegroup' | sample 1"
    stop_machines(f, CONFIG, SECRETS)

    fetch.assert_called_with(f, CONFIG, SECRETS)
    assert client.virtual_machines.power_off.call_count == 1
示例#3
0
def stop_node(filter: str = None,
              configuration: Configuration = None,
              secrets: Secrets = None):
    """
    Stop 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 stop_node: configuration='{}', filter='{}'".format(
        configuration, filter))

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