Merge "Prox standalone test case changes:"
authorAbhijit Sinha <abhijit.sinha@intel.com>
Wed, 14 Nov 2018 15:03:24 +0000 (15:03 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Wed, 14 Nov 2018 15:03:24 +0000 (15:03 +0000)
samples/vnf_samples/nsut/vfw/tc_baremetal_http_ixload_1b_Requests-65000_Concurrency.yaml
samples/vnf_samples/traffic_profiles/http_tests/HTTP_1b-requests_65000_concurrency.yaml
yardstick/benchmark/scenarios/networking/vnf_generic.py
yardstick/network_services/traffic_profile/http_ixload.py
yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
yardstick/tests/unit/network_services/traffic_profile/test_http_ixload.py

index 1c807ca..7a9a265 100644 (file)
@@ -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}
index dcc11d5..fec8b33 100644 (file)
@@ -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:
index d8f0625..5ac51cd 100644 (file)
@@ -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 = \
index 9210f3c..c64e751 100644 (file)
@@ -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()
index 90248d1..8214782 100644 (file)
@@ -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)
 
index 1adab48..c9be200 100644 (file)
@@ -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):