Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Make diffbackup_hours optional
  • Loading branch information
danikaZ committed Mar 29, 2022
commit e3053ac22f0ba3f68d00d8da5d582382704e5fda
1 change: 0 additions & 1 deletion src/azure-cli/azure/cli/command_modules/sql/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,6 @@ def _configure_security_policy_storage_params(arg_ctx):
c.argument(
'diffbackup_hours',
options_list=['--diffbackup-hours'],
required=True,
help='New backup short term retention policy differential backup interval in hours.'
'Valid differential backup interval for live database can be 12 or 24 hours.')

Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/sql/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2736,7 +2736,7 @@ def update_short_term_retention(
server_name,
resource_group_name,
retention_days,
diffbackup_hours,
diffbackup_hours=None,
no_wait=False,
**kwargs):
'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -965,26 +965,25 @@ def test_sql_db_short_term_retention(self):
'server_name': 'lillian-westus2-server',
'database_name': 'ps5691',
'retention_days_v1': 7,
'diffbackup_hours_v1': 24,
'retention_days_v2': 6,
'diffbackup_hours_v2': 12
'diffbackup_hours_v2': 12,
'retention_days_v3': 5,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only two groups of retention_Days and diffbackup_hours should be enough for the testing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three sets are better, because set str-policy using set 2 could verify that both retention days and diff backup hours work as expected.

'diffbackup_hours_v3': 10
})

# Test UPDATE short term retention policy on live database, value updated to v1.
# Test UPDATE short term retention policy (retention days only), value equals to v1.
self.cmd(
'sql db str-policy set -g {resource_group} -s {server_name} -n {database_name} --retention-days {retention_days_v1} --diffbackup-hours {diffbackup_hours_v1}',
'sql db str-policy set -g {resource_group} -s {server_name} -n {database_name} --retention-days {retention_days_v1}',
checks=[
self.check('resourceGroup', '{resource_group}'),
self.check('retentionDays', '{retention_days_v1}'),
self.check('diffBackupIntervalInHours', '{diffbackup_hours_v1}')])
self.check('retentionDays', '{retention_days_v1}')])

# Test GET short term retention policy on live database, value equals to v1.
# Test GET short term retention policy (retention days only) on live database, value equals to v1.
self.cmd(
'sql db str-policy show -g {resource_group} -s {server_name} -n {database_name}',
checks=[
self.check('resourceGroup', '{resource_group}'),
self.check('retentionDays', '{retention_days_v1}'),
self.check('diffBackupIntervalInHours', '{diffbackup_hours_v1}')])
self.check('retentionDays', '{retention_days_v1}'),])

# Test UPDATE short term retention policy on live database, value updated to v2.
self.cmd(
Expand All @@ -994,6 +993,22 @@ def test_sql_db_short_term_retention(self):
self.check('retentionDays', '{retention_days_v2}'),
self.check('diffBackupIntervalInHours', '{diffbackup_hours_v2}')])

# Test GET short term retention policy on live database, value equals to v2.
self.cmd(
'sql db str-policy show -g {resource_group} -s {server_name} -n {database_name}',
checks=[
self.check('resourceGroup', '{resource_group}'),
self.check('retentionDays', '{retention_days_v2}'),
self.check('diffBackupIntervalInHours', '{diffbackup_hours_v2}')])

# Test UPDATE short term retention policy on live database, value updated to v3.
self.cmd(
'sql db str-policy set -g {resource_group} -s {server_name} -n {database_name} --retention-days {retention_days_v3} --diffbackup-hours {diffbackup_hours_v3}',
checks=[
self.check('resourceGroup', '{resource_group}'),
self.check('retentionDays', '{retention_days_v3}'),
self.check('diffBackupIntervalInHours', '{diffbackup_hours_v3}')])


class SqlServerDbLongTermRetentionScenarioTest(ScenarioTest):
def test_sql_db_long_term_retention(
Expand Down