Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minion_manager.rpc.client.py/tasks.py unit tests #321

Merged

Conversation

mihaelabalutoiu
Copy link
Contributor

@mihaelabalutoiu mihaelabalutoiu commented Jun 10, 2024

This PR adds test cases for the following module:

  • minion_manager.rpc.tasks.py
  • minion_manager.rpc.client.py

Copy link
Contributor

@Dany9966 Dany9966 left a comment

Choose a reason for hiding this comment

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

First review pass done! Please look out for messages (log, event, progress updates, whatever) we do not want to include in tests, and remove all of them please.

coriolis/minion_manager/rpc/tasks.py Outdated Show resolved Hide resolved
coriolis/tests/minion_manager/rpc/test_client.py Outdated Show resolved Hide resolved
coriolis/tests/minion_manager/rpc/test_client.py Outdated Show resolved Hide resolved
coriolis/tests/minion_manager/rpc/test_tasks.py Outdated Show resolved Hide resolved
coriolis/tests/minion_manager/rpc/test_tasks.py Outdated Show resolved Hide resolved
coriolis/tests/minion_manager/rpc/test_tasks.py Outdated Show resolved Hide resolved
coriolis/tests/minion_manager/rpc/test_tasks.py Outdated Show resolved Hide resolved
coriolis/tests/minion_manager/rpc/test_tasks.py Outdated Show resolved Hide resolved
exception message for proper formatting.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
module

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
Copy link
Contributor Author

@mihaelabalutoiu mihaelabalutoiu left a comment

Choose a reason for hiding this comment

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

I updated the code, please take a look now. Thank you!

coriolis/tests/minion_manager/rpc/test_client.py Outdated Show resolved Hide resolved
coriolis/tests/minion_manager/rpc/test_tasks.py Outdated Show resolved Hide resolved
coriolis/tests/minion_manager/rpc/test_tasks.py Outdated Show resolved Hide resolved
@Dany9966
Copy link
Contributor

Dany9966 commented Sep 6, 2024

Mostly lgtm, you only have a little missed case in HealthcheckMinionMachineTask.execute. Please handle that too.

module

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
Comment on lines +1678 to +1679
mock_get_minion_machine.return_value = self.minion_machine
mock_execute.side_effect = CoriolisTestException
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get what you're testing here. You mock the tested method, make it raise and then check that the raise has occurred?
For this case, you need to:

  1. set mock_get_minion_machine.return_value = None;
  2. remove the mock_execute entirely;
  3. keep _fail_on_error on True;
  4. Check that the call raises InvalidMinionMachineState.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind this, this case was already covered. This case is also good. Thank you!

Copy link
Contributor

@Dany9966 Dany9966 left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

@Dany9966 Dany9966 merged commit 16e71ab into cloudbase:master Sep 11, 2024
4 checks passed
@mihaelabalutoiu mihaelabalutoiu deleted the add-minion-manager-unit-tests branch September 11, 2024 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants