Skip to content

Commit

Permalink
Add tests for coriolis.conductor.rpc.server module
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristi1324 committed Mar 11, 2024
1 parent cfd2da4 commit 9ae48b3
Show file tree
Hide file tree
Showing 5 changed files with 4,436 additions and 1,334 deletions.
11 changes: 4 additions & 7 deletions coriolis/conductor/rpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ def report_migration_minions_allocation_error(
awaiting_minions_status = (
constants.EXECUTION_STATUS_AWAITING_MINION_ALLOCATIONS)
if migration.last_execution_status != awaiting_minions_status:
raise exception.InvalidReplicaState(
raise exception.InvalidMigrationState(
"Migration is in '%s' status instead of the expected '%s' to "
"have minion machines allocations fail for it." % (
migration.last_execution_status, awaiting_minions_status))
Expand Down Expand Up @@ -3291,19 +3291,16 @@ def confirm_task_cancellation(self, ctxt, task_id, cancellation_details):
"NOT altering state of finalized task '%s' ('%s') following "
"confirmation of cancellation. Updating its exception "
"details though: %s", task.id, task.status, exception_details)
db_api.set_task_status(
ctxt, task.id, final_status,
exception_details=exception_details)
else:
LOG.info(
"Transitioning canceled task '%s' from '%s' to '%s' following "
"confirmation of its cancellation.",
task.id, task.status, final_status)
db_api.set_task_status(
ctxt, task.id, final_status,
exception_details=exception_details)
execution = db_api.get_tasks_execution(ctxt, task.execution_id)
self._advance_execution_state(ctxt, execution, requery=False)
db_api.set_task_status(
ctxt, task.id, final_status,
exception_details=exception_details)

@parent_tasks_execution_synchronized
def set_task_error(self, ctxt, task_id, exception_details):
Expand Down
34 changes: 34 additions & 0 deletions coriolis/tests/conductor/rpc/data/cancel_migration_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
- config:
force: False
execution_statuses: [EXECUTION_STATUS_RUNNING]
raises_exception: False

- config:
force: False
execution_statuses: []
raises_exception: True

- config:
force: False
execution_statuses: [EXECUTION_STATUS_COMPLETED]
raises_exception: True

- config:
force: True
execution_statuses: [EXECUTION_STATUS_CANCELLING]
raises_exception: False

- config:
force: False
execution_statuses: [EXECUTION_STATUS_CANCELLING]
raises_exception: True

- config:
force: False
execution_statuses: [EXECUTION_STATUS_AWAITING_MINION_ALLOCATIONS]
raises_exception: False

- config:
force: True
execution_statuses: [EXECUTION_STATUS_RUNNING, EXECUTION_STATUS_CANCELLING, EXECUTION_STATUS_AWAITING_MINION_ALLOCATIONS]
raises_exception: True
19 changes: 19 additions & 0 deletions coriolis/tests/conductor/rpc/data/confirm_task_cancellation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- task_status: TASK_STATUS_CANCELLING_AFTER_COMPLETION
expected_final_status: TASK_STATUS_CANCELED
expected_advance_execution_state_call: True

- task_status: TASK_STATUS_FORCE_CANCELED
expected_final_status: TASK_STATUS_FORCE_CANCELED
expected_advance_execution_state_call: False

- task_status: TASK_STATUS_FAILED_TO_CANCEL
expected_final_status: TASK_STATUS_CANCELED
expected_advance_execution_state_call: True

- task_status: TASK_STATUS_COMPLETED
expected_final_status: TASK_STATUS_COMPLETED
expected_advance_execution_state_call: False

- task_status: EXECUTION_STATUS_RUNNING
expected_final_status: TASK_STATUS_CANCELED
expected_advance_execution_state_call: True
38 changes: 38 additions & 0 deletions coriolis/tests/conductor/rpc/data/update_replica_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
- config:
replica:
instances: ['mock_instance_1', 'mock_instance_2']
info:
mock_instance_1: {}
mock_instance_2: {}
updated_properties:
origin_minion_pool_id: "mock_origin_minion_pool_id"
destination_minion_pool_id: "mock_destination_minion_pool_id"
instance_osmorphing_minion_pool_mappings:
mock_instance_1: "mock_pool"
mock_instance_2: "mock_pool"
user_scripts: "mock_user_scripts"
instances: ['mock_instance_1', 'mock_instance_2']
destination_environment:
network_map: "mock_network_map"
has_updated_values: True
has_replica_instance: True

- config:
replica: {}
updated_properties:
origin_minion_pool_id: "mock_origin_minion_pool_id"
destination_minion_pool_id: "mock_destination_minion_pool_id"
instance_osmorphing_minion_pool_mappings:
mock_instance_1: "mock_pool"
mock_instance_2: "mock_pool"
user_scripts: "mock_user_scripts"
destination_environment:
network_map: "mock_network_map"
has_updated_values: True
has_replica_instance: False

- config:
replica: {}
updated_properties: {}
has_updated_values: False
has_replica_instance: False
Loading

0 comments on commit 9ae48b3

Please sign in to comment.