Example #1
0
 def test_execute_script_remote(self, remote_execute_mock):
     node_name = 'node5'
     info = {}
     obj = node.NodeContext()
     self.addCleanup(obj._delete_context)
     obj._execute_script(node_name, info)
     remote_execute_mock.assert_called_once()
Example #2
0
 def test_node_info(self):
     node_name_args = 'node5'
     obj = node.NodeContext()
     self.addCleanup(obj._delete_context)
     obj.nodes = [{'name': node_name_args, 'check': node_name_args}]
     node_info = obj._get_node_info(node_name_args)
     self.assertEqual(node_info.get('check'), node_name_args)
Example #3
0
 def test_execute_script_local(self, local_execute_mock):
     node_name = 'local'
     info = {}
     obj = node.NodeContext()
     self.addCleanup(obj._delete_context)
     obj._execute_script(node_name, info)
     local_execute_mock.assert_called_once()
Example #4
0
 def test_undeploy_anisble(self, dispatch_ansible_mock):
     obj = node.NodeContext()
     obj.env = {
         'type': 'ansible'
     }
     obj.undeploy()
     dispatch_ansible_mock.assert_called_once()
Example #5
0
 def test_undeploy(self, dispatch_script_mock):
     obj = node.NodeContext()
     obj.env = {
         'type': 'script'
     }
     obj.undeploy()
     dispatch_script_mock.assert_called_once()
Example #6
0
 def test_deploy_anisible(self, dispatch_ansible_mock):
     obj = node.NodeContext()
     self.addCleanup(obj._delete_context)
     obj.env = {
         'type': 'ansible'
     }
     obj.deploy()
     dispatch_ansible_mock.assert_called_once()
Example #7
0
 def test_get_script(self):
     script_args = 'hello.bash'
     info_args = {'script': script_args}
     obj = node.NodeContext()
     self.addCleanup(obj._delete_context)
     script, options = obj._get_script(info_args)
     self.assertEqual(script_args, script)
     self.assertEqual('', options)
Example #8
0
 def test_deploy(self, dispatch_script_mock):
     obj = node.NodeContext()
     self.addCleanup(obj._delete_context)
     obj.env = {
         'type': 'script'
     }
     obj.deploy()
     dispatch_script_mock.assert_called_once()
Example #9
0
 def setUp(self):
     self.test_context = node.NodeContext()
     self.addCleanup(self._remove_contexts)
     self.os_path_join = os.path.join
     self.attrs = {
         'name': 'foo',
         'task_id': '1234567890',
         'file': self._get_file_abspath(self.NODES_SAMPLE)
     }
Example #10
0
 def test_get_client(self, wait_mock):
     node_name_args = 'node5'
     obj = node.NodeContext()
     obj.nodes = [{
         'name': node_name_args,
         'user': '******',
         'ip': '10.10.10.10',
         'pwd': 'ubuntu',
     }]
     obj._get_client(node_name_args)
     self.assertTrue(wait_mock.called)
Example #11
0
 def test_get_client(self, wait_mock):
     node_name_args = 'node5'
     obj = node.NodeContext()
     self.addCleanup(obj._delete_context)
     obj.nodes = [{
         'name': node_name_args,
         'user': '******',
         'ip': '10.10.10.10',
         'pwd': 'ubuntu',
     }]
     obj._get_client(node_name_args)
     wait_mock.assert_called_once()
Example #12
0
    def test_execute_remote_script(self, execute_mock, put_file_mock):
        obj = node.NodeContext()
        obj.env = {'prefix': 'yardstick.benchmark.scenarios.compute'}
        node_name_args = 'node5'
        obj.nodes = [{
            'name': node_name_args,
            'user': '******',
            'ip': '10.10.10.10',
            'pwd': 'ubuntu',
        }]

        info = {'script': 'computecapacity.bash'}
        execute_mock.return_value = (0, '', '')
        obj._execute_remote_script('node5', info)

        self.assertTrue(put_file_mock.called)
        self.assertTrue(execute_mock.called)
Example #13
0
    def test__add_resources_to_template_raw(self):
        test_context = node.NodeContext()
        self.addCleanup(test_context._delete_context)
        test_context._name = 'foo'
        test_context.template_file = '/tmp/some-heat-file'
        test_context.heat_parameters = {'image': 'cirros'}
        test_context.key_filename = "/tmp/1234"
        test_context.keypair_name = "foo-key"
        test_context.secgroup_name = "foo-secgroup"
        test_context.key_uuid = "2f2e4997-0a8e-4eb7-9fa4-f3f8fbbc393b"

        test_context.tmpfile = tempfile.NamedTemporaryFile(delete=True,
                                                           mode='w+t')
        test_context.tmpfile.write("heat_template_version: 2015-04-30")
        test_context.tmpfile.flush()
        test_context.tmpfile.seek(0)
        heat_template = heat.HeatTemplate('template name')
        heat_template.resources = {}

        heat_template.add_network("network1")
        heat_template.add_network("network2")
        heat_template.add_security_group("sec_group1")
        heat_template.add_security_group("sec_group2")
        heat_template.add_subnet("subnet1", "network1", "cidr1")
        heat_template.add_subnet("subnet2", "network2", "cidr2")
        heat_template.add_router("router1", "gw1", "subnet1")
        heat_template.add_router_interface("router_if1", "router1", "subnet1")
        network1 = mock.MagicMock()
        network1.stack_name = "network1"
        network1.subnet_stack_name = "subnet1"
        network1.vnic_type = "normal"
        network2 = mock.MagicMock()
        network2.stack_name = "network2"
        network2.subnet_stack_name = "subnet2"
        network2.vnic_type = "normal"
        heat_template.add_port("port1", network1)
        heat_template.add_port("port2",
                               network2,
                               sec_group_id="sec_group1",
                               provider="not-sriov")
        heat_template.add_port("port3",
                               network2,
                               sec_group_id="sec_group1",
                               provider="sriov")
        heat_template.add_floating_ip("floating_ip1", "network1", "port1",
                                      "router_if1")
        heat_template.add_floating_ip("floating_ip2", "network2", "port2",
                                      "router_if2", "foo-secgroup")
        heat_template.add_floating_ip_association("floating_ip1_association",
                                                  "floating_ip1", "port1")
        heat_template.add_servergroup("server_grp2", "affinity")
        heat_template.add_servergroup("server_grp3", "anti-affinity")
        heat_template.add_security_group("security_group")
        heat_template.add_server(name="server1",
                                 image="image1",
                                 flavor="flavor1",
                                 flavors=[])
        heat_template.add_server_group(name="servergroup",
                                       policies=["policy1", "policy2"])
        heat_template.add_server_group(name="servergroup", policies="policy1")
        heat_template.add_server(name="server2",
                                 image="image1",
                                 flavor="flavor1",
                                 flavors=[],
                                 ports=["port1", "port2"],
                                 networks=["network1", "network2"],
                                 scheduler_hints="hints1",
                                 user="******",
                                 key_name="foo-key",
                                 user_data="user",
                                 metadata={
                                     "cat": 1,
                                     "doc": 2
                                 },
                                 additional_properties={
                                     "prop1": 1,
                                     "prop2": 2
                                 })
        heat_template.add_server(name="server2",
                                 image="image1",
                                 flavor="flavor1",
                                 flavors=["flavor1", "flavor2"],
                                 ports=["port1", "port2"],
                                 networks=["network1", "network2"],
                                 scheduler_hints="hints1",
                                 user="******",
                                 key_name="foo-key",
                                 user_data="user",
                                 metadata={
                                     "cat": 1,
                                     "doc": 2
                                 },
                                 additional_properties={
                                     "prop1": 1,
                                     "prop2": 2
                                 })
        heat_template.add_server(name="server2",
                                 image="image1",
                                 flavor="flavor1",
                                 flavors=["flavor3", "flavor4"],
                                 ports=["port1", "port2"],
                                 networks=["network1", "network2"],
                                 scheduler_hints="hints1",
                                 user="******",
                                 key_name="foo-key",
                                 user_data="user",
                                 metadata={
                                     "cat": 1,
                                     "doc": 2
                                 },
                                 additional_properties={
                                     "prop1": 1,
                                     "prop2": 2
                                 })
        heat_template.add_flavor(name="flavor1",
                                 vcpus=1,
                                 ram=2048,
                                 disk=1,
                                 extra_specs={
                                     "cat": 1,
                                     "dog": 2
                                 })
        heat_template.add_flavor(name=None, vcpus=1, ram=2048)
        heat_template.add_server(name="server1",
                                 image="image1",
                                 flavor="flavor1",
                                 flavors=[],
                                 ports=["port1", "port2"],
                                 networks=["network1", "network2"],
                                 scheduler_hints="hints1",
                                 user="******",
                                 key_name="foo-key",
                                 user_data="user",
                                 metadata={
                                     "cat": 1,
                                     "doc": 2
                                 },
                                 additional_properties={
                                     "prop1": 1,
                                     "prop2": 2
                                 })
        heat_template.add_network("network1")

        heat_template.add_flavor("test")
        self.assertEqual(heat_template.resources['test']['type'],
                         'OS::Nova::Flavor')
Example #14
0
 def setUp(self):
     self.test_context = node.NodeContext()
Example #15
0
 def test_get_script(self):
     script_args = 'hello.bash'
     info_args = {'script': script_args}
     script, options = node.NodeContext()._get_script(info_args)
     self.assertEqual(script_args, script)
     self.assertEqual('', options)
Example #16
0
 def test_execute_script_remote(self, remote_execute_mock):
     node_name = 'node5'
     info = {}
     node.NodeContext()._execute_script(node_name, info)
     self.assertTrue(remote_execute_mock.called)
Example #17
0
 def test_execute_script_local(self, local_execute_mock):
     node_name = 'local'
     info = {}
     node.NodeContext()._execute_script(node_name, info)
     self.assertTrue(local_execute_mock.called)
Example #18
0
 def test_undeploy(self, dispatch_script_mock):
     obj = node.NodeContext()
     obj.env = {'type': 'script'}
     obj.undeploy()
     self.assertTrue(dispatch_script_mock.called)
Example #19
0
 def test_undeploy_anisble(self, dispatch_ansible_mock):
     obj = node.NodeContext()
     obj.env = {'type': 'ansible'}
     obj.undeploy()
     self.assertTrue(dispatch_ansible_mock.called)
Example #20
0
 def setUp(self):
     self.test_context = node.NodeContext()
     self.os_path_join = os.path.join