Skip to content

Commit 7b49e77

Browse files
committed
Refactor AKS backup configuration initialization
1 parent 15075c6 commit 7b49e77

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_backup_instance_operations.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,20 +297,15 @@ def test_dataprotection_backup_instance_update_aks_configuration(test):
297297

298298
# Fetch original BI backupDatasourceParametersList (if any) to allow resetting later
299299
original_bi = test.cmd('az dataprotection backup-instance show -g "{rg}" --vault-name "{vaultName}" --name "{backupInstanceName}"').get_output_in_json()
300-
original_bi_backup_config_json = original_bi['properties']['policyInfo']['policyParameters'].get('backupDatasourceParametersList')[0]
300+
originalBackupConfig = original_bi['properties']['policyInfo']['policyParameters'].get('backupDatasourceParametersList')[0]
301301
test.kwargs.update({
302-
'backupConfig': original_bi_backup_config_json
302+
'backupConfig': originalBackupConfig
303303
})
304304

305-
# Generate the AKS backup configuration using the dedicated CLI helper
306-
new_backup_config_json = test.cmd('az dataprotection backup-instance initialize-backupconfig --datasource-type AzureKubernetesService').get_output_in_json()
307-
308-
# mutate a visible field to make the change observable
309-
new_backup_config_json['included_namespaces'] = ["nsA", "nsB"]
310-
new_backup_config_json['label_selectors'] = ["app=web"]
311-
new_backup_config_json['excluded_resource_types'] = ["ResourceX"]
312-
new_backup_config_json['include_cluster_scope_resources'] = False
313-
new_backup_config_json['snapshot_volumes'] = False
305+
# Generate the AKS backup configuration with specific values in a single command to make the change observable
306+
new_backup_config_json = test.cmd('az dataprotection backup-instance initialize-backupconfig --datasource-type AzureKubernetesService '
307+
'--included-namespaces "nsA" "nsB" --label-selectors "app=web" --excluded-resource-types "ResourceX" '
308+
'--include-cluster-scope-resources false --snapshot-volumes false').get_output_in_json()
314309
test.kwargs.update({
315310
'tempBackupConfig': new_backup_config_json
316311
})

0 commit comments

Comments
 (0)