Merge "Open storperf testcase to huawei-pod2"
[yardstick.git] / yardstick / vTC / apexlake / tests / instantiation_validation_bench_test.py
index 369129a..69c5d74 100644 (file)
@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import absolute_import
 import unittest
 import mock
 import os
@@ -21,6 +22,8 @@ import experimental_framework.benchmarks.\
     instantiation_validation_benchmark as iv_module
 from experimental_framework.benchmarks.\
     instantiation_validation_benchmark import InstantiationValidationBenchmark
+from six.moves import map
+from six.moves import range
 
 
 kill_counter = [0, 0]
@@ -204,11 +207,11 @@ class InstantiationValidationInitTest(unittest.TestCase):
         ]
         expected['allowed_values'] = dict()
         expected['allowed_values'][iv_module.THROUGHPUT] = \
-            map(str, range(0, 100))
+            list(map(str, list(range(0, 100))))
         expected['allowed_values'][iv_module.VLAN_SENDER] = \
-            map(str, range(-1, 4096))
+            list(map(str, list(range(-1, 4096))))
         expected['allowed_values'][iv_module.VLAN_RECEIVER] = \
-            map(str, range(-1, 4096))
+            list(map(str, list(range(-1, 4096))))
         expected['default_values'] = dict()
         expected['default_values'][iv_module.THROUGHPUT] = '1'
         expected['default_values'][iv_module.VLAN_SENDER] = '-1'
@@ -216,7 +219,7 @@ class InstantiationValidationInitTest(unittest.TestCase):
         output = self.iv.get_features()
         self.assertEqual(expected, output)
 
-    @mock.patch('commands.getoutput')
+    @mock.patch('subprocess.check_output')
     def test__get_pids_for_success(self, mock_getoutput):
         expected = [1234]
         mock_getoutput.return_value = '1234'
@@ -254,6 +257,7 @@ class InstantiationValidationInitTest(unittest.TestCase):
         self.assertEqual(dummy_os_kill('', '', True), [1, 1])
         self.assertEqual(dummy_run_command('', True), [1, 1, 0, 0, 0])
 
+    @mock.patch('experimental_framework.benchmarks.instantiation_validation_benchmark.time')
     @mock.patch('os.chdir')
     @mock.patch('experimental_framework.common.run_command',
                 side_effect=dummy_run_command_2)
@@ -262,7 +266,7 @@ class InstantiationValidationInitTest(unittest.TestCase):
                 'InstantiationValidationBenchmark._get_pids')
     @mock.patch('os.kill', side_effect=dummy_os_kill)
     def test__init_packet_checker_for_success(self, mock_kill, mock_pids,
-                                              mock_run_command, mock_chdir):
+                                              mock_run_command, mock_chdir, mock_time):
         global command_counter
         command_counter = [0, 0, 0, 0, 0]
         mock_pids.return_value = [1234, 4321]
@@ -311,13 +315,14 @@ class InstantiationValidationInitTest(unittest.TestCase):
         self.assertEqual(dummy_replace_in_file('', '', '', True),
                          [0, 0, 0, 1, 1, 1])
 
+    @mock.patch('experimental_framework.benchmarks.instantiation_validation_benchmark.time')
     @mock.patch('experimental_framework.common.LOG')
     @mock.patch('experimental_framework.packet_generators.'
                 'dpdk_packet_generator.DpdkPacketGenerator',
                 side_effect=DummyDpdkPacketGenerator)
     @mock.patch('experimental_framework.common.get_dpdk_pktgen_vars')
     def test_run_for_success(self, mock_common_get_vars, mock_pktgen,
-                             mock_log):
+                             mock_log, mock_time):
         rval = dict()
         rval[cfs.CFSP_DPDK_BUS_SLOT_NIC_2] = 'bus_2'
         rval[cfs.CFSP_DPDK_NAME_IF_2] = 'if_2'