Further cleanup unit tests
We changed all client workflows other than derived params to not use mistral and zaqar. However, the unit tests still mock lot of these. Let's remove those. Change-Id: Ieddd97e73b1bd0f88b1fed17ac2575b3e2964e5f
This commit is contained in:
parent
adf29a1e70
commit
6f67c20a89
|
@ -20,7 +20,6 @@ from osc_lib.tests import utils
|
|||
|
||||
from tripleoclient import plugin
|
||||
|
||||
|
||||
AUTH_TOKEN = "foobar"
|
||||
AUTH_URL = "http://0.0.0.0"
|
||||
WS_URL = "ws://0.0.0.0"
|
||||
|
@ -172,19 +171,12 @@ class FakePlaybookExecution(utils.TestCommand):
|
|||
self.app.client_manager.identity = mock.Mock()
|
||||
self.app.client_manager.image = mock.Mock()
|
||||
self.app.client_manager.network = mock.Mock()
|
||||
tc = self.app.client_manager.tripleoclient = FakeClientWrapper()
|
||||
self.tripleoclient = mock.Mock()
|
||||
self.workflow = self.app.client_manager.workflow_engine = mock.Mock()
|
||||
stack = self.app.client_manager.orchestration = mock.Mock()
|
||||
stack.stacks.get.return_value = FakeStackObject
|
||||
tc = self.app.client_manager.tripleoclient = FakeClientWrapper()
|
||||
tc.create_mistral_context = plugin.ClientWrapper(
|
||||
instance=FakeInstanceData
|
||||
).create_mistral_context
|
||||
|
||||
# NOTE(cloudnull): When mistral is gone this should be removed.
|
||||
self.execution = mock.Mock()
|
||||
self.execution.id = "IDID"
|
||||
self.workflow.executions.create.return_value = self.execution
|
||||
instance=FakeInstanceData).create_mistral_context
|
||||
|
||||
get_key = mock.patch('tripleoclient.utils.get_key')
|
||||
get_key.start()
|
||||
|
|
|
@ -430,11 +430,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
orchestration_client = clients.orchestration
|
||||
mock_stack = fakes.create_tht_stack()
|
||||
orchestration_client.stacks.get.side_effect = [None, mock.Mock()]
|
||||
workflow_client = clients.workflow_engine
|
||||
workflow_client.environments.get.return_value = mock.MagicMock(
|
||||
variables={'environments': []})
|
||||
workflow_client.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
|
||||
def _orch_clt_create(**kwargs):
|
||||
orchestration_client.stacks.get.return_value = mock_stack
|
||||
|
|
|
@ -42,18 +42,13 @@ class TestDeleteNode(fakes.TestDeleteNode):
|
|||
# Get the command object to test
|
||||
self.cmd = overcloud_node.DeleteNode(self.app, None)
|
||||
self.cmd.app_args = mock.Mock(verbose_level=1)
|
||||
self.app.client_manager.workflow_engine = mock.Mock()
|
||||
self.tripleoclient = mock.Mock()
|
||||
|
||||
self.workflow = self.app.client_manager.workflow_engine
|
||||
self.stack_name = self.app.client_manager.orchestration.stacks.get
|
||||
stack = self.stack_name.return_value = mock.Mock(
|
||||
stack_name="overcloud"
|
||||
)
|
||||
stack.output_show.return_value = {'output': {'output_value': []}}
|
||||
execution = mock.Mock()
|
||||
execution.id = "IDID"
|
||||
self.workflow.executions.create.return_value = execution
|
||||
|
||||
delete_node = mock.patch(
|
||||
'tripleo_common.actions.scale.ScaleDownAction.run',
|
||||
|
@ -392,13 +387,6 @@ class TestCleanNode(fakes.TestOvercloudNode):
|
|||
def setUp(self):
|
||||
super(TestCleanNode, self).setUp()
|
||||
|
||||
self.workflow = self.app.client_manager.workflow_engine
|
||||
execution = mock.Mock()
|
||||
execution.id = "IDID"
|
||||
self.workflow.executions.create.return_value = execution
|
||||
client = self.app.client_manager.tripleoclient
|
||||
self.websocket = client.messaging_websocket()
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = overcloud_node.CleanNode(self.app, None)
|
||||
|
||||
|
@ -478,13 +466,6 @@ class TestImportNodeMultiArch(fakes.TestOvercloudNode):
|
|||
self.json_file.close()
|
||||
self.addCleanup(os.unlink, self.json_file.name)
|
||||
|
||||
self.workflow = self.app.client_manager.workflow_engine
|
||||
execution = mock.Mock()
|
||||
execution.id = "IDID"
|
||||
self.workflow.executions.create.return_value = execution
|
||||
client = self.app.client_manager.tripleoclient
|
||||
self.websocket = client.messaging_websocket()
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = overcloud_node_v2.ImportNode(self.app, None)
|
||||
|
||||
|
@ -513,15 +494,6 @@ class TestImportNodeMultiArch(fakes.TestOvercloudNode):
|
|||
|
||||
def _check_workflow_call(self, parsed_args, introspect=False,
|
||||
provide=False, local=None, no_deploy_image=False):
|
||||
self.websocket.wait_for_messages.return_value = [{
|
||||
"status": "SUCCESS",
|
||||
"message": "Success",
|
||||
"registered_nodes": [{
|
||||
"uuid": "MOCK_NODE_UUID"
|
||||
}],
|
||||
"execution_id": "IDID"
|
||||
}]
|
||||
|
||||
file_return_nodes = [
|
||||
{
|
||||
'uuid': 'MOCK_NODE_UUID'
|
||||
|
@ -589,18 +561,6 @@ class TestConfigureNode(fakes.TestOvercloudNode):
|
|||
def setUp(self):
|
||||
super(TestConfigureNode, self).setUp()
|
||||
|
||||
self.workflow = self.app.client_manager.workflow_engine
|
||||
execution = mock.Mock()
|
||||
execution.id = "IDID"
|
||||
self.workflow.executions.create.return_value = execution
|
||||
client = self.app.client_manager.tripleoclient
|
||||
self.websocket = client.messaging_websocket()
|
||||
self.websocket.wait_for_messages.return_value = iter([{
|
||||
"status": "SUCCESS",
|
||||
"message": "",
|
||||
"execution_id": "IDID"
|
||||
}])
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = overcloud_node.ConfigureNode(self.app, None)
|
||||
|
||||
|
@ -694,15 +654,10 @@ class TestDiscoverNode(fakes.TestOvercloudNode):
|
|||
def setUp(self):
|
||||
super(TestDiscoverNode, self).setUp()
|
||||
|
||||
self.workflow = self.app.client_manager.workflow_engine
|
||||
execution = mock.Mock()
|
||||
execution.id = "IDID"
|
||||
self.workflow.executions.create.return_value = execution
|
||||
client = self.app.client_manager.tripleoclient
|
||||
client.create_mistral_context = plugin.ClientWrapper(
|
||||
instance=ooofakes.FakeInstanceData
|
||||
).create_mistral_context
|
||||
self.websocket = client.messaging_websocket()
|
||||
|
||||
self.cmd = overcloud_node.DiscoverNode(self.app, None)
|
||||
|
||||
|
@ -713,15 +668,6 @@ class TestDiscoverNode(fakes.TestOvercloudNode):
|
|||
self.gcn.start()
|
||||
self.addCleanup(self.gcn.stop)
|
||||
|
||||
self.websocket.wait_for_messages.return_value = [{
|
||||
"status": "SUCCESS",
|
||||
"message": "Success",
|
||||
"registered_nodes": [{
|
||||
"uuid": "MOCK_NODE_UUID"
|
||||
}],
|
||||
"execution_id": "IDID"
|
||||
}]
|
||||
|
||||
self.http_boot = '/var/lib/ironic/httpboot'
|
||||
|
||||
def test_with_ip_range(self):
|
||||
|
|
|
@ -31,7 +31,6 @@ class TestImportNode(fakes.TestOvercloudNode):
|
|||
|
||||
def setUp(self):
|
||||
super(TestImportNode, self).setUp()
|
||||
|
||||
self.nodes_list = [{
|
||||
"pm_user": "stack",
|
||||
"pm_addr": "192.168.122.1",
|
||||
|
@ -50,23 +49,6 @@ class TestImportNode(fakes.TestOvercloudNode):
|
|||
]
|
||||
}]
|
||||
|
||||
# NOTE(cloudnull): Workflow and client calls are still mocked because
|
||||
# mistal is still presnet here.
|
||||
self.workflow = self.app.client_manager.workflow_engine
|
||||
execution = mock.Mock()
|
||||
execution.id = "IDID"
|
||||
self.workflow.executions.create.return_value = execution
|
||||
client = self.app.client_manager.tripleoclient
|
||||
self.websocket = client.messaging_websocket()
|
||||
self.websocket.wait_for_messages.return_value = [{
|
||||
"status": "SUCCESS",
|
||||
"message": "Success",
|
||||
"registered_nodes": [{
|
||||
"uuid": "MOCK_NODE_UUID"
|
||||
}],
|
||||
"execution_id": execution.id
|
||||
}]
|
||||
|
||||
self.json_file = tempfile.NamedTemporaryFile(
|
||||
mode='w', delete=False, suffix='.json')
|
||||
json.dump(self.nodes_list, self.json_file)
|
||||
|
@ -176,21 +158,6 @@ class TestIntrospectNode(fakes.TestOvercloudNode):
|
|||
|
||||
def setUp(self):
|
||||
super(TestIntrospectNode, self).setUp()
|
||||
|
||||
# Get the command object to test
|
||||
self.workflow = self.app.client_manager.workflow_engine
|
||||
execution = mock.Mock()
|
||||
execution.id = "IDID"
|
||||
self.workflow.executions.create.return_value = execution
|
||||
client = self.app.client_manager.tripleoclient
|
||||
self.websocket = client.messaging_websocket()
|
||||
self.websocket.wait_for_messages.return_value = iter([{
|
||||
"status": "SUCCESS",
|
||||
"message": "Success",
|
||||
"introspected_nodes": {},
|
||||
"execution_id": execution.id
|
||||
}] * 2)
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = overcloud_node.IntrospectNode(self.app, None)
|
||||
|
||||
|
|
|
@ -25,26 +25,7 @@ class TestBaremetalWorkflows(fakes.FakePlaybookExecution):
|
|||
|
||||
self.app.client_manager.workflow_engine = self.workflow = mock.Mock()
|
||||
self.tripleoclient = mock.Mock()
|
||||
self.websocket = mock.Mock()
|
||||
self.websocket.__enter__ = lambda s: self.websocket
|
||||
self.websocket.__exit__ = lambda s, *exc: None
|
||||
self.tripleoclient.messaging_websocket.return_value = self.websocket
|
||||
self.app.client_manager.tripleoclient = self.tripleoclient
|
||||
execution = mock.Mock()
|
||||
execution.id = "IDID"
|
||||
self.workflow.executions.create.return_value = execution
|
||||
|
||||
self.message_success = iter([{
|
||||
"execution_id": "IDID",
|
||||
"status": "SUCCESS",
|
||||
"message": "Success.",
|
||||
"registered_nodes": [],
|
||||
}])
|
||||
self.message_failed = iter([{
|
||||
"execution_id": "IDID",
|
||||
"status": "FAIL",
|
||||
"message": "Fail.",
|
||||
}])
|
||||
|
||||
self.mock_playbook = mock.patch(
|
||||
'tripleoclient.utils.run_ansible_playbook',
|
||||
|
|
|
@ -16,8 +16,6 @@ import mock
|
|||
|
||||
from osc_lib.tests import utils
|
||||
|
||||
from tripleoclient import plugin
|
||||
from tripleoclient.tests.fakes import FakeInstanceData
|
||||
from tripleoclient.tests.fakes import FakeStackObject
|
||||
from tripleoclient.workflows import deployment
|
||||
|
||||
|
@ -26,28 +24,7 @@ class TestDeploymentWorkflows(utils.TestCommand):
|
|||
|
||||
def setUp(self):
|
||||
super(TestDeploymentWorkflows, self).setUp()
|
||||
|
||||
self.app.client_manager.workflow_engine = self.workflow = mock.Mock()
|
||||
self.tripleoclient = mock.Mock()
|
||||
self.websocket = mock.Mock()
|
||||
self.websocket.__enter__ = lambda s: self.websocket
|
||||
self.websocket.__exit__ = lambda s, *exc: None
|
||||
self.tripleoclient.messaging_websocket.return_value = self.websocket
|
||||
tc = self.app.client_manager.tripleoclient = self.tripleoclient
|
||||
tc.create_mistral_context = plugin.ClientWrapper(
|
||||
instance=FakeInstanceData
|
||||
).create_mistral_context
|
||||
self.message_success = iter([{
|
||||
"execution": {"id": "IDID"},
|
||||
"status": "SUCCESS",
|
||||
"message": "Success.",
|
||||
"registered_nodes": [],
|
||||
}])
|
||||
self.message_failed = iter([{
|
||||
"execution": {"id": "IDID"},
|
||||
"status": "FAIL",
|
||||
"message": "Fail.",
|
||||
}])
|
||||
|
||||
@mock.patch('shutil.rmtree')
|
||||
@mock.patch('os.chdir')
|
||||
|
|
Loading…
Reference in New Issue