aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/network_services/traffic_profile
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-09-05 13:02:33 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-09-05 13:02:33 +0000
commitd332664dd680d877ef822660c2f8bed2ef0a7322 (patch)
tree84bb833730cfd9f2141ef7ae86296013ecbc3e77 /tests/unit/network_services/traffic_profile
parent2251057b0222464398ae86d92b5904f418af6ed8 (diff)
parenta1722f91ac250e2a021b7a1cc4e4f99f11ff41e0 (diff)
Merge "Addition of Prox NSB changes in yardstick"
Diffstat (limited to 'tests/unit/network_services/traffic_profile')
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_binsearch.py12
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_mpls.py93
2 files changed, 99 insertions, 6 deletions
diff --git a/tests/unit/network_services/traffic_profile/test_prox_binsearch.py b/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
index 72b86709c..0edce7a14 100644
--- a/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
+++ b/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
@@ -37,8 +37,8 @@ class TestProxBinSearchProfile(unittest.TestCase):
if args[2] < 0 or args[2] > 100:
raise RuntimeError(' '.join([str(args), str(runs)]))
if args[2] > 75.0:
- return fail_tuple
- return success_tuple
+ return fail_tuple, {}
+ return success_tuple, {}
tp_config = {
'traffic_profile': {
@@ -51,7 +51,7 @@ class TestProxBinSearchProfile(unittest.TestCase):
fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
traffic_generator = mock.MagicMock()
- traffic_generator.resource_helper.run_test = target
+ traffic_generator.run_test = target
profile = ProxBinSearchProfile(tp_config)
profile.init(mock.MagicMock())
@@ -67,8 +67,8 @@ class TestProxBinSearchProfile(unittest.TestCase):
if args[2] < 0 or args[2] > 100:
raise RuntimeError(' '.join([str(args), str(runs)]))
if args[2] > 25.0:
- return fail_tuple
- return success_tuple
+ return fail_tuple, {}
+ return success_tuple, {}
tp_config = {
'traffic_profile': {
@@ -82,7 +82,7 @@ class TestProxBinSearchProfile(unittest.TestCase):
fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
traffic_generator = mock.MagicMock()
- traffic_generator.resource_helper.run_test = target
+ traffic_generator.run_test = target
profile = ProxBinSearchProfile(tp_config)
profile.init(mock.MagicMock())
diff --git a/tests/unit/network_services/traffic_profile/test_prox_mpls.py b/tests/unit/network_services/traffic_profile/test_prox_mpls.py
new file mode 100644
index 000000000..77bca9cc0
--- /dev/null
+++ b/tests/unit/network_services/traffic_profile/test_prox_mpls.py
@@ -0,0 +1,93 @@
+# Copyright (c) 2017 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from __future__ import absolute_import
+
+import unittest
+import mock
+
+from tests.unit import STL_MOCKS
+
+STLClient = mock.MagicMock()
+stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
+stl_patch.start()
+
+if stl_patch:
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxTestDataTuple
+ from yardstick.network_services.traffic_profile.prox_mpls_tag_untag import ProxMplsTagUntagProfile
+
+
+class TestProxMplsTagUntagProfile(unittest.TestCase):
+
+ def test_mpls_1(self):
+ def target(*args, **kwargs):
+ runs.append(args[2])
+ if args[2] < 0 or args[2] > 100:
+ raise RuntimeError(' '.join([str(args), str(runs)]))
+ if args[2] > 75.0:
+ return fail_tuple, {}
+ return success_tuple, {}
+
+ tp_config = {
+ 'traffic_profile': {
+ 'packet_sizes': [200],
+ },
+ }
+
+ runs = []
+ success_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.1, 5.2, 5.3], 995, 1000, 123.4)
+ fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
+
+ traffic_generator = mock.MagicMock()
+ traffic_generator.run_test = target
+
+ profile = ProxMplsTagUntagProfile(tp_config)
+ profile.init(mock.MagicMock())
+
+ profile.execute(traffic_generator)
+ self.assertEqual(round(profile.current_lower, 2), 74.69)
+ self.assertEqual(round(profile.current_upper, 2), 75.39)
+ self.assertEqual(len(runs), 8)
+
+ def test_mpls_2(self):
+ def target(*args, **kwargs):
+ runs.append(args[2])
+ if args[2] < 0 or args[2] > 100:
+ raise RuntimeError(' '.join([str(args), str(runs)]))
+ if args[2] > 25.0:
+ return fail_tuple, {}
+ return success_tuple, {}
+
+ tp_config = {
+ 'traffic_profile': {
+ 'packet_sizes': [200],
+ 'test_precision': 2.0,
+ },
+ }
+
+ runs = []
+ success_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.1, 5.2, 5.3], 995, 1000, 123.4)
+ fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
+
+ traffic_generator = mock.MagicMock()
+ traffic_generator.run_test = target
+
+ profile = ProxMplsTagUntagProfile(tp_config)
+ profile.init(mock.MagicMock())
+
+ profile.execute(traffic_generator)
+ self.assertEqual(round(profile.current_lower, 2), 24.06)
+ self.assertEqual(round(profile.current_upper, 2), 25.47)
+ self.assertEqual(len(runs), 7)