aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMyron Sosyak <myronx.sosyak@intel.com>2018-09-19 14:10:57 +0100
committerTaras Chornyi <tarasx.chornyi@intel.com>2018-11-12 09:00:53 +0000
commitd99cfd9eaac88851d7efbb95292c2752755ae070 (patch)
treef20460834e9e1b5c11335c32dd982304b254defd
parent3fec49e7a3926ddf4f9303ee47a33d109421a573 (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>
-rw-r--r--samples/vnf_samples/nsut/vfw/tc_baremetal_http_ixload_1b_Requests-65000_Concurrency.yaml4
-rw-r--r--samples/vnf_samples/traffic_profiles/http_tests/HTTP_1b-requests_65000_concurrency.yaml12
-rw-r--r--yardstick/benchmark/scenarios/networking/vnf_generic.py25
-rw-r--r--yardstick/network_services/traffic_profile/http_ixload.py51
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py22
-rw-r--r--yardstick/tests/unit/network_services/traffic_profile/test_http_ixload.py57
6 files changed, 159 insertions, 12 deletions
diff --git a/samples/vnf_samples/nsut/vfw/tc_baremetal_http_ixload_1b_Requests-65000_Concurrency.yaml b/samples/vnf_samples/nsut/vfw/tc_baremetal_http_ixload_1b_Requests-65000_Concurrency.yaml
index 1c807ca53..7a9a265d6 100644
--- a/samples/vnf_samples/nsut/vfw/tc_baremetal_http_ixload_1b_Requests-65000_Concurrency.yaml
+++ b/samples/vnf_samples/nsut/vfw/tc_baremetal_http_ixload_1b_Requests-65000_Concurrency.yaml
@@ -22,6 +22,10 @@ scenarios:
tg__0: trafficgen_1.yardstick
vnf__0: vnf.yardstick
options:
+ simulated_users:
+ uplink: [65000]
+ page_object:
+ uplink: ["/1b.html"]
framesize:
uplink: {64B: 100}
downlink: {64B: 100}
diff --git a/samples/vnf_samples/traffic_profiles/http_tests/HTTP_1b-requests_65000_concurrency.yaml b/samples/vnf_samples/traffic_profiles/http_tests/HTTP_1b-requests_65000_concurrency.yaml
index dcc11d55a..fec8b3316 100644
--- a/samples/vnf_samples/traffic_profiles/http_tests/HTTP_1b-requests_65000_concurrency.yaml
+++ b/samples/vnf_samples/traffic_profiles/http_tests/HTTP_1b-requests_65000_concurrency.yaml
@@ -13,10 +13,8 @@ uplink_0:
gateway: <GATEWAY_ADDR> # will be taken from pod file
http_client:
- http_no_requests: "1000" # number of http iterations
- http_concurency: "65000" # number of threads to be run
- http_locator: "/1B.bin" # http locator to be read
- attacker_tests: "False" # True : If attacker Test, False : Otherwise
+ simulated_users: {{ get(simulated_users, 'simulated_users.uplink_0', '65000') }} # number of threads to be run
+ page_object: {{ get(page_object, 'page_object.uplink_0', '/1b.html') }} # http locator to be read
downlink_0:
ip:
@@ -33,10 +31,8 @@ uplink_1:
gateway: <GATEWAY_ADDR>
http_client:
- http_no_requests: "1000"
- http_concurency: "65000"
- http_locator: "/1B.bin"
- attacker_tests: "False"
+ simulated_users: {{ get(simulated_users, 'simulated_users.uplink_1', '65000') }} # number of threads to be run
+ page_object: {{ get(page_object, 'page_object.uplink_1', '/1b.html') }} # http locator to be read
downlink_1:
ip:
diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py
index d8f062522..5ac51cdfc 100644
--- a/yardstick/benchmark/scenarios/networking/vnf_generic.py
+++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py
@@ -151,6 +151,26 @@ class NetworkServiceTestCase(scenario_base.Scenario):
return options.get('duration',
tprofile_base.TrafficProfileConfig.DEFAULT_DURATION)
+ def _key_list_to_dict(self, key, value_list):
+ value_dict = {}
+ try:
+ for index, count in enumerate(value_list[key]):
+ value_dict["{}_{}".format(key, index)] = count
+ except KeyError:
+ value_dict = {}
+
+ return value_dict
+
+ def _get_simulated_users(self):
+ users = self.scenario_cfg.get("options", {}).get("simulated_users", {})
+ simulated_users = self._key_list_to_dict("uplink", users)
+ return {"simulated_users": simulated_users}
+
+ def _get_page_object(self):
+ objects = self.scenario_cfg.get("options", {}).get("page_object", {})
+ page_object = self._key_list_to_dict("uplink", objects)
+ return {"page_object": page_object}
+
def _fill_traffic_profile(self):
tprofile = self._get_traffic_profile()
extra_args = self.scenario_cfg.get('extra_args', {})
@@ -160,8 +180,9 @@ class NetworkServiceTestCase(scenario_base.Scenario):
tprofile_base.TrafficProfile.UPLINK: {},
tprofile_base.TrafficProfile.DOWNLINK: {},
'extra_args': extra_args,
- 'duration': self._get_duration()}
-
+ 'duration': self._get_duration(),
+ 'page_object': self._get_page_object(),
+ 'simulated_users': self._get_simulated_users()}
traffic_vnfd = vnfdgen.generate_vnfd(tprofile, tprofile_data)
traffic_config = \
diff --git a/yardstick/network_services/traffic_profile/http_ixload.py b/yardstick/network_services/traffic_profile/http_ixload.py
index 9210f3c6d..c64e7511f 100644
--- a/yardstick/network_services/traffic_profile/http_ixload.py
+++ b/yardstick/network_services/traffic_profile/http_ixload.py
@@ -264,6 +264,57 @@ class IXLOADHttpTest(object):
continue
self.update_network_param(net_traffic, param["ip"])
+ if "uplink" in name:
+ self.update_http_client_param(net_traffic, param["http_client"])
+
+ def update_http_client_param(self, net_traffic, param):
+ """Update http client object in net_traffic
+
+ Update http client object in net_traffic by parameters
+ specified in param.
+ Do not return anything.
+
+ :param net_traffic: (IxLoadObjectProxy) proxy obj to tcl net_traffic object
+ :param param: (dict) http_client section from traffic profile
+ :return:
+ """
+ self.update_page_size(net_traffic, param["page_object"])
+ self.update_user_count(net_traffic, param["simulated_users"])
+
+ def update_page_size(self, net_traffic, page_object):
+ """Update page_object field in http client object in net_traffic
+
+ This function update field which configure page_object
+ which will be loaded from server
+ Do not return anything.
+
+ :param net_traffic: (IxLoadObjectProxy) proxy obj to tcl net_traffic object
+ :param page_object: (str) path to object on server e.g. "/4k.html"
+ :return:
+ """
+ try:
+ activity = net_traffic.activityList[0]
+ ix_http_command = activity.agent.actionList[0]
+ ix_http_command.config(pageObject=page_object)
+ except Exception:
+ raise exceptions.InvalidRxfFile
+
+ def update_user_count(self, net_traffic, user_count):
+ """Update userObjectiveValue field in activity object in net_traffic
+
+ This function update field which configure users count
+ which will be simulated by client.
+ Do not return anything.
+
+ :param net_traffic: (IxLoadObjectProxy) proxy obj to tcl net_traffic object
+ :param user_count: (int) number of simulated users
+ :return:
+ """
+ try:
+ activity = net_traffic.activityList[0]
+ activity.config(userObjectiveValue=user_count)
+ except Exception:
+ raise exceptions.InvalidRxfFile
def start_http_test(self):
self.ix_load = IxLoad()
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):