Ejemplo n.º 1
0
 def test_install_req_libs(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(0, {}, ""))
         ssh.return_value = ssh_mock
         sriov_obj = sriov.Sriov()
         sriov_obj.first_run = True
         sriov_obj.connection = ssh_mock
         self.assertIsNone(sriov_obj.install_req_libs())
Ejemplo n.º 2
0
 def test_check_output(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         cmd = "command"
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(0, {}, ""))
         ssh.return_value = ssh_mock
         sriov_obj = sriov.Sriov()
         sriov_obj.connection = ssh_mock
         self.assertIsNotNone(sriov_obj.check_output(cmd, None))
Ejemplo n.º 3
0
 def test_get_nic_details(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(0, "eth0 eth1", ""))
         ssh.return_value = ssh_mock
         sriov_obj = sriov.Sriov()
         sriov_obj.sriov = SRIOV
         sriov_obj.connection = ssh_mock
         self.assertIsNotNone(sriov_obj.get_nic_details())
Ejemplo n.º 4
0
 def test_destroy_vm_unsuccessful(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(0, {}, ""))
         ssh.return_value = ssh_mock
         sriov_obj = sriov.Sriov()
         sriov_obj.connection = ssh_mock
         sriov_obj.sriov = SRIOV
         sriov_obj.check_output = mock.Mock(return_value=(1, {}))
         self.assertIsNone(sriov_obj.destroy_vm())
Ejemplo n.º 5
0
 def test_ssh_connection(self, mock_prov):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(1, "a", ""))
         ssh.return_value = ssh_mock
         mock_prov.provision_tool = mock.Mock()
         sriov_obj = sriov.Sriov()
         sriov_obj.connection = ssh_mock
         sriov_obj.sriov = SRIOV_PASSWORD
         self.assertIsNone(sriov_obj.ssh_remote_machine())
Ejemplo n.º 6
0
 def test_setup_sriov_context_vm_already_present(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         nic_details = {
             'interface': {
                 0: 'enp6s0f0',
                 1: 'enp6s0f1'
             },
             'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
             'pci': ['0000:06:00.0', '0000:06:00.1'],
             'phy_driver': 'i40e',
             'vf_pci': [{
                 'vf_pci': '06:02.00'
             }, {
                 'vf_pci': '06:06.00'
             }]
         }
         vf = [{'vf_pci': '06:02.00'}, {'vf_pci': '06:06.00'}]
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(0, {}, ""))
         ssh.return_value = ssh_mock
         sriov_obj = sriov.Sriov()
         sriov_obj.connection = ssh_mock
         sriov_obj.sriov = SRIOV
         blacklist = "/etc/modprobe.d/blacklist.conf"
         self.assertEqual(vfnic, "i40evf")
         mock_sriov = mock.Mock()
         mock_sriov.sriov_obj.read_from_file(blacklist)
         sriov_obj.read_from_file = mock.Mock(
             return_value="some random text")
         ssh_mock.execute = \
             mock.Mock(return_value=(0, {}, ""))
         sriov_obj.configure_nics_for_sriov = mock.Mock(
             return_value=nic_details)
         nic_details = sriov_obj.configure_nics_for_sriov.return_value
         self.assertEqual(vf, nic_details['vf_pci'])
         vf = [{
             'vf_pci': '06:02.00',
             'mac': '00:00:00:00:00:0a'
         }, {
             'vf_pci': '06:06.00',
             'mac': '00:00:00:00:00:0b'
         }]
         sriov_obj.add_sriov_interface = mock.Mock()
         ssh_mock.execute = \
             mock.Mock(return_value=(0, {}, ""))
         ssh_mock.put = mock.Mock()
         sriov_obj.check_output = mock.Mock(return_value=(0, "vm1"))
         with mock.patch(
                 "yardstick.benchmark.contexts.standalone.sriov.time"):
             self.assertIsNone(
                 sriov_obj.setup_sriov_context(PCIS, nic_details, DRIVER))
Ejemplo n.º 7
0
 def test_get_vf_datas(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(0, {}, ""))
         ssh.return_value = ssh_mock
         sriov_obj = sriov.Sriov()
         sriov_obj.connection = ssh_mock
         sriov_obj.get_virtual_devices = mock.Mock(
             return_value={'0000:06:00.0': '0000:06:02.0'})
         with mock.patch("re.search") as re:
             re = mock.Mock()
             print("{0}".format(re))
             self.assertIsNotNone(
                 sriov_obj.get_vf_datas('vf_pci',
                                        {'0000:06:00.0': '0000:06:02.0'},
                                        "00:00:00:00:00:0a"))
Ejemplo n.º 8
0
 def test_add_sriov_interface(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(0, {}, ""))
         ssh.return_value = ssh_mock
         sriov_obj = sriov.Sriov()
         sriov_obj.connection = ssh_mock
         with mock.patch("xml.etree.ElementTree.parse") as parse:
             with mock.patch("re.search") as re:
                 with mock.patch("xml.etree.ElementTree.SubElement") \
                     as elem:
                     parse = mock.Mock(return_value="root")
                     re = mock.Mock()
                     elem = mock.Mock()
                     print("{0} {1} {2}".format(parse, re, elem))
                     self.assertIsNone(
                         sriov_obj.add_sriov_interface(
                             0, "0000:06:02.0", "00:00:00:00:00:0a",
                             "/tmp/vm_sriov.xml"))
Ejemplo n.º 9
0
 def test_configure_nics_for_sriov(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         nic_details = {
             'interface': {
                 0: 'enp6s0f0',
                 1: 'enp6s0f1'
             },
             'vf_macs': ['00:00:00:71:7d:25', '00:00:00:71:7d:26'],
             'pci': ['0000:06:00.0', '0000:06:00.1'],
             'phy_driver': 'i40e',
             'vf_pci': [{}, {}]
         }
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock((DRIVER), return_value=(0, "0 driver", ""))
         ssh.return_value = ssh_mock
         ssh_mock.execute = \
             mock.Mock(return_value=(0, {}, ""))
         ssh.return_value = ssh_mock
         for i in range(len(NIC_DETAILS['pci'])):
             ssh_mock.execute = \
                 mock.Mock(return_value=(0, {}, ""))
             ssh_mock.execute = \
                 mock.Mock(return_value=(0, {}, ""))
             sriov_obj = sriov.Sriov()
             sriov_obj.connection = ssh_mock
             ssh_mock.execute = \
                 mock.Mock(return_value=(
                     0,
                     "{'0':'06:02:00','1':'06:06:00'}",
                     ""))
             sriov_obj.get_vf_datas = mock.Mock(
                 return_value={'0000:06:00.0': '0000:06:02.0'})
             nic_details['vf_pci'][i] = sriov_obj.get_vf_datas.return_value
             vf_pci = [[], []]
             vf_pci[i] = sriov_obj.get_vf_datas.return_value
         with mock.patch(
                 "yardstick.benchmark.contexts.standalone.sriov.time"):
             self.assertIsNotNone(
                 sriov_obj.configure_nics_for_sriov(DRIVER, NIC_DETAILS))
Ejemplo n.º 10
0
    def test_get_virtual_devices(self):
        with mock.patch("yardstick.ssh.SSH") as ssh:
            ssh_mock = mock.Mock(autospec=ssh.SSH)
            ssh_mock.execute = \
                mock.Mock(return_value=(0, {}, ""))
            ssh.return_value = ssh_mock
            sriov_obj = sriov.Sriov()
            sriov_obj.connection = ssh_mock
            pci_out = " \
            PCI_CLASS=20000 \
            PCI_ID=8086:154C \
            PCI_SUBSYS_ID=8086:0000 \
            PCI_SLOT_NAME=0000:06:02.0 \
            MODALIAS= \
            pci:v00008086d0000154Csv00008086sd00000000bc02sc00i00"

            pci = "0000:06:00.0"
            sriov_obj.check_output = mock.Mock(return_value=(0, pci_out))
            with mock.patch("re.search") as re:
                re = mock.Mock(return_value="a")
                print("{0}".format(re))
                self.assertIsNotNone(sriov_obj.get_virtual_devices(pci))
Ejemplo n.º 11
0
 def setUp(self):
     self.test_context = sriov.Sriov()
Ejemplo n.º 12
0
 def test_write_to_file(self):
     sriov_obj = sriov.Sriov()
     self.assertIsNone(sriov_obj.write_to_file(SAMPLE_FILE, "some content"))
Ejemplo n.º 13
0
 def test_read_from_file(self):
     CORRECT_FILE_PATH = self._get_file_abspath(self.NODES_SAMPLE_PASSWORD)
     sriov_obj = sriov.Sriov()
     self.assertIsNotNone(sriov_obj.read_from_file(CORRECT_FILE_PATH))
Ejemplo n.º 14
0
 def test_split_cpu_list_null(self):
     with mock.patch("itertools.chain") as iter1:
         iter1 = mock.Mock()
         print("{0}".format(iter1))
         sriov_obj = sriov.Sriov()
         self.assertEqual(sriov_obj.split_cpu_list([]), [])
Ejemplo n.º 15
0
 def test_split_cpu_list_available(self):
     with mock.patch("itertools.chain") as iter1:
         iter1 = mock.Mock()
         print("{0}".format(iter1))
         sriov_obj = sriov.Sriov()
         self.assertIsNotNone(sriov_obj.split_cpu_list('0,5'))