aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests
diff options
context:
space:
mode:
authorOleksandr Naumets <oleksandrx.naumets@intel.com>2018-11-13 12:42:08 +0000
committerOleksandr Naumets <oleksandrx.naumets@intel.com>2018-12-11 17:32:16 +0000
commit63d966f9208664eaa8147c8f719d414418425a63 (patch)
tree6e8cc600c613503cadecfe2577dd14c862a2ff61 /yardstick/tests
parentedb66ef37f9d89a783f3eda15d82d6fcebd7598e (diff)
Extend vBNG PPPoE test cases functionality
Extended Ixia traffic generator with functionality to create traffic flows between device groups. JIRA: YARDSTICK-1521 Change-Id: Iaaa822f2f3da876629576d4101be29c9a65296d0 Signed-off-by: Oleksandr Naumets <oleksandrx.naumets@intel.com>
Diffstat (limited to 'yardstick/tests')
-rw-r--r--yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py40
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py112
2 files changed, 143 insertions, 9 deletions
diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py b/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
index 5b39b6cd1..ef16676c7 100644
--- a/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
+++ b/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
@@ -16,6 +16,7 @@ import copy
import mock
import unittest
+import collections
from yardstick.network_services.traffic_profile import ixia_rfc2544
from yardstick.network_services.traffic_profile import trex_traffic_profile
@@ -511,9 +512,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
with mock.patch.object(rfc2544_profile, '_get_ixia_traffic_profile') \
as mock_get_tp, \
mock.patch.object(rfc2544_profile, '_ixia_traffic_generate') \
- as mock_tgenerate, \
- mock.patch.object(rfc2544_profile, 'update_traffic_profile') \
- as mock_update_tp:
+ as mock_tgenerate:
mock_get_tp.return_value = 'fake_tprofile'
output = rfc2544_profile.execute_traffic(mock.ANY,
ixia_obj=mock.ANY)
@@ -524,7 +523,6 @@ class TestIXIARFC2544Profile(unittest.TestCase):
self.assertEqual(0, rfc2544_profile.min_rate)
mock_get_tp.assert_called_once()
mock_tgenerate.assert_called_once()
- mock_update_tp.assert_called_once()
def test_execute_traffic_not_first_run(self):
rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE)
@@ -683,3 +681,37 @@ class TestIXIARFC2544Profile(unittest.TestCase):
self.assertEqual(66.833, samples['RxThroughput'])
self.assertEqual(0.099651, samples['DropPercentage'])
self.assertEqual(33.45, rfc2544_profile.rate)
+
+
+class TestIXIARFC2544PppoeScenarioProfile(unittest.TestCase):
+
+ TRAFFIC_PROFILE = {
+ "schema": "nsb:traffic_profile:0.1",
+ "name": "fixed",
+ "description": "Fixed traffic profile to run UDP traffic",
+ "traffic_profile": {
+ "traffic_type": "FixedTraffic",
+ "frame_rate": 100},
+ 'uplink_0': {'ipv4': {'port': 'xe0', 'id': 1}},
+ 'downlink_0': {'ipv4': {'port': 'xe2', 'id': 2}},
+ 'uplink_1': {'ipv4': {'port': 'xe1', 'id': 3}},
+ 'downlink_1': {'ipv4': {'port': 'xe2', 'id': 4}}
+ }
+
+ def setUp(self):
+ self.ixia_tp = ixia_rfc2544.IXIARFC2544PppoeScenarioProfile(
+ self.TRAFFIC_PROFILE)
+
+ def test___init__(self):
+ self.assertIsInstance(self.ixia_tp.full_profile,
+ collections.OrderedDict)
+
+ def test__get_flow_groups_params(self):
+ expected_tp = collections.OrderedDict([
+ ('uplink_0', {'ipv4': {'id': 1, 'port': 'xe0'}}),
+ ('downlink_0', {'ipv4': {'id': 2, 'port': 'xe2'}}),
+ ('uplink_1', {'ipv4': {'id': 3, 'port': 'xe1'}}),
+ ('downlink_1', {'ipv4': {'id': 4, 'port': 'xe2'}})])
+
+ self.ixia_tp._get_flow_groups_params()
+ self.assertDictEqual(self.ixia_tp.full_profile, expected_tp)
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
index e22398847..65bf56f1e 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
@@ -18,6 +18,7 @@ import mock
import six
import unittest
import ipaddress
+from collections import OrderedDict
from yardstick.common import utils
from yardstick.common import exceptions
@@ -105,6 +106,7 @@ class TestIxiaResourceHelper(unittest.TestCase):
ixia_rhelper.run_traffic(mock_tprofile)
self.assertEqual('fake_samples', ixia_rhelper._queue.get())
+ mock_tprofile.update_traffic_profile.assert_called_once()
@mock.patch.object(tg_rfc2544_ixia, 'ixnet_api')
@@ -524,12 +526,112 @@ class TestIxiaPppoeClientScenario(unittest.TestCase):
mock_apply_core_net_cfg.assert_called_once()
mock_apply_access_net_cfg.assert_called_once()
- def test_create_traffic_model(self):
- self.scenario._access_topologies = 'access'
- self.scenario._core_topologies = 'core'
- self.scenario.create_traffic_model()
+ @mock.patch.object(tg_rfc2544_ixia.IxiaPppoeClientScenario,
+ '_get_endpoints_src_dst_id_pairs')
+ @mock.patch.object(tg_rfc2544_ixia.IxiaPppoeClientScenario,
+ '_get_endpoints_src_dst_obj_pairs')
+ def test_create_traffic_model(self, mock_obj_pairs, mock_id_pairs):
+ uplink_endpoints = ['group1', 'group2']
+ downlink_endpoints = ['group3', 'group3']
+ mock_id_pairs.return_value = ['xe0', 'xe1', 'xe0', 'xe1']
+ mock_obj_pairs.return_value = ['group1', 'group3', 'group2', 'group3']
+ mock_tp = mock.Mock()
+ mock_tp.full_profile = {'uplink_0': 'data',
+ 'downlink_0': 'data',
+ 'uplink_1': 'data',
+ 'downlink_1': 'data'
+ }
+ self.scenario.create_traffic_model(mock_tp)
+ mock_id_pairs.assert_called_once_with(mock_tp.full_profile)
+ mock_obj_pairs.assert_called_once_with(['xe0', 'xe1', 'xe0', 'xe1'])
self.scenario.client.create_ipv4_traffic_model.assert_called_once_with(
- 'access', 'core')
+ uplink_endpoints, downlink_endpoints)
+
+ def test__get_endpoints_src_dst_id_pairs(self):
+ full_tp = OrderedDict([
+ ('uplink_0', {'ipv4': {'port': 'xe0'}}),
+ ('downlink_0', {'ipv4': {'port': 'xe1'}}),
+ ('uplink_1', {'ipv4': {'port': 'xe0'}}),
+ ('downlink_1', {'ipv4': {'port': 'xe3'}})])
+ endpoints_src_dst_pairs = ['xe0', 'xe1', 'xe0', 'xe3']
+ res = self.scenario._get_endpoints_src_dst_id_pairs(full_tp)
+ self.assertEqual(res, endpoints_src_dst_pairs)
+
+ def test__get_endpoints_src_dst_id_pairs_wrong_flows_number(self):
+ full_tp = OrderedDict([
+ ('uplink_0', {'ipv4': {'port': 'xe0'}}),
+ ('downlink_0', {'ipv4': {'port': 'xe1'}}),
+ ('uplink_1', {'ipv4': {'port': 'xe0'}})])
+ with self.assertRaises(RuntimeError):
+ self.scenario._get_endpoints_src_dst_id_pairs(full_tp)
+
+ def test__get_endpoints_src_dst_id_pairs_no_port_key(self):
+ full_tp = OrderedDict([
+ ('uplink_0', {'ipv4': {'id': 1}}),
+ ('downlink_0', {'ipv4': {'id': 2}})])
+ self.assertEqual(
+ self.scenario._get_endpoints_src_dst_id_pairs(full_tp), [])
+
+ def test__get_endpoints_src_dst_obj_pairs_tp_with_port_key(self):
+ endpoints_id_pairs = ['xe0', 'xe1',
+ 'xe0', 'xe1',
+ 'xe0', 'xe3',
+ 'xe0', 'xe3']
+ ixia_cfg = {
+ 'pppoe_client': {
+ 'sessions_per_port': 4,
+ 'sessions_per_svlan': 1
+ },
+ 'flow': {
+ 'src_ip': [{'tg__0': 'xe0'}, {'tg__0': 'xe2'}],
+ 'dst_ip': [{'tg__0': 'xe1'}, {'tg__0': 'xe3'}]
+ }
+ }
+
+ expected_result = ['tp1_dg1', 'tp3_dg1', 'tp1_dg2', 'tp3_dg1',
+ 'tp1_dg3', 'tp4_dg1', 'tp1_dg4', 'tp4_dg1']
+
+ self.scenario._ixia_cfg = ixia_cfg
+ self.scenario._access_topologies = ['topology1', 'topology2']
+ self.scenario._core_topologies = ['topology3', 'topology4']
+ self.mock_IxNextgen.get_topology_device_groups.side_effect = \
+ [['tp1_dg1', 'tp1_dg2', 'tp1_dg3', 'tp1_dg4'],
+ ['tp2_dg1', 'tp2_dg2', 'tp2_dg3', 'tp2_dg4'],
+ ['tp3_dg1'],
+ ['tp4_dg1']]
+ res = self.scenario._get_endpoints_src_dst_obj_pairs(
+ endpoints_id_pairs)
+ self.assertEqual(res, expected_result)
+
+ def test__get_endpoints_src_dst_obj_pairs_default_flows_mapping(self):
+ endpoints_id_pairs = []
+ ixia_cfg = {
+ 'pppoe_client': {
+ 'sessions_per_port': 4,
+ 'sessions_per_svlan': 1
+ },
+ 'flow': {
+ 'src_ip': [{'tg__0': 'xe0'}, {'tg__0': 'xe2'}],
+ 'dst_ip': [{'tg__0': 'xe1'}, {'tg__0': 'xe3'}]
+ }
+ }
+
+ expected_result = ['tp1_dg1', 'tp3_dg1', 'tp1_dg2', 'tp3_dg1',
+ 'tp1_dg3', 'tp3_dg1', 'tp1_dg4', 'tp3_dg1',
+ 'tp2_dg1', 'tp4_dg1', 'tp2_dg2', 'tp4_dg1',
+ 'tp2_dg3', 'tp4_dg1', 'tp2_dg4', 'tp4_dg1']
+
+ self.scenario._ixia_cfg = ixia_cfg
+ self.scenario._access_topologies = ['topology1', 'topology2']
+ self.scenario._core_topologies = ['topology3', 'topology4']
+ self.mock_IxNextgen.get_topology_device_groups.side_effect = \
+ [['tp1_dg1', 'tp1_dg2', 'tp1_dg3', 'tp1_dg4'],
+ ['tp2_dg1', 'tp2_dg2', 'tp2_dg3', 'tp2_dg4'],
+ ['tp3_dg1'],
+ ['tp4_dg1']]
+ res = self.scenario._get_endpoints_src_dst_obj_pairs(
+ endpoints_id_pairs)
+ self.assertEqual(res, expected_result)
def test_run_protocols(self):
self.scenario.client.is_protocols_running.return_value = True