Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def migration_update_func(cmd, client, resource_group_name, server_name, migrati
migration_resource = migration_show_func(cmd, client, resource_group_name, server_name, migration_name)
if migration_resource.migration_mode == "Offline":
raise BadRequestError("Cutover is not possible for migration {} if the migration_mode set to offline. The migration will cutover automatically".format(migration_name))
parameters = postgresql_flexibleservers.models.MigrationResourceForPatch(trigger_cutover="True", dbs_to_trigger_cutover_migration_on=migration_resource.dbs_to_migrate)
parameters = postgresql_flexibleservers.models.MigrationResourceForPatch(trigger_cutover="True", dbs_to_trigger_cutover_on=migration_resource.dbs_to_migrate)

if cancel is not None:
if operationSpecified is True:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import unittest
from unittest.mock import MagicMock, patch

from azure.cli.command_modules.postgresql.commands import migration_commands
from azure.mgmt.postgresqlflexibleservers.models import Migration


class MigrationCommandsTest(unittest.TestCase):
Comment thread
nasc17 marked this conversation as resolved.
Resolved

def test_postgresql_migration_cutover_submits_all_databases(self):
cmd = MagicMock()
client = MagicMock()
client.get.return_value = Migration(
location='eastus',
migration_mode='Online',
dbs_to_migrate=['db1', 'db2'],
)

with patch.object(migration_commands, 'validate_citus_cluster'):
result = migration_commands.migration_update_func(
cmd, client, 'test-rg', 'test-server', 'test-migration', cutover=True,
)

client.get.assert_called_once_with('test-rg', 'test-server', 'test-migration')
client.update.assert_called_once()
resource_group, server_name, migration_name, parameters = client.update.call_args.args
self.assertEqual((resource_group, server_name, migration_name),
('test-rg', 'test-server', 'test-migration'))
self.assertEqual(parameters.as_dict(), {
'properties': {
'triggerCutover': 'True',
'dbsToTriggerCutoverOn': ['db1', 'db2'],
},
})
self.assertIs(result, client.update.return_value)
Loading