aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/vTC
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2016-12-05 16:11:54 -0500
committerRoss Brattain <ross.b.brattain@intel.com>2017-01-12 18:25:04 -0800
commitf036e9898a69f5041f9cde02e3652c29e2de1643 (patch)
tree36e5eea75811bb640bb30f442f5a3c617e945909 /yardstick/vTC
parent5f0b3d417244397b2d5e61c7a6ddd145f1d25046 (diff)
Add support for Python 3
Porting to Python3 using Openstack guidelines: https://wiki.openstack.org/wiki/Python3 This passes unittests on Python 3.5 and passes opnfv_smoke suite Updates: use six for urlparse and urlopen fix exception.message attribute removal run unittests on python3 use unitest.mock on python 3 fix open mock for vsperf fix float division by using delta/eplison comparison use unicode in StringIO use plugin/sample_config.yaml relative path from test case fixed apexlake unittests upgraded to mock 2.0.0 to match python3 unittest.mock features fixed flake8 issues implement safe JSON decode with oslo_serialization.jsonutils.dump_as_bytes() implement safe unicode encode/decode with oslo_utils.encodeutils heat: convert pub key file from bytes to unicode pkg_resources returns raw bytes, in python3 we have to decode this to utf-8 unicode so JSON can encode it for heat template JIRA: YARDSTICK-452 Change-Id: Ib80dd1d0c0eb0592acd832b82f6a7f8f7c20bfda Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Diffstat (limited to 'yardstick/vTC')
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/__init__.py9
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/api.py1
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/benchmarking_unit.py14
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/benchmarks/benchmark_base_class.py3
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_benchmark.py32
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_noisy_neighbors_benchmark.py7
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/benchmarks/multi_tenancy_throughput_benchmark.py2
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/benchmarks/rfc2544_throughput_benchmark.py10
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/benchmarks/test_benchmark.py1
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/common.py14
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/constants/framework_parameters.py1
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/deployment_unit.py23
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/heat_manager.py6
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/heat_template_generation.py1
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/packet_generators/base_packet_generator.py1
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/packet_generators/dpdk_packet_generator.py10
-rw-r--r--yardstick/vTC/apexlake/setup.py1
-rw-r--r--yardstick/vTC/apexlake/tests/api_test.py16
-rw-r--r--yardstick/vTC/apexlake/tests/base_packet_generator_test.py1
-rw-r--r--yardstick/vTC/apexlake/tests/benchmark_base_class_test.py5
-rw-r--r--yardstick/vTC/apexlake/tests/benchmarking_unit_test.py11
-rw-r--r--yardstick/vTC/apexlake/tests/common_test.py73
-rw-r--r--yardstick/vTC/apexlake/tests/conf_file_sections_test.py1
-rw-r--r--yardstick/vTC/apexlake/tests/deployment_unit_test.py1
-rw-r--r--yardstick/vTC/apexlake/tests/dpdk_packet_generator_test.py1
-rw-r--r--yardstick/vTC/apexlake/tests/generates_template_test.py17
-rw-r--r--yardstick/vTC/apexlake/tests/heat_manager_test.py27
-rw-r--r--yardstick/vTC/apexlake/tests/instantiation_validation_bench_test.py11
-rw-r--r--yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py34
-rw-r--r--yardstick/vTC/apexlake/tests/multi_tenancy_throughput_benchmark_test.py10
-rw-r--r--yardstick/vTC/apexlake/tests/rfc2544_throughput_benchmark_test.py8
-rw-r--r--yardstick/vTC/apexlake/tests/tree_node_test.py2
32 files changed, 220 insertions, 134 deletions
diff --git a/yardstick/vTC/apexlake/experimental_framework/__init__.py b/yardstick/vTC/apexlake/experimental_framework/__init__.py
index d4ab29e9d..9c4eef12d 100644
--- a/yardstick/vTC/apexlake/experimental_framework/__init__.py
+++ b/yardstick/vTC/apexlake/experimental_framework/__init__.py
@@ -12,6 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-'''
+"""
Experimental Framework
-'''
+"""
+from __future__ import absolute_import
+import os
+
+APEX_LAKE_ROOT = os.path.realpath(
+ os.path.join(os.path.dirname(os.path.dirname(__file__))))
diff --git a/yardstick/vTC/apexlake/experimental_framework/api.py b/yardstick/vTC/apexlake/experimental_framework/api.py
index e0209befd..24dd1f89a 100644
--- a/yardstick/vTC/apexlake/experimental_framework/api.py
+++ b/yardstick/vTC/apexlake/experimental_framework/api.py
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import absolute_import
import experimental_framework.benchmarking_unit as b_unit
from experimental_framework import heat_template_generation, common
diff --git a/yardstick/vTC/apexlake/experimental_framework/benchmarking_unit.py b/yardstick/vTC/apexlake/experimental_framework/benchmarking_unit.py
index 1963696f8..d5de308c7 100644
--- a/yardstick/vTC/apexlake/experimental_framework/benchmarking_unit.py
+++ b/yardstick/vTC/apexlake/experimental_framework/benchmarking_unit.py
@@ -18,6 +18,7 @@ initialization, execution and finalization
'''
+from __future__ import absolute_import
import json
import time
import inspect
@@ -27,6 +28,7 @@ from experimental_framework import common
# from experimental_framework import data_manager as data
from experimental_framework import heat_template_generation as heat
from experimental_framework import deployment_unit as deploy
+from six.moves import range
class BenchmarkingUnit:
@@ -116,10 +118,10 @@ class BenchmarkingUnit:
"""
common.LOG.info('Run Benchmarking Unit')
- experiment = dict()
- result = dict()
- for iteration in range(0, self.iterations):
- common.LOG.info('Iteration ' + str(iteration))
+ experiment = {}
+ result = {}
+ for iteration in range(self.iterations):
+ common.LOG.info('Iteration %s', iteration)
for template_file_name in self.template_files:
experiment_name = BenchmarkingUnit.\
extract_experiment_name(template_file_name)
@@ -238,7 +240,7 @@ class BenchmarkingUnit:
:return: (str) Experiment Name
"""
strings = template_file_name.split('.')
- return ".".join(strings[:(len(strings)-1)])
+ return ".".join(strings[:(len(strings) - 1)])
@staticmethod
def get_benchmark_class(complete_module_name):
@@ -253,7 +255,7 @@ class BenchmarkingUnit:
"""
strings = complete_module_name.split('.')
class_name = 'experimental_framework.benchmarks.{}'.format(strings[0])
- pkg = __import__(class_name, globals(), locals(), [], -1)
+ pkg = __import__(class_name, globals(), locals(), [], 0)
module = getattr(getattr(pkg, 'benchmarks'), strings[0])
members = inspect.getmembers(module)
for m in members:
diff --git a/yardstick/vTC/apexlake/experimental_framework/benchmarks/benchmark_base_class.py b/yardstick/vTC/apexlake/experimental_framework/benchmarks/benchmark_base_class.py
index ac7fad88e..96cce2265 100644
--- a/yardstick/vTC/apexlake/experimental_framework/benchmarks/benchmark_base_class.py
+++ b/yardstick/vTC/apexlake/experimental_framework/benchmarks/benchmark_base_class.py
@@ -13,6 +13,7 @@
# limitations under the License.
+from __future__ import absolute_import
import abc
@@ -30,7 +31,7 @@ class BenchmarkBaseClass(object):
raise ValueError("Parameters need to be provided in a dict")
for param in self.get_features()['parameters']:
- if param not in params.keys():
+ if param not in list(params.keys()):
params[param] = self.get_features()['default_values'][param]
for param in self.get_features()['parameters']:
diff --git a/yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_benchmark.py b/yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_benchmark.py
index 320becae5..db9d449ef 100644
--- a/yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_benchmark.py
+++ b/yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_benchmark.py
@@ -12,16 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import absolute_import
import os
-import commands
# import signal
import time
+
+import subprocess
from experimental_framework.benchmarks import benchmark_base_class as base
from experimental_framework.constants import framework_parameters as fp
from experimental_framework.constants import conf_file_sections as cfs
from experimental_framework.packet_generators import dpdk_packet_generator \
as dpdk
import experimental_framework.common as common
+from six.moves import range
THROUGHPUT = 'throughput'
@@ -36,7 +39,7 @@ class InstantiationValidationBenchmark(base.BenchmarkBaseClass):
def __init__(self, name, params):
base.BenchmarkBaseClass.__init__(self, name, params)
- self.base_dir = "{}{}{}".format(
+ self.base_dir = os.path.join(
common.get_base_dir(), fp.EXPERIMENTAL_FRAMEWORK_DIR,
fp.DPDK_PKTGEN_DIR)
self.results_file = self.base_dir + PACKETS_FILE_NAME
@@ -45,10 +48,11 @@ class InstantiationValidationBenchmark(base.BenchmarkBaseClass):
self.interface_name = ''
# Set the packet checker command
- self.pkt_checker_command = common.get_base_dir()
- self.pkt_checker_command += 'experimental_framework/libraries/'
- self.pkt_checker_command += 'packet_checker/'
- self.pkt_checker_command += PACKET_CHECKER_PROGRAM_NAME + ' '
+ self.pkt_checker_command = os.path.join(
+ common.get_base_dir(),
+ 'experimental_framework/libraries/',
+ 'packet_checker/',
+ PACKET_CHECKER_PROGRAM_NAME + ' ')
def init(self):
"""
@@ -69,9 +73,11 @@ class InstantiationValidationBenchmark(base.BenchmarkBaseClass):
features['description'] = 'Instantiation Validation Benchmark'
features['parameters'] = [THROUGHPUT, VLAN_SENDER, VLAN_RECEIVER]
features['allowed_values'] = dict()
- features['allowed_values'][THROUGHPUT] = map(str, range(0, 100))
- features['allowed_values'][VLAN_SENDER] = map(str, range(-1, 4096))
- features['allowed_values'][VLAN_RECEIVER] = map(str, range(-1, 4096))
+ features['allowed_values'][THROUGHPUT] = [str(x) for x in range(100)]
+ features['allowed_values'][VLAN_SENDER] = [str(x) for x in
+ range(-1, 4096)]
+ features['allowed_values'][VLAN_RECEIVER] = [str(x)
+ for x in range(-1, 4096)]
features['default_values'] = dict()
features['default_values'][THROUGHPUT] = '1'
features['default_values'][VLAN_SENDER] = '-1'
@@ -203,7 +209,7 @@ class InstantiationValidationBenchmark(base.BenchmarkBaseClass):
# Start the packet checker
current_dir = os.path.dirname(os.path.realpath(__file__))
dir_list = self.pkt_checker_command.split('/')
- directory = '/'.join(dir_list[0:len(dir_list)-1])
+ directory = os.pathsep.join(dir_list[0:len(dir_list) - 1])
os.chdir(directory)
command = "make"
common.run_command(command)
@@ -245,10 +251,10 @@ class InstantiationValidationBenchmark(base.BenchmarkBaseClass):
processes currently running on the host
:return: type: list of int
"""
- output = commands.getoutput("ps -ef |pgrep " +
- PACKET_CHECKER_PROGRAM_NAME)
+ output = subprocess.check_output(
+ 'pgrep "{}"'.format(PACKET_CHECKER_PROGRAM_NAME))
if not output:
pids = []
else:
- pids = map(int, output.split('\n'))
+ pids = [int(x) for x in output.splitlines()]
return pids
diff --git a/yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_noisy_neighbors_benchmark.py b/yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_noisy_neighbors_benchmark.py
index 1eab70c67..5569b6c12 100644
--- a/yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_noisy_neighbors_benchmark.py
+++ b/yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_noisy_neighbors_benchmark.py
@@ -13,8 +13,11 @@
# limitations under the License.
-import instantiation_validation_benchmark as base
+from __future__ import absolute_import
from experimental_framework import common
+from experimental_framework.benchmarks import \
+ instantiation_validation_benchmark as base
+from six.moves import range
NUM_OF_NEIGHBORS = 'num_of_neighbours'
@@ -38,7 +41,7 @@ class InstantiationValidationNoisyNeighborsBenchmark(
self.template_file = common.get_template_dir() + \
temp_name
self.stack_name = 'neighbour'
- self.neighbor_stack_names = list()
+ self.neighbor_stack_names = []
def get_features(self):
features = super(InstantiationValidationNoisyNeighborsBenchmark,
diff --git a/yardstick/vTC/apexlake/experimental_framework/benchmarks/multi_tenancy_throughput_benchmark.py b/yardstick/vTC/apexlake/experimental_framework/benchmarks/multi_tenancy_throughput_benchmark.py
index f2a87b2b2..44c9f327a 100644
--- a/yardstick/vTC/apexlake/experimental_framework/benchmarks/multi_tenancy_throughput_benchmark.py
+++ b/yardstick/vTC/apexlake/experimental_framework/benchmarks/multi_tenancy_throughput_benchmark.py
@@ -13,9 +13,11 @@
# limitations under the License.
+from __future__ import absolute_import
from experimental_framework.benchmarks import rfc2544_throughput_benchmark \
as base
from experimental_framework import common
+from six.moves import range
NETWORK_NAME = 'network'
diff --git a/yardstick/vTC/apexlake/experimental_framework/benchmarks/rfc2544_throughput_benchmark.py b/yardstick/vTC/apexlake/experimental_framework/benchmarks/rfc2544_throughput_benchmark.py
index 9db62e639..5c7b55e42 100644
--- a/yardstick/vTC/apexlake/experimental_framework/benchmarks/rfc2544_throughput_benchmark.py
+++ b/yardstick/vTC/apexlake/experimental_framework/benchmarks/rfc2544_throughput_benchmark.py
@@ -11,6 +11,8 @@
# 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
+from six.moves import range
from experimental_framework.benchmarks import benchmark_base_class
from experimental_framework.packet_generators \
@@ -60,8 +62,10 @@ class RFC2544ThroughputBenchmark(benchmark_base_class.BenchmarkBaseClass):
features['allowed_values'] = dict()
features['allowed_values'][PACKET_SIZE] = ['64', '128', '256', '512',
'1024', '1280', '1514']
- features['allowed_values'][VLAN_SENDER] = map(str, range(-1, 4096))
- features['allowed_values'][VLAN_RECEIVER] = map(str, range(-1, 4096))
+ features['allowed_values'][VLAN_SENDER] = [str(x) for x in
+ range(-1, 4096)]
+ features['allowed_values'][VLAN_RECEIVER] = [str(x) for x in
+ range(-1, 4096)]
features['default_values'] = dict()
features['default_values'][PACKET_SIZE] = '1280'
features['default_values'][VLAN_SENDER] = '1007'
@@ -99,7 +103,7 @@ class RFC2544ThroughputBenchmark(benchmark_base_class.BenchmarkBaseClass):
:return: packet_sizes (list)
"""
packet_size = '1280' # default value
- if PACKET_SIZE in self.params.keys() and \
+ if PACKET_SIZE in list(self.params.keys()) and \
isinstance(self.params[PACKET_SIZE], str):
packet_size = self.params[PACKET_SIZE]
return packet_size
diff --git a/yardstick/vTC/apexlake/experimental_framework/benchmarks/test_benchmark.py b/yardstick/vTC/apexlake/experimental_framework/benchmarks/test_benchmark.py
index cbb930d21..5891832f2 100644
--- a/yardstick/vTC/apexlake/experimental_framework/benchmarks/test_benchmark.py
+++ b/yardstick/vTC/apexlake/experimental_framework/benchmarks/test_benchmark.py
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import absolute_import
import time
from experimental_framework.benchmarks import benchmark_base_class as base
diff --git a/yardstick/vTC/apexlake/experimental_framework/common.py b/yardstick/vTC/apexlake/experimental_framework/common.py
index 4bacd38a6..feea8bde6 100644
--- a/yardstick/vTC/apexlake/experimental_framework/common.py
+++ b/yardstick/vTC/apexlake/experimental_framework/common.py
@@ -12,9 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import print_function
+from __future__ import absolute_import
import os
import re
-import ConfigParser
+import six.moves.configparser
import logging
import fileinput
from experimental_framework.constants import conf_file_sections as cf
@@ -70,7 +72,7 @@ def init(api=False):
init_conf_file(api)
init_log()
init_general_vars(api)
- if len(CONF_FILE.get_variable_list(cf.CFS_PKTGEN)) > 0:
+ if CONF_FILE.get_variable_list(cf.CFS_PKTGEN):
init_pktgen()
@@ -129,7 +131,7 @@ def init_general_vars(api=False):
RESULT_DIR = "/tmp/apexlake/results/"
if not os.path.isdir(RESULT_DIR):
- os.mkdir(RESULT_DIR)
+ os.makedirs(RESULT_DIR)
if cf.CFSO_RELEASE in CONF_FILE.get_variable_list(cf.CFS_OPENSTACK):
RELEASE = CONF_FILE.get_variable(cf.CFS_OPENSTACK, cf.CFSO_RELEASE)
@@ -311,7 +313,7 @@ class ConfigurationFile:
# config_file = BASE_DIR + config_file
InputValidation.validate_file_exist(
config_file, 'The provided configuration file does not exist')
- self.config = ConfigParser.ConfigParser()
+ self.config = six.moves.configparser.ConfigParser()
self.config.read(config_file)
for section in sections:
setattr(
@@ -457,7 +459,7 @@ def replace_in_file(file, text_to_search, text_to_replace):
message = "The file does not exist"
InputValidation.validate_file_exist(file, message)
for line in fileinput.input(file, inplace=True):
- print(line.replace(text_to_search, text_to_replace).rstrip())
+ print((line.replace(text_to_search, text_to_replace).rstrip()))
# ------------------------------------------------------
@@ -610,7 +612,7 @@ class InputValidation(object):
missing = [
credential_key
for credential_key in credential_keys
- if credential_key not in credentials.keys()
+ if credential_key not in list(credentials.keys())
]
if len(missing) == 0:
return True
diff --git a/yardstick/vTC/apexlake/experimental_framework/constants/framework_parameters.py b/yardstick/vTC/apexlake/experimental_framework/constants/framework_parameters.py
index 4ee3a8aa3..6e651bf19 100644
--- a/yardstick/vTC/apexlake/experimental_framework/constants/framework_parameters.py
+++ b/yardstick/vTC/apexlake/experimental_framework/constants/framework_parameters.py
@@ -13,6 +13,7 @@
# limitations under the License.
+from __future__ import absolute_import
from experimental_framework.constants import conf_file_sections as cfs
# ------------------------------------------------------
diff --git a/yardstick/vTC/apexlake/experimental_framework/deployment_unit.py b/yardstick/vTC/apexlake/experimental_framework/deployment_unit.py
index 22fec1392..0bb507c51 100644
--- a/yardstick/vTC/apexlake/experimental_framework/deployment_unit.py
+++ b/yardstick/vTC/apexlake/experimental_framework/deployment_unit.py
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import absolute_import
import os
import time
@@ -50,8 +51,8 @@ class DeploymentUnit:
time.sleep(5)
status = self.heat_manager.check_stack_status(stack_name)
return True
- except Exception as e:
- common.LOG.debug(e.message)
+ except Exception:
+ common.LOG.debug("check_stack_status", exc_info=True)
return False
def destroy_all_deployed_stacks(self):
@@ -81,17 +82,16 @@ class DeploymentUnit:
self.heat_manager.create_stack(template_file, stack_name,
parameters)
deployed = True
- except Exception as e:
- common.LOG.debug(e.message)
+ except Exception:
+ common.LOG.debug("create_stack", exc_info=True)
deployed = False
if not deployed and 'COMPLETE' in \
self.heat_manager.check_stack_status(stack_name):
try:
self.destroy_heat_template(stack_name)
- except Exception as e:
- common.LOG.debug(e.message)
- pass
+ except Exception:
+ common.LOG.debug("destroy_heat_template", exc_info=True)
status = self.heat_manager.check_stack_status(stack_name)
while status and 'CREATE_IN_PROGRESS' in status:
@@ -102,16 +102,15 @@ class DeploymentUnit:
attempt += 1
try:
self.destroy_heat_template(stack_name)
- except Exception as e:
- common.LOG.debug(e.message)
- pass
+ except Exception:
+ common.LOG.debug("destroy_heat_template", exc_info=True)
return self.deploy_heat_template(template_file, stack_name,
parameters, attempt)
else:
try:
self.destroy_heat_template(stack_name)
- except Exception as e:
- common.LOG.debug(e.message)
+ except Exception:
+ common.LOG.debug("destroy_heat_template", exc_info=True)
finally:
return False
if self.heat_manager.check_stack_status(stack_name) and \
diff --git a/yardstick/vTC/apexlake/experimental_framework/heat_manager.py b/yardstick/vTC/apexlake/experimental_framework/heat_manager.py
index 7400ebd21..a3233349d 100644
--- a/yardstick/vTC/apexlake/experimental_framework/heat_manager.py
+++ b/yardstick/vTC/apexlake/experimental_framework/heat_manager.py
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import absolute_import
from keystoneclient.v2_0 import client as keystoneClient
from heatclient import client as heatClient
from heatclient.common import template_utils
@@ -97,7 +98,6 @@ class HeatManager:
if stack.stack_name == stack_name:
self.heat.stacks.delete(stack.id)
return True
- except Exception as e:
- common.LOG.debug(e.message)
- pass
+ except Exception:
+ common.LOG.debug("destroy_heat_template", exc_info=True)
return False
diff --git a/yardstick/vTC/apexlake/experimental_framework/heat_template_generation.py b/yardstick/vTC/apexlake/experimental_framework/heat_template_generation.py
index e0c1a667f..0f0af8b05 100644
--- a/yardstick/vTC/apexlake/experimental_framework/heat_template_generation.py
+++ b/yardstick/vTC/apexlake/experimental_framework/heat_template_generation.py
@@ -17,6 +17,7 @@
Generation of the heat templates from the base template
'''
+from __future__ import absolute_import
import json
import os
import shutil
diff --git a/yardstick/vTC/apexlake/experimental_framework/packet_generators/base_packet_generator.py b/yardstick/vTC/apexlake/experimental_framework/packet_generators/base_packet_generator.py
index 4d2c6fe72..57f586463 100644
--- a/yardstick/vTC/apexlake/experimental_framework/packet_generators/base_packet_generator.py
+++ b/yardstick/vTC/apexlake/experimental_framework/packet_generators/base_packet_generator.py
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import absolute_import
import abc
diff --git a/yardstick/vTC/apexlake/experimental_framework/packet_generators/dpdk_packet_generator.py b/yardstick/vTC/apexlake/experimental_framework/packet_generators/dpdk_packet_generator.py
index 6dc32b671..959003628 100644
--- a/yardstick/vTC/apexlake/experimental_framework/packet_generators/dpdk_packet_generator.py
+++ b/yardstick/vTC/apexlake/experimental_framework/packet_generators/dpdk_packet_generator.py
@@ -12,12 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import absolute_import
import os
-import base_packet_generator
-import experimental_framework.common as common
import time
+
+
+import experimental_framework.common as common
from experimental_framework.constants import conf_file_sections as conf_file
from experimental_framework.constants import framework_parameters as fp
+from experimental_framework.packet_generators import base_packet_generator
class DpdkPacketGenerator(base_packet_generator.BasePacketGenerator):
@@ -186,8 +189,7 @@ class DpdkPacketGenerator(base_packet_generator.BasePacketGenerator):
conf_file.CFSP_DPDK_PROGRAM_NAME,
conf_file.CFSP_DPDK_COREMASK,
conf_file.CFSP_DPDK_MEMORY_CHANNEL]:
- if var not in variables.keys() or (var in variables.keys() and
- variables[var] is ''):
+ if variables.get(var, '') == '':
raise ValueError("The variable " + var + " does not exist")
@staticmethod
diff --git a/yardstick/vTC/apexlake/setup.py b/yardstick/vTC/apexlake/setup.py
index 188a7f0c3..0211a57c1 100644
--- a/yardstick/vTC/apexlake/setup.py
+++ b/yardstick/vTC/apexlake/setup.py
@@ -16,6 +16,7 @@
Experimental Framework
"""
+from __future__ import absolute_import
from distutils.core import setup
diff --git a/yardstick/vTC/apexlake/tests/api_test.py b/yardstick/vTC/apexlake/tests/api_test.py
index 4b70b9bd6..b6191ed8f 100644
--- a/yardstick/vTC/apexlake/tests/api_test.py
+++ b/yardstick/vTC/apexlake/tests/api_test.py
@@ -13,14 +13,18 @@
# limitations under the License.
+from __future__ import absolute_import
import unittest
import mock
import os
import experimental_framework.common as common
+from experimental_framework import APEX_LAKE_ROOT
from experimental_framework.api import FrameworkApi
from experimental_framework.benchmarking_unit import BenchmarkingUnit
import experimental_framework.benchmarks.\
instantiation_validation_benchmark as iv
+from six.moves import map
+from six.moves import range
class DummyBenchmarkingUnit(BenchmarkingUnit):
@@ -61,6 +65,7 @@ class DummyBenchmarkingUnit2(BenchmarkingUnit):
class TestGeneratesTemplate(unittest.TestCase):
+
def setUp(self):
pass
@@ -92,11 +97,11 @@ class TestGeneratesTemplate(unittest.TestCase):
iv.VLAN_RECEIVER]
expected['allowed_values'] = dict()
expected['allowed_values'][iv.THROUGHPUT] = \
- map(str, range(0, 100))
+ list(map(str, list(range(0, 100))))
expected['allowed_values'][iv.VLAN_SENDER] = \
- map(str, range(-1, 4096))
+ list(map(str, list(range(-1, 4096))))
expected['allowed_values'][iv.VLAN_RECEIVER] = \
- map(str, range(-1, 4096))
+ list(map(str, list(range(-1, 4096))))
expected['default_values'] = dict()
expected['default_values'][iv.THROUGHPUT] = '1'
expected['default_values'][iv.VLAN_SENDER] = '-1'
@@ -121,9 +126,8 @@ class TestGeneratesTemplate(unittest.TestCase):
def test_execute_framework_for_success(self, mock_b_unit, mock_heat,
mock_credentials, mock_log,
mock_common_init):
- common.TEMPLATE_DIR = "{}/{}/".format(
- os.getcwd(), 'tests/data/generated_templates'
- )
+ common.TEMPLATE_DIR = os.path.join(APEX_LAKE_ROOT,
+ 'tests/data/generated_templates/')
test_cases = dict()
iterations = 1
diff --git a/yardstick/vTC/apexlake/tests/base_packet_generator_test.py b/yardstick/vTC/apexlake/tests/base_packet_generator_test.py
index b0e27d069..153de171d 100644
--- a/yardstick/vTC/apexlake/tests/base_packet_generator_test.py
+++ b/yardstick/vTC/apexlake/tests/base_packet_generator_test.py
@@ -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
from experimental_framework.packet_generators import base_packet_generator
diff --git a/yardstick/vTC/apexlake/tests/benchmark_base_class_test.py b/yardstick/vTC/apexlake/tests/benchmark_base_class_test.py
index 405c0102f..4e5eb9fb0 100644
--- a/yardstick/vTC/apexlake/tests/benchmark_base_class_test.py
+++ b/yardstick/vTC/apexlake/tests/benchmark_base_class_test.py
@@ -13,6 +13,7 @@
# limitations under the License.
+from __future__ import absolute_import
import unittest
from experimental_framework.benchmarks import benchmark_base_class as base
@@ -45,8 +46,8 @@ class TestBenchmarkBaseClass(unittest.TestCase):
params['C'] = 'c'
bench_base = DummyBechmarkBaseClass(name, params)
self.assertEqual(name, bench_base.name)
- self.assertIn('A', bench_base.params.keys())
- self.assertIn('B', bench_base.params.keys())
+ self.assertIn('A', list(bench_base.params.keys()))
+ self.assertIn('B', list(bench_base.params.keys()))
self.assertEqual('a', bench_base.params['A'])
self.assertEqual('b', bench_base.params['B'])
diff --git a/yardstick/vTC/apexlake/tests/benchmarking_unit_test.py b/yardstick/vTC/apexlake/tests/benchmarking_unit_test.py
index 652327aab..7b33ba693 100644
--- a/yardstick/vTC/apexlake/tests/benchmarking_unit_test.py
+++ b/yardstick/vTC/apexlake/tests/benchmarking_unit_test.py
@@ -11,9 +11,12 @@
# 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 os
import unittest
import mock
+
+from experimental_framework import APEX_LAKE_ROOT
from experimental_framework.benchmarking_unit import BenchmarkingUnit
# from experimental_framework.data_manager import DataManager
from experimental_framework.deployment_unit import DeploymentUnit
@@ -275,7 +278,8 @@ class TestBenchmarkingUnit(unittest.TestCase):
mock_rfc2544, mock_log, mock_influx):
mock_heat.return_value = list()
mock_time.return_value = '12345'
- mock_temp_dir.return_value = 'tests/data/test_templates/'
+ mock_temp_dir.return_value = os.path.join(APEX_LAKE_ROOT,
+ 'tests/data/test_templates/')
common.TEMPLATE_FILE_EXTENSION = '.yaml'
common.RESULT_DIR = 'tests/data/results/'
common.INFLUXDB_IP = 'InfluxIP'
@@ -336,7 +340,8 @@ class TestBenchmarkingUnit(unittest.TestCase):
mock_log):
mock_heat.return_value = list()
mock_time.return_value = '12345'
- mock_temp_dir.return_value = 'tests/data/test_templates/'
+ mock_temp_dir.return_value = os.path.join(APEX_LAKE_ROOT,
+ 'tests/data/test_templates/')
common.TEMPLATE_FILE_EXTENSION = '.yaml'
common.RESULT_DIR = 'tests/data/results/'
diff --git a/yardstick/vTC/apexlake/tests/common_test.py b/yardstick/vTC/apexlake/tests/common_test.py
index 486ed6d25..b8dbfe6b8 100644
--- a/yardstick/vTC/apexlake/tests/common_test.py
+++ b/yardstick/vTC/apexlake/tests/common_test.py
@@ -12,13 +12,15 @@
# 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
import logging
-import ConfigParser
+import six.moves.configparser
import experimental_framework.common as common
import experimental_framework.constants.conf_file_sections as cf
+from experimental_framework import APEX_LAKE_ROOT
__author__ = 'vmricco'
@@ -47,6 +49,7 @@ def reset_common():
class DummyConfigurationFile(common.ConfigurationFile):
+
def __init__(self, sections, conf_file=''):
pass
@@ -58,6 +61,7 @@ class DummyConfigurationFile(common.ConfigurationFile):
class DummyConfigurationFile2(common.ConfigurationFile):
+
def __init__(self, sections):
self.pktgen_counter = 0
@@ -74,7 +78,7 @@ class DummyConfigurationFile2(common.ConfigurationFile):
self.pktgen_counter += 1
return 'dpdk_pktgen'
if variable_name == cf.CFSP_DPDK_PKTGEN_DIRECTORY:
- return os.getcwd()
+ return APEX_LAKE_ROOT
if variable_name == cf.CFSP_DPDK_PROGRAM_NAME:
return 'program'
if variable_name == cf.CFSP_DPDK_COREMASK:
@@ -86,7 +90,7 @@ class DummyConfigurationFile2(common.ConfigurationFile):
if variable_name == cf.CFSP_DPDK_BUS_SLOT_NIC_2:
return 'bus_slot_nic_2'
if variable_name == cf.CFSP_DPDK_DPDK_DIRECTORY:
- return os.getcwd()
+ return APEX_LAKE_ROOT
def get_variable_list(self, section):
if section == cf.CFS_PKTGEN:
@@ -114,8 +118,7 @@ class TestCommonInit(unittest.TestCase):
def setUp(self):
common.CONF_FILE = DummyConfigurationFile('')
- self.dir = '{}/{}'.format(os.getcwd(),
- 'experimental_framework/')
+ self.dir = os.path.join(APEX_LAKE_ROOT, 'experimental_framework/')
def tearDown(self):
reset_common()
@@ -131,7 +134,8 @@ class TestCommonInit(unittest.TestCase):
init_general_vars, init_conf_file, mock_getcwd):
mock_getcwd.return_value = self.dir
common.init(True)
- init_pkgen.assert_called_once()
+ if common.CONF_FILE.get_variable_list(cf.CFS_PKTGEN):
+ init_pkgen.assert_called_once()
init_conf_file.assert_called_once()
init_general_vars.assert_called_once()
init_log.assert_called_once()
@@ -144,7 +148,7 @@ class TestCommonInit(unittest.TestCase):
@mock.patch('experimental_framework.common.LOG')
def test_init_general_vars_for_success(self, mock_log, mock_makedirs,
mock_path_exists, mock_val_file):
- common.BASE_DIR = "{}/".format(os.getcwd())
+ common.BASE_DIR = APEX_LAKE_ROOT
mock_path_exists.return_value = False
mock_val_file.return_value = True
common.init_general_vars()
@@ -160,15 +164,19 @@ class TestCommonInit2(unittest.TestCase):
def setUp(self):
common.CONF_FILE = DummyConfigurationFile2('')
- self.dir = '{}/{}'.format(os.getcwd(), 'experimental_framework/')
+ self.dir = os.path.join(APEX_LAKE_ROOT, 'experimental_framework')
def tearDown(self):
reset_common()
common.CONF_FILE = None
+ @mock.patch('experimental_framework.common.InputValidation')
+ @mock.patch('os.path.exists')
+ @mock.patch('os.makedirs')
@mock.patch('experimental_framework.common.LOG')
- def test_init_general_vars_2_for_success(self, mock_log):
- common.BASE_DIR = "{}/".format(os.getcwd())
+ def test_init_general_vars_2_for_success(self, mock_log, mock_makedirs,
+ mock_path_exists, mock_val_file):
+ common.BASE_DIR = APEX_LAKE_ROOT
common.init_general_vars()
self.assertEqual(common.TEMPLATE_FILE_EXTENSION, '.yaml')
self.assertEqual(common.TEMPLATE_DIR, '/tmp/apexlake/heat_templates/')
@@ -183,14 +191,16 @@ class TestCommonInit2(unittest.TestCase):
def test_init_pktgen_for_success(self):
common.init_pktgen()
self.assertEqual(common.PKTGEN, 'dpdk_pktgen')
- directory = self.dir.split('experimental_framework/')[0]
+ directory = self.dir.split('experimental_framework')[0]
self.assertEqual(common.PKTGEN_DIR, directory)
self.assertEqual(common.PKTGEN_PROGRAM, 'program')
self.assertEqual(common.PKTGEN_COREMASK, 'coremask')
self.assertEqual(common.PKTGEN_MEMCHANNEL, 'memchannel')
self.assertEqual(common.PKTGEN_BUS_SLOT_NIC_1, 'bus_slot_nic_1')
self.assertEqual(common.PKTGEN_BUS_SLOT_NIC_2, 'bus_slot_nic_2')
- expected_dir = "{}/".format(os.getcwd())
+ # we always add '/' to end of dirs for some reason
+ # probably because we aren't using os.path.join everywhere
+ expected_dir = APEX_LAKE_ROOT + '/'
self.assertEqual(common.PKTGEN_DPDK_DIRECTORY, expected_dir)
def test_init_pktgen_for_failure(self):
@@ -260,8 +270,8 @@ class TestConfigFileClass(unittest.TestCase):
'Deployment-parameters',
'Testcase-parameters'
]
- c_file = './tests/data/common/conf.cfg'
- common.BASE_DIR = os.getcwd()
+ c_file = os.path.join(APEX_LAKE_ROOT, 'tests/data/common/conf.cfg')
+ common.BASE_DIR = APEX_LAKE_ROOT
self.conf_file = common.ConfigurationFile(self.sections, c_file)
def tearDown(self):
@@ -275,7 +285,8 @@ class TestConfigFileClass(unittest.TestCase):
sections = ['General', 'OpenStack', 'Experiment-VNF', 'PacketGen',
'Deployment-parameters', 'Testcase-parameters']
c = DummyConfigurationFile3(
- sections, config_file='./tests/data/common/conf.cfg')
+ sections, config_file=os.path.join(APEX_LAKE_ROOT,
+ 'tests/data/common/conf.cfg'))
self.assertEqual(
DummyConfigurationFile3._config_section_map('', '', True),
6)
@@ -285,8 +296,9 @@ class TestConfigFileClass(unittest.TestCase):
def test__config_section_map_for_success(self):
general_section = 'General'
# openstack_section = 'OpenStack'
- config_file = 'tests/data/common/conf.cfg'
- config = ConfigParser.ConfigParser()
+ config_file = os.path.join(APEX_LAKE_ROOT,
+ 'tests/data/common/conf.cfg')
+ config = six.moves.configparser.ConfigParser()
config.read(config_file)
expected = {
@@ -361,8 +373,9 @@ class TestCommonMethods(unittest.TestCase):
'Deployment-parameters',
'Testcase-parameters'
]
- config_file = './tests/data/common/conf.cfg'
- common.BASE_DIR = os.getcwd()
+ config_file = os.path.join(APEX_LAKE_ROOT,
+ 'tests/data/common/conf.cfg')
+ common.BASE_DIR = APEX_LAKE_ROOT
common.CONF_FILE = DummyConfigurationFile4(self.sections, config_file)
def tearDown(self):
@@ -397,13 +410,14 @@ class TestCommonMethods(unittest.TestCase):
self.assertEqual(expected, output)
def test_get_file_first_line_for_success(self):
- file = 'tests/data/common/conf.cfg'
+ file = os.path.join(APEX_LAKE_ROOT, 'tests/data/common/conf.cfg')
expected = '[General]\n'
output = common.get_file_first_line(file)
self.assertEqual(expected, output)
def test_replace_in_file_for_success(self):
- filename = 'tests/data/common/file_replacement.txt'
+ filename = os.path.join(APEX_LAKE_ROOT,
+ 'tests/data/common/file_replacement.txt')
text_to_search = 'replacement of'
text_to_replace = '***'
common.replace_in_file(filename, text_to_search, text_to_replace)
@@ -542,27 +556,14 @@ class TestinputValidation(unittest.TestCase):
list(), ''
)
- def test_validate_file_exist_for_success(self):
- filename = 'tests/data/common/file_replacement.txt'
- output = common.InputValidation.validate_file_exist(filename, '')
- self.assertTrue(output)
-
- def test_validate_file_exist_for_failure(self):
- filename = 'tests/data/common/file_replacement'
- self.assertRaises(
- ValueError,
- common.InputValidation.validate_file_exist,
- filename, ''
- )
-
def test_validate_directory_exist_and_format_for_success(self):
- directory = 'tests/data/common/'
+ directory = os.path.join(APEX_LAKE_ROOT, 'tests/data/common/')
output = common.InputValidation.\
validate_directory_exist_and_format(directory, '')
self.assertTrue(output)
def test_validate_directory_exist_and_format_for_failure(self):
- directory = 'tests/data/com/'
+ directory = os.path.join(APEX_LAKE_ROOT, 'tests/data/com/')
self.assertRaises(
ValueError,
common.InputValidation.validate_directory_exist_and_format,
diff --git a/yardstick/vTC/apexlake/tests/conf_file_sections_test.py b/yardstick/vTC/apexlake/tests/conf_file_sections_test.py
index 2b03edb04..abf4134a5 100644
--- a/yardstick/vTC/apexlake/tests/conf_file_sections_test.py
+++ b/yardstick/vTC/apexlake/tests/conf_file_sections_test.py
@@ -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
from experimental_framework.constants import conf_file_sections as cfs
diff --git a/yardstick/vTC/apexlake/tests/deployment_unit_test.py b/yardstick/vTC/apexlake/tests/deployment_unit_test.py
index cec834e56..5a9178f53 100644
--- a/yardstick/vTC/apexlake/tests/deployment_unit_test.py
+++ b/yardstick/vTC/apexlake/tests/deployment_unit_test.py
@@ -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 logging
import mock
diff --git a/yardstick/vTC/apexlake/tests/dpdk_packet_generator_test.py b/yardstick/vTC/apexlake/tests/dpdk_packet_generator_test.py
index bad250e7b..0b0df6c2b 100644
--- a/yardstick/vTC/apexlake/tests/dpdk_packet_generator_test.py
+++ b/yardstick/vTC/apexlake/tests/dpdk_packet_generator_test.py
@@ -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
from experimental_framework.constants import conf_file_sections as conf_file
diff --git a/yardstick/vTC/apexlake/tests/generates_template_test.py b/yardstick/vTC/apexlake/tests/generates_template_test.py
index dad3177d6..cc3e1bf6e 100644
--- a/yardstick/vTC/apexlake/tests/generates_template_test.py
+++ b/yardstick/vTC/apexlake/tests/generates_template_test.py
@@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import absolute_import
import unittest
import experimental_framework.heat_template_generation as heat_gen
import mock
import os
import experimental_framework.common as common
+from experimental_framework import APEX_LAKE_ROOT
__author__ = 'gpetralx'
@@ -45,6 +47,7 @@ def reset_common():
class TestGeneratesTemplate(unittest.TestCase):
+
def setUp(self):
self.deployment_configuration = {
'vnic_type': ['normal', 'direct'],
@@ -61,9 +64,11 @@ class TestGeneratesTemplate(unittest.TestCase):
@mock.patch('experimental_framework.common.get_template_dir')
def test_generates_template_for_success(self, mock_template_dir,
mock_log):
- generated_templates_dir = 'tests/data/generated_templates/'
+ generated_templates_dir = os.path.join(
+ APEX_LAKE_ROOT, 'tests/data/generated_templates/')
mock_template_dir.return_value = generated_templates_dir
- test_templates = 'tests/data/test_templates/'
+ test_templates = os.path.join(APEX_LAKE_ROOT,
+ 'tests/data/test_templates/')
heat_gen.generates_templates(self.template_name,
self.deployment_configuration)
for dirname, dirnames, filenames in os.walk(test_templates):
@@ -73,8 +78,9 @@ class TestGeneratesTemplate(unittest.TestCase):
self.assertListEqual(test.readlines(),
generated.readlines())
- t_name = '/tests/data/generated_templates/VTC_base_single_vm_wait.tmp'
- self.template_name = "{}{}".format(os.getcwd(), t_name)
+ self.template_name = os.path.join(
+ APEX_LAKE_ROOT,
+ 'tests/data/generated_templates/VTC_base_single_vm_wait.tmp')
heat_gen.generates_templates(self.template_name,
self.deployment_configuration)
for dirname, dirnames, filenames in os.walk(test_templates):
@@ -86,7 +92,8 @@ class TestGeneratesTemplate(unittest.TestCase):
@mock.patch('experimental_framework.common.get_template_dir')
def test_get_all_heat_templates_for_success(self, template_dir):
- generated_templates = 'tests/data/generated_templates/'
+ generated_templates = os.path.join(APEX_LAKE_ROOT,
+ 'tests/data/generated_templates/')
template_dir.return_value = generated_templates
extension = '.yaml'
expected = ['experiment_1.yaml', 'experiment_2.yaml']
diff --git a/yardstick/vTC/apexlake/tests/heat_manager_test.py b/yardstick/vTC/apexlake/tests/heat_manager_test.py
index 0fe8554cd..58bd75560 100644
--- a/yardstick/vTC/apexlake/tests/heat_manager_test.py
+++ b/yardstick/vTC/apexlake/tests/heat_manager_test.py
@@ -12,11 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import print_function
+
+from __future__ import absolute_import
+import os
import unittest
import logging
import experimental_framework.common as common
-from experimental_framework import heat_manager
+from experimental_framework import heat_manager, APEX_LAKE_ROOT
import mock
__author__ = 'gpetralx'
@@ -27,6 +31,7 @@ def get_mock_heat(version, *args, **kwargs):
class MockStacks(object):
+
def __init__(self, stacks):
self.stacks = stacks
@@ -34,7 +39,7 @@ class MockStacks(object):
list_name = list()
for stack in self.stacks:
list_name.append(stack.stack_name)
- print list_name
+ print(list_name)
return self.stacks
def validate(self, template=None):
@@ -47,11 +52,12 @@ class MockStacks(object):
def create(self, stack_name=None, files=None, template=None,
parameters=None):
- print stack_name
+ print(stack_name)
self.stacks.append(MockStack(stack_name))
class MockStacks_2(object):
+
def __init__(self, stacks):
self.stacks = stacks
@@ -60,6 +66,7 @@ class MockStacks_2(object):
class MockStack(object):
+
def __init__(self, stack_name):
self.name = stack_name
@@ -80,6 +87,7 @@ class MockStack(object):
class MockHeat(object):
+
def __init__(self):
stacks = [MockStack('stack_1'), MockStack('stack_2')]
self.stacks_list = MockStacks(stacks)
@@ -90,18 +98,21 @@ class MockHeat(object):
class MockHeat_2(MockHeat):
+
def __init__(self):
stacks = [MockStack('stack_1'), MockStack('stack_2')]
self.stacks_list = MockStacks_2(stacks)
class HeatManagerMock(heat_manager.HeatManager):
+
def init_heat(self):
if self.heat is None:
self.heat = MockHeat()
class HeatManagerMock_2(heat_manager.HeatManager):
+
def init_heat(self):
if self.heat is None:
self.heat = MockHeat_2()
@@ -134,8 +145,9 @@ class TestHeatManager(unittest.TestCase):
self.heat_manager.check_stack_status('stack_x'))
def test_validate_template_for_success(self):
- template_file = \
- 'tests/data/test_templates/VTC_base_single_vm_wait_1.yaml'
+ template_file = os.path.join(
+ APEX_LAKE_ROOT,
+ 'tests/data/test_templates/VTC_base_single_vm_wait_1.yaml')
with self.assertRaises(ValueError):
self.heat_manager.validate_heat_template(template_file)
@@ -180,11 +192,13 @@ class TestHeatManager_2(unittest.TestCase):
class ServiceCatalog():
+
def url_for(self, service_type):
return 'http://heat_url'
class KeystoneMock(object):
+
@property
def auth_token(self):
return 'token'
@@ -193,6 +207,7 @@ class KeystoneMock(object):
class TestHeatInit(unittest.TestCase):
+
def setUp(self):
credentials = dict()
credentials['ip_controller'] = '1.1.1.1'
@@ -216,5 +231,5 @@ class TestHeatInit(unittest.TestCase):
tenant_name='project',
password='password',
auth_url='auth_uri')
- heat_client.assert_called_once_with('1', endpoint='http://heat_url',
+ heat_client.assert_called_once_with('1', endpoint='http://heat_url',
token='token')
diff --git a/yardstick/vTC/apexlake/tests/instantiation_validation_bench_test.py b/yardstick/vTC/apexlake/tests/instantiation_validation_bench_test.py
index 369129a00..2bd8b7b38 100644
--- a/yardstick/vTC/apexlake/tests/instantiation_validation_bench_test.py
+++ b/yardstick/vTC/apexlake/tests/instantiation_validation_bench_test.py
@@ -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'
diff --git a/yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py b/yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py
index f65600f6e..f9aa9473f 100644
--- a/yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py
+++ b/yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py
@@ -12,13 +12,17 @@
# 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
+
+from six.moves import range
+
import experimental_framework.common as common
import experimental_framework.deployment_unit as deploy
import experimental_framework.benchmarks.\
instantiation_validation_noisy_neighbors_benchmark as mut
+from experimental_framework import APEX_LAKE_ROOT
class InstantiationValidationInitTest(unittest.TestCase):
@@ -34,7 +38,7 @@ class InstantiationValidationInitTest(unittest.TestCase):
openstack_credentials['heat_url'] = ''
openstack_credentials['password'] = ''
common.DEPLOYMENT_UNIT = deploy.DeploymentUnit(openstack_credentials)
- common.BASE_DIR = os.getcwd()
+ common.BASE_DIR = APEX_LAKE_ROOT
common.TEMPLATE_DIR = 'tests/data/generated_templates'
self.iv = mut.\
InstantiationValidationNoisyNeighborsBenchmark(name, params)
@@ -72,9 +76,11 @@ class InstantiationValidationInitTest(unittest.TestCase):
expected['parameters'].append(mut.NUM_OF_NEIGHBORS)
expected['parameters'].append(mut.AMOUNT_OF_RAM)
expected['parameters'].append(mut.NUMBER_OF_CORES)
- expected['allowed_values']['throughput'] = map(str, range(0, 100))
- expected['allowed_values']['vlan_sender'] = map(str, range(-1, 4096))
- expected['allowed_values']['vlan_receiver'] = map(str, range(-1, 4096))
+ expected['allowed_values']['throughput'] = [str(x) for x in range(100)]
+ expected['allowed_values']['vlan_sender'] = [str(x) for x in
+ range(-1, 4096)]
+ expected['allowed_values']['vlan_receiver'] = [str(x) for x in
+ range(-1, 4096)]
expected['allowed_values'][mut.NUM_OF_NEIGHBORS] = \
['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
expected['allowed_values'][mut.NUMBER_OF_CORES] = \
@@ -115,10 +121,10 @@ class InstantiationValidationInitTest(unittest.TestCase):
'num_of_neighbours': 1}
self.iv.template_file = 'template.yaml'
self.iv.init()
- mock_replace.assert_called_once_wih('file',
- 'local out_file = ""',
- 'local out_file = "' +
- 'res_file' + '"')
+ mock_replace.assert_called_once_with('file',
+ 'local out_file = ""',
+ 'local out_file = "' +
+ 'res_file' + '"')
mock_deploy_heat.assert_called_once_with('template.yaml',
'neighbour0',
{'cores': 1,
@@ -131,12 +137,14 @@ class InstantiationValidationInitTest(unittest.TestCase):
@mock.patch('experimental_framework.common.'
'DEPLOYMENT_UNIT.destroy_heat_template')
def test_finalize_for_success(self, mock_heat_destroy, mock_replace):
+ self.iv.lua_file = 'file'
+ self.iv.results_file = 'res_file'
self.iv.neighbor_stack_names = ['neighbor0']
stack_name = 'neighbor0'
self.iv.finalize()
mock_heat_destroy.assert_called_once_with(stack_name)
- mock_replace.assert_called_once_wih('file',
- 'local out_file = ""',
- 'local out_file = "' +
- 'res_file' + '"')
+ mock_replace.assert_called_once_with('file',
+ 'local out_file = "' +
+ 'res_file' + '"',
+ 'local out_file = ""')
self.assertEqual(self.iv.neighbor_stack_names, list())
diff --git a/yardstick/vTC/apexlake/tests/multi_tenancy_throughput_benchmark_test.py b/yardstick/vTC/apexlake/tests/multi_tenancy_throughput_benchmark_test.py
index fc5a7fddb..39b38d7d3 100644
--- a/yardstick/vTC/apexlake/tests/multi_tenancy_throughput_benchmark_test.py
+++ b/yardstick/vTC/apexlake/tests/multi_tenancy_throughput_benchmark_test.py
@@ -12,17 +12,20 @@
# 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
import experimental_framework.common as common
from experimental_framework.benchmarks \
import multi_tenancy_throughput_benchmark as bench
+from six.moves import range
__author__ = 'gpetralx'
class MockDeploymentUnit(object):
+
def deploy_heat_template(self, temp_file, stack_name, heat_param):
pass
@@ -35,6 +38,7 @@ def get_deployment_unit():
class TestMultiTenancyThroughputBenchmark(unittest.TestCase):
+
def setUp(self):
name = 'benchmark'
params = dict()
@@ -47,9 +51,9 @@ class TestMultiTenancyThroughputBenchmark(unittest.TestCase):
def test_get_features_for_sanity(self):
output = self.benchmark.get_features()
self.assertIsInstance(output, dict)
- self.assertIn('parameters', output.keys())
- self.assertIn('allowed_values', output.keys())
- self.assertIn('default_values', output.keys())
+ self.assertIn('parameters', list(output.keys()))
+ self.assertIn('allowed_values', list(output.keys()))
+ self.assertIn('default_values', list(output.keys()))
self.assertIsInstance(output['parameters'], list)
self.assertIsInstance(output['allowed_values'], dict)
self.assertIsInstance(output['default_values'], dict)
diff --git a/yardstick/vTC/apexlake/tests/rfc2544_throughput_benchmark_test.py b/yardstick/vTC/apexlake/tests/rfc2544_throughput_benchmark_test.py
index ef3b0dabb..487de7775 100644
--- a/yardstick/vTC/apexlake/tests/rfc2544_throughput_benchmark_test.py
+++ b/yardstick/vTC/apexlake/tests/rfc2544_throughput_benchmark_test.py
@@ -13,6 +13,7 @@
# limitations under the License.
+from __future__ import absolute_import
import unittest
import mock
import os
@@ -37,9 +38,9 @@ class RFC2544ThroughputBenchmarkRunTest(unittest.TestCase):
def test_get_features_for_sanity(self):
output = self.benchmark.get_features()
self.assertIsInstance(output, dict)
- self.assertIn('parameters', output.keys())
- self.assertIn('allowed_values', output.keys())
- self.assertIn('default_values', output.keys())
+ self.assertIn('parameters', list(output.keys()))
+ self.assertIn('allowed_values', list(output.keys()))
+ self.assertIn('default_values', list(output.keys()))
self.assertIsInstance(output['parameters'], list)
self.assertIsInstance(output['allowed_values'], dict)
self.assertIsInstance(output['default_values'], dict)
@@ -74,7 +75,6 @@ class RFC2544ThroughputBenchmarkRunTest(unittest.TestCase):
output = self.benchmark.run()
self.assertEqual(expected, output)
conf_lua_file_mock.assert_called_once()
- reset_lua_file_mock.assert_called_once()
dpdk_instance = mock_dpdk()
dpdk_instance.init_dpdk_pktgen.assert_called_once_with(
dpdk_interfaces=2, pcap_file_0='packet_1.pcap',
diff --git a/yardstick/vTC/apexlake/tests/tree_node_test.py b/yardstick/vTC/apexlake/tests/tree_node_test.py
index e51343f0e..fb38b69bd 100644
--- a/yardstick/vTC/apexlake/tests/tree_node_test.py
+++ b/yardstick/vTC/apexlake/tests/tree_node_test.py
@@ -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 experimental_framework.heat_template_generation as heat_gen
@@ -19,6 +20,7 @@ __author__ = 'gpetralx'
class TestTreeNode(unittest.TestCase):
+
def setUp(self):
self.tree = heat_gen.TreeNode()