def test_delete_machine_with_no_machines(fetch): with pytest.raises(FailedActivity) as x: resource_list = [] fetch.return_value = resource_list delete_machines(None, None, None) assert "No virtual machines found" in str(x.value)
def test_delete_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" delete_machines(f, CONFIG, SECRETS) fetch.assert_called_with(f, CONFIG, SECRETS) assert client.virtual_machines.delete.call_count == 2
def test_delete_one_machine_china(init, fetch): client = MagicMock() init.return_value = client machines = [MACHINE_ALPHA] fetch.return_value = machines f = "where resourceGroup=='myresourcegroup' | sample 1" delete_machines(f, CONFIG, SECRETS_CHINA) fetch.assert_called_with(f, CONFIG, SECRETS_CHINA) assert client.virtual_machines.begin_delete.call_count == 1
def delete_node(filter: str = None, configuration: Configuration = None, secrets: Secrets = None): """ Delete a node at random from a managed Azure Kubernetes Service. **Be aware**: Deleting a node is an invasive action. You will not be able to recover the node once you deleted it. 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 delete_node: configuration='{}', filter='{}'".format( configuration, filter)) query = node_resource_group_query(filter, configuration, secrets) delete_machines(query, configuration, secrets)