def test_instantiate_error(self, ssh): mock_ssh(ssh, exec_result=(1, "", "")) mock_traffic_profile = mock.Mock(autospec=TrafficProfile) mock_traffic_profile.get_traffic_definition.return_value = "64" mock_traffic_profile.params = self.TRAFFIC_PROFILE trex_traffic_gen = TrexTrafficGenRFC('vnf1', self.VNFD_0) trex_traffic_gen.resource_helper = mock.MagicMock() scenario_cfg = { "tc": "tc_baremetal_rfc2544_ipv4_1flow_64B", "nodes": [ "tg_1", "vnf_1", ], "topology": 'nsb_test_case.yaml', 'options': { 'packetsize': 64, 'traffic_type': 4, 'rfc2544': { 'allowed_drop_rate': '0.8 - 1', }, 'vnf__1': { 'rules': 'acl_1rule.yaml', 'vnf_config': { 'lb_config': 'SW', 'lb_count': 1, 'worker_config': '1C/1T', 'worker_threads': 1, }, }, }, } trex_traffic_gen.instantiate(scenario_cfg, {})
def test_instantiate(self, ssh): mock_ssh(ssh) mock_traffic_profile = mock.Mock(autospec=TrafficProfile) mock_traffic_profile.get_traffic_definition.return_value = "64" mock_traffic_profile.params = self.TRAFFIC_PROFILE trex_traffic_gen = TrexTrafficGenRFC('vnf1', self.VNFD_0) trex_traffic_gen._start_server = mock.Mock(return_value=0) trex_traffic_gen.resource_helper = mock.MagicMock() trex_traffic_gen.setup_helper.setup_vnf_environment = mock.MagicMock() scenario_cfg = { "tc": "tc_baremetal_rfc2544_ipv4_1flow_64B", "topology": 'nsb_test_case.yaml', 'options': { 'packetsize': 64, 'traffic_type': 4, 'rfc2544': { 'allowed_drop_rate': '0.8 - 1', }, 'vnf__1': { 'rules': 'acl_1rule.yaml', 'vnf_config': { 'lb_config': 'SW', 'lb_count': 1, 'worker_config': '1C/1T', 'worker_threads': 1 }, }, }, } tg_rfc2544_trex.WAIT_TIME = 3 scenario_cfg.update({"nodes": ["tg_1", "vnf_1"]}) self.assertIsNone(trex_traffic_gen.instantiate(scenario_cfg, {}))
def test__generate_trex_cfg(self, ssh, _): mock_ssh(ssh) trex_traffic_gen = TrexTrafficGenRFC('vnf1', self.VNFD_0) trex_traffic_gen.ssh_helper = mock.MagicMock() trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock() self.assertIsNone(trex_traffic_gen.resource_helper.generate_cfg())
def test__traffic_runner(self): mock_traffic_profile = mock.Mock(autospec=TrafficProfile) mock_traffic_profile.get_traffic_definition.return_value = "64" mock_traffic_profile.execute.return_value = "64" mock_traffic_profile.get_drop_percentage.return_value = "64" mock_traffic_profile.params = self.TRAFFIC_PROFILE with mock.patch("yardstick.ssh.SSH") as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] self.sut = TrexTrafficGenRFC(vnfd) self.sut.connection = mock.Mock() self.sut.connection.run = mock.Mock() q = Queue() client_started = multiprocessing.Value('i', 1) self.sut._vpci_ascending = ["0000:05:00.0", "0000:05:00.1"] self.sut._connect_client = mock.Mock(autospec=STLClient) self.sut._connect_client.get_stats = mock.Mock(return_value="0") self.sut.tc_file_name = \ self._get_file_abspath( "tc_baremetal_rfc2544_ipv4_1flow_64B.yaml") tg_rfc2544_trex.DURATION = 1 tg_rfc2544_trex.WAIT_TIME = 1 self.sut._traffic_runner(mock_traffic_profile, q, client_started, self.sut._terminated)
def test_scale(self): with mock.patch(SSH_HELPER) as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = mock.Mock(return_value=(0, "", "")) ssh_mock.run = mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock trex_traffic_gen = TrexTrafficGenRFC('vnf1', self.VNFD_0) trex_traffic_gen.scale('')
def test_terminate(self): with mock.patch(SSH_HELPER) as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock trex_traffic_gen = TrexTrafficGenRFC('vnf1', self.VNFD_0) trex_traffic_gen.resource_helper = mock.MagicMock() self.assertIsNone(trex_traffic_gen.terminate())
def test_terminate(self): with mock.patch("yardstick.ssh.SSH") as ssh: vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock trex_traffic_gen = TrexTrafficGenRFC(vnfd) self.assertEqual(None, trex_traffic_gen.terminate())
def test_collect_kpi(self): with mock.patch("yardstick.ssh.SSH") as ssh: vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) restult = trex_traffic_gen.collect_kpi() self.assertEqual({}, restult)
def test__connect_client(self): with mock.patch("yardstick.ssh.SSH") as ssh: vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock trex_traffic_gen = TrexTrafficGenRFC(vnfd) client = mock.Mock(autospec=STLClient) client.connect = mock.Mock(return_value=0) self.assertIsNotNone(trex_traffic_gen._connect_client(client))
def test__generate_trex_cfg(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_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) tg_rfc2544_trex.WAIT_TIME = 1 self.assertEqual(None, trex_traffic_gen._generate_trex_cfg(vnfd))
def test__split_mac_address_into_list(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.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) result = ['0x00', '0x00', '0x00', '0x00', '0x00', '0x01'] self.assertEqual( result, trex_traffic_gen._split_mac_address_into_list( "00:00:00:00:00:01"))
def test__get_rfc_tolerance(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_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) self.assertEqual([0.8, 1.0], trex_traffic_gen._get_rfc_tolerance(self.TC_YAML)) self.TC_YAML["scenarios"][0]["tc_options"]['rfc2544'][ 'allowed_drop_rate'] = '0.8' self.assertEqual([0.8, 0.8], trex_traffic_gen._get_rfc_tolerance(self.TC_YAML))
def test_instantiate(self): mock_traffic_profile = mock.Mock(autospec=TrafficProfile) mock_traffic_profile.get_traffic_definition.return_value = "64" mock_traffic_profile.params = self.TRAFFIC_PROFILE with mock.patch("yardstick.ssh.SSH") as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) trex_traffic_gen._start_server = mock.Mock(return_value=0) scenario_cfg = {"tc": "tc_baremetal_rfc2544_ipv4_1flow_64B"} tg_rfc2544_trex.WAIT_TIME = 3 self.assertEqual(0, trex_traffic_gen.instantiate(scenario_cfg, {}))
def test_run_traffic(self): mock_traffic_profile = mock.Mock(autospec=TrafficProfile) mock_traffic_profile.get_traffic_definition.return_value = "64" mock_traffic_profile.params = self.TRAFFIC_PROFILE with mock.patch("yardstick.ssh.SSH") as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] self.sut = TrexTrafficGenRFC(vnfd) self.sut.connection = mock.Mock() self.sut.connection.run = mock.Mock() self.sut._traffic_runner = mock.Mock(return_value=0) client_started = multiprocessing.Value('i', 1) result = self.sut.run_traffic(mock_traffic_profile, client_started) self.sut._traffic_process.terminate() self.assertIsNotNone(result)
def test_scale(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_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] flavor = "" trex_traffic_gen = TrexTrafficGenRFC(vnfd) self.assertRaises(NotImplementedError, trex_traffic_gen.scale, flavor)
class TestTrexTrafficGenRFC(unittest.TestCase): VNFD = { 'vnfd:vnfd-catalog': { 'vnfd': [{ 'short-name': 'VpeVnf', 'vdu': [{ 'routing_table': [{ 'network': '152.16.100.20', 'netmask': '255.255.255.0', 'gateway': '152.16.100.20', 'if': 'xe0' }, { 'network': '152.16.40.20', 'netmask': '255.255.255.0', 'gateway': '152.16.40.20', 'if': 'xe1' }], 'description': 'VPE approximation using DPDK', 'name': 'vpevnf-baremetal', 'nd_route_tbl': [{ 'network': '0064:ff9b:0:0:0:0:9810:6414', 'netmask': '112', 'gateway': '0064:ff9b:0:0:0:0:9810:6414', 'if': 'xe0' }, { 'network': '0064:ff9b:0:0:0:0:9810:2814', 'netmask': '112', 'gateway': '0064:ff9b:0:0:0:0:9810:2814', 'if': 'xe1' }], 'id': 'vpevnf-baremetal', 'external-interface': [{ 'virtual-interface': { 'dst_mac': '00:00:00:00:00:04', 'vpci': '0000:05:00.0', 'local_ip': '152.16.100.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', 'dpdk_port_num': '0', 'bandwidth': '10 Gbps', 'driver': "i40e", 'dst_ip': '152.16.100.20', 'local_iface_name': 'xe0', 'local_mac': '00:00:00:00:00:01' }, 'vnfd-connection-point-ref': 'xe0', 'name': 'xe0' }, { 'virtual-interface': { 'dst_mac': '00:00:00:00:00:03', 'vpci': '0000:05:00.1', 'local_ip': '152.16.40.19', 'type': 'PCI-PASSTHROUGH', 'driver': "i40e", 'netmask': '255.255.255.0', 'dpdk_port_num': '1', 'bandwidth': '10 Gbps', 'dst_ip': '152.16.40.20', 'local_iface_name': 'xe1', 'local_mac': '00:00:00:00:00:02' }, 'vnfd-connection-point-ref': 'xe1', 'name': 'xe1' }] }], 'description': 'Vpe approximation using DPDK', 'mgmt-interface': { 'vdu-id': 'vpevnf-baremetal', 'host': '1.1.1.1', 'password': '******', 'user': '******', 'ip': '1.1.1.1' }, 'benchmark': { 'kpi': ['packets_in', 'packets_fwd', 'packets_dropped'] }, 'connection-point': [{ 'type': 'VPORT', 'name': 'xe0' }, { 'type': 'VPORT', 'name': 'xe1' }], 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh' }] } } TRAFFIC_PROFILE = { "schema": "isb:traffic_profile:0.1", "name": "fixed", "description": "Fixed traffic profile to run UDP traffic", "traffic_profile": { "traffic_type": "FixedTraffic", "frame_rate": 100, # pps "flow_number": 10, "frame_size": 64 } } TC_YAML = { 'scenarios': [{ 'tc_options': { 'rfc2544': { 'allowed_drop_rate': '0.8 - 1' } }, 'runner': { 'duration': 400, 'interval': 35, 'type': 'Duration' }, 'traffic_options': { 'flow': 'ipv4_1flow_Packets_vpe.yaml', 'imix': 'imix_voice.yaml' }, 'vnf_options': { 'vpe': { 'cfg': 'vpe_config' } }, 'traffic_profile': 'ipv4_throughput_vpe.yaml', 'type': 'NSPerf', 'nodes': { 'tg__1': 'trafficgen_1.yardstick', 'vnf__1': 'vnf.yardstick' }, 'topology': 'vpe_vnf_topology.yaml' }], 'context': { 'nfvi_type': 'baremetal', 'type': 'Node', 'name': 'yardstick', 'file': '/etc/yardstick/nodes/pod.yaml' }, 'schema': 'yardstick:task:0.1' } def test___init__(self): with mock.patch("yardstick.ssh.SSH") as ssh: vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) self.assertIsNotNone(trex_traffic_gen._terminated) def test_collect_kpi(self): with mock.patch("yardstick.ssh.SSH") as ssh: vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) restult = trex_traffic_gen.collect_kpi() self.assertEqual({}, restult) def test_listen_traffic(self): with mock.patch("yardstick.ssh.SSH") as ssh: vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) self.assertEqual(None, trex_traffic_gen.listen_traffic({})) def test_instantiate(self): mock_traffic_profile = mock.Mock(autospec=TrafficProfile) mock_traffic_profile.get_traffic_definition.return_value = "64" mock_traffic_profile.params = self.TRAFFIC_PROFILE with mock.patch("yardstick.ssh.SSH") as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) trex_traffic_gen._start_server = mock.Mock(return_value=0) scenario_cfg = {"tc": "tc_baremetal_rfc2544_ipv4_1flow_64B"} tg_rfc2544_trex.WAIT_TIME = 3 self.assertEqual(0, trex_traffic_gen.instantiate(scenario_cfg, {})) def test_instantiate_error(self): mock_traffic_profile = mock.Mock(autospec=TrafficProfile) mock_traffic_profile.get_traffic_definition.return_value = "64" mock_traffic_profile.params = self.TRAFFIC_PROFILE with mock.patch("yardstick.ssh.SSH") as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(1, "", "")) ssh_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) scenario_cfg = {"tc": "tc_baremetal_rfc2544_ipv4_1flow_64B"} self.assertRaises(RuntimeError, trex_traffic_gen.instantiate, scenario_cfg, {}) def test__get_rfc_tolerance(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_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) self.assertEqual([0.8, 1.0], trex_traffic_gen._get_rfc_tolerance(self.TC_YAML)) self.TC_YAML["scenarios"][0]["tc_options"]['rfc2544'][ 'allowed_drop_rate'] = '0.8' self.assertEqual([0.8, 0.8], trex_traffic_gen._get_rfc_tolerance(self.TC_YAML)) def test__start_server(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_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) self.assertEqual(None, trex_traffic_gen._start_server()) def _get_file_abspath(self, filename): curr_path = os.path.dirname(os.path.abspath(__file__)) file_path = os.path.join(curr_path, filename) return file_path def test__traffic_runner(self): mock_traffic_profile = mock.Mock(autospec=TrafficProfile) mock_traffic_profile.get_traffic_definition.return_value = "64" mock_traffic_profile.execute.return_value = "64" mock_traffic_profile.get_drop_percentage.return_value = "64" mock_traffic_profile.params = self.TRAFFIC_PROFILE with mock.patch("yardstick.ssh.SSH") as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] self.sut = TrexTrafficGenRFC(vnfd) self.sut.connection = mock.Mock() self.sut.connection.run = mock.Mock() q = Queue() client_started = multiprocessing.Value('i', 1) self.sut._vpci_ascending = ["0000:05:00.0", "0000:05:00.1"] self.sut._connect_client = mock.Mock(autospec=STLClient) self.sut._connect_client.get_stats = mock.Mock(return_value="0") self.sut.tc_file_name = \ self._get_file_abspath( "tc_baremetal_rfc2544_ipv4_1flow_64B.yaml") tg_rfc2544_trex.DURATION = 1 tg_rfc2544_trex.WAIT_TIME = 1 self.sut._traffic_runner(mock_traffic_profile, q, client_started, self.sut._terminated) def test__split_mac_address_into_list(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.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) result = ['0x00', '0x00', '0x00', '0x00', '0x00', '0x01'] self.assertEqual( result, trex_traffic_gen._split_mac_address_into_list( "00:00:00:00:00:01")) def test__generate_trex_cfg(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_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGenRFC(vnfd) tg_rfc2544_trex.WAIT_TIME = 1 self.assertEqual(None, trex_traffic_gen._generate_trex_cfg(vnfd)) def test_run_traffic(self): mock_traffic_profile = mock.Mock(autospec=TrafficProfile) mock_traffic_profile.get_traffic_definition.return_value = "64" mock_traffic_profile.params = self.TRAFFIC_PROFILE with mock.patch("yardstick.ssh.SSH") as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] self.sut = TrexTrafficGenRFC(vnfd) self.sut.connection = mock.Mock() self.sut.connection.run = mock.Mock() self.sut._traffic_runner = mock.Mock(return_value=0) client_started = multiprocessing.Value('i', 1) result = self.sut.run_traffic(mock_traffic_profile, client_started) self.sut._traffic_process.terminate() self.assertIsNotNone(result) def test_scale(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_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] flavor = "" trex_traffic_gen = TrexTrafficGenRFC(vnfd) self.assertRaises(NotImplementedError, trex_traffic_gen.scale, flavor) def test_terminate(self): with mock.patch("yardstick.ssh.SSH") as ssh: vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock trex_traffic_gen = TrexTrafficGenRFC(vnfd) self.assertEqual(None, trex_traffic_gen.terminate()) def test__connect_client(self): with mock.patch("yardstick.ssh.SSH") as ssh: vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock trex_traffic_gen = TrexTrafficGenRFC(vnfd) client = mock.Mock(autospec=STLClient) client.connect = mock.Mock(return_value=0) self.assertIsNotNone(trex_traffic_gen._connect_client(client))
def test__start_server(self, ssh): mock_ssh(ssh) trex_traffic_gen = TrexTrafficGenRFC('vnf1', self.VNFD_0) trex_traffic_gen.resource_helper = mock.MagicMock() self.assertIsNone(trex_traffic_gen._start_server())
def test_listen_traffic(self, ssh): mock_ssh(ssh) trex_traffic_gen = TrexTrafficGenRFC('vnf1', self.VNFD_0) self.assertIsNone(trex_traffic_gen.listen_traffic({}))
def test_collect_kpi(self, ssh): mock_ssh(ssh) trex_traffic_gen = TrexTrafficGenRFC('vnf1', self.VNFD_0) self.assertIsNone(trex_traffic_gen.collect_kpi())
def test___init__(self, ssh): mock_ssh(ssh) trex_traffic_gen = TrexTrafficGenRFC('vnf1', self.VNFD_0) self.assertIsNotNone( trex_traffic_gen.resource_helper._terminated.value)