From c2f99db8b4d8f021b29a4e3aae483ba715936a66 Mon Sep 17 00:00:00 2001 From: Ross Brattain Date: Mon, 13 Mar 2017 22:08:06 -0700 Subject: Add Ansible executor class for node context import the AnsibleCommon class to execute Ansible playbooks Update node context support to use AnsibleCommon needs unittests We must call ansible-playbook as an executable, so we must create temp files for inventory, and for the playbooks. AnsibleCommon has evolved to be quite flexible, it auto-generates the inventory from the context['nodes'] and generates groups from the node Role. We also support either a single playbook filename, or a list of filenames. If given a list we dynamically generate a playbook that includes the other playbooks. We support adding any number of extra_vars using a temp JSON file. Also designed to be extended by subclassing. Change-Id: I5bd0a2b4547feaadd70b7e2b8801f19371b99df0 Signed-off-by: Ross Brattain --- tests/unit/benchmark/contexts/test_node.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tests/unit/benchmark/contexts/test_node.py') diff --git a/tests/unit/benchmark/contexts/test_node.py b/tests/unit/benchmark/contexts/test_node.py index 9b5761c8d..a2e2f7b9a 100644 --- a/tests/unit/benchmark/contexts/test_node.py +++ b/tests/unit/benchmark/contexts/test_node.py @@ -131,10 +131,8 @@ class NodeContextTestCase(unittest.TestCase): self.test_context.env = {} self.assertEqual(self.test_context._dispatch_ansible('ansible'), None) - @mock.patch("{}.subprocess".format(PREFIX)) - def test__do_ansible_job(self, mock_subprocess): - mock_subprocess.Popen = mock.MagicMock() - mock_subprocess.communicate = mock.Mock() + @mock.patch("{}.AnsibleCommon".format(PREFIX)) + def test__do_ansible_job(self, mock_ansible): self.assertEqual(None, self.test_context._do_ansible_job('dummy')) def test_successful_init(self): -- cgit 1.2.3-korg