diff options
author | Myron Sosyak <myronx.sosyak@intel.com> | 2018-09-19 14:10:57 +0100 |
---|---|---|
committer | Taras Chornyi <tarasx.chornyi@intel.com> | 2018-11-12 09:00:53 +0000 |
commit | d99cfd9eaac88851d7efbb95292c2752755ae070 (patch) | |
tree | f20460834e9e1b5c11335c32dd982304b254defd /yardstick/tests | |
parent | 3fec49e7a3926ddf4f9303ee47a33d109421a573 (diff) |
Implement functionality for updating http client
Implemented functionality for updating http client configuration.
Extended http_ixload.py with functions for update page object
and count of simulated users in http client on netTraffic.
JIRA: YARDSTICK-1435
Change-Id: I9a0be226d4201d861d3a764864b42e5d87a4a305
Signed-off-by: Myron Sosyak <myronx.sosyak@intel.com>
Signed-off-by: Taras Chornyi <tarasx.chornyi@intel.com>
Diffstat (limited to 'yardstick/tests')
-rw-r--r-- | yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py | 22 | ||||
-rw-r--r-- | yardstick/tests/unit/network_services/traffic_profile/test_http_ixload.py | 57 |
2 files changed, 77 insertions, 2 deletions
diff --git a/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py index 90248d1bf..8214782b2 100644 --- a/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py +++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py @@ -325,6 +325,8 @@ class TestNetworkServiceTestCase(unittest.TestCase): }, }, 'options': { + 'simulated_users': {'uplink': [1, 2]}, + 'page_object': {'uplink': [1, 2]}, 'framesize': {'64B': 100} }, 'runner': { @@ -620,6 +622,20 @@ class TestNetworkServiceTestCase(unittest.TestCase): with self.assertRaises(IOError): self.s._get_traffic_profile() + def test__key_list_to_dict(self): + result = self.s._key_list_to_dict("uplink", {"uplink": [1, 2]}) + self.assertEqual({"uplink_0": 1, "uplink_1": 2}, result) + + def test__get_simulated_users(self): + result = self.s._get_simulated_users() + self.assertEqual({'simulated_users': {'uplink_0': 1, 'uplink_1': 2}}, + result) + + def test__get_page_object(self): + result = self.s._get_page_object() + self.assertEqual({'page_object': {'uplink_0': 1, 'uplink_1': 2}}, + result) + def test___get_traffic_imix_exception(self): with mock.patch.dict(self.scenario_cfg["traffic_options"], {'imix': ''}): self.assertEqual({'imix': {'64B': 100}}, @@ -642,7 +658,11 @@ class TestNetworkServiceTestCase(unittest.TestCase): 'flow': {'flow': {}}, 'imix': {'imix': {'64B': 100}}, 'uplink': {}, - 'duration': 30} + 'duration': 30, + 'simulated_users': { + 'simulated_users': {'uplink_0': 1, 'uplink_1': 2}}, + 'page_object': { + 'page_object': {'uplink_0': 1, 'uplink_1': 2}},} ) mock_tprofile_get.assert_called_once_with(fake_vnfd) diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_http_ixload.py b/yardstick/tests/unit/network_services/traffic_profile/test_http_ixload.py index 1adab48bc..c9be200b2 100644 --- a/yardstick/tests/unit/network_services/traffic_profile/test_http_ixload.py +++ b/yardstick/tests/unit/network_services/traffic_profile/test_http_ixload.py @@ -249,16 +249,20 @@ class TestIxLoadTrafficGen(unittest.TestCase): ixload = http_ixload.IXLOADHttpTest( jsonutils.dump_as_bytes(self.test_input)) - ixload.links_param = {"uplink_0": {"ip": {}}} + ixload.links_param = {"uplink_0": {"ip": {}, + "http_client": {}}} ixload.test = mock.Mock() ixload.test.communityList = community_list ixload.update_network_param = mock.Mock() + ixload.update_http_client_param = mock.Mock() ixload.update_config() ixload.update_network_param.assert_called_once_with(net_taraffic_0, {}) + ixload.update_http_client_param.assert_called_once_with(net_taraffic_0, + {}) def test_update_network_mac_address(self): ethernet = mock.MagicMock() @@ -338,6 +342,57 @@ class TestIxLoadTrafficGen(unittest.TestCase): net_traffic, "mac") + def test_update_http_client_param(self): + net_traffic = mock.Mock() + + ixload = http_ixload.IXLOADHttpTest( + jsonutils.dump_as_bytes(self.test_input)) + + ixload.update_page_size = mock.Mock() + ixload.update_user_count = mock.Mock() + + param = {"page_object": "page_object", + "simulated_users": "simulated_users"} + + ixload.update_http_client_param(net_traffic, param) + + ixload.update_page_size.assert_called_once_with(net_traffic, + "page_object") + ixload.update_user_count.assert_called_once_with(net_traffic, + "simulated_users") + + def test_update_page_size(self): + activity = mock.MagicMock() + net_traffic = mock.Mock() + + ixload = http_ixload.IXLOADHttpTest( + jsonutils.dump_as_bytes(self.test_input)) + + net_traffic.activityList = [activity] + ix_http_command = activity.agent.actionList[0] + ixload.update_page_size(net_traffic, "page_object") + ix_http_command.config.assert_called_once_with( + pageObject="page_object") + + net_traffic.activityList = [] + with self.assertRaises(exceptions.InvalidRxfFile): + ixload.update_page_size(net_traffic, "page_object") + + def test_update_user_count(self): + activity = mock.MagicMock() + net_traffic = mock.Mock() + + ixload = http_ixload.IXLOADHttpTest( + jsonutils.dump_as_bytes(self.test_input)) + + net_traffic.activityList = [activity] + ixload.update_user_count(net_traffic, 123) + activity.config.assert_called_once_with(userObjectiveValue=123) + + net_traffic.activityList = [] + with self.assertRaises(exceptions.InvalidRxfFile): + ixload.update_user_count(net_traffic, 123) + @mock.patch('yardstick.network_services.traffic_profile.http_ixload.IxLoad') @mock.patch('yardstick.network_services.traffic_profile.http_ixload.StatCollectorUtils') def test_start_http_test(self, *args): |