summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliyin <liyin11@huawei.com>2017-02-07 15:29:50 +0800
committerAce Lee <liyin11@huawei.com>2017-02-09 05:10:52 +0000
commit0a29e9ec59e21dc46db0497187cc9d0de0844b05 (patch)
tree5222fd128df289fa3f6e56621c1a8af273e1eab3
parentfd7583e843493495e5e15f62b5f7d9ca484bf167 (diff)
Log_dir bug fix&Add function of test_ip init
JIRA:BOTTLENECK-129 This patch fix the error of log_dir can't be found. And change several thing: 1.Add if config don't have test_ip, it will use local:8888 as test ip. 2.Fix the bug in setup.py. 3.Add parser init to logger file. Change-Id: I808c69e2b2ff3c04f271cc7f3e14e1ab406a4d1b Signed-off-by: liyin <liyin11@huawei.com>
-rw-r--r--config/__init__.py8
-rw-r--r--setup.py60
-rw-r--r--testsuites/posca/__init__.py1
-rwxr-xr-xtestsuites/posca/run_posca.py11
-rw-r--r--testsuites/posca/testcase_script/posca_factor_system_bandwidth.py17
-rw-r--r--utils/logger.py5
-rw-r--r--utils/parser.py12
7 files changed, 61 insertions, 53 deletions
diff --git a/config/__init__.py b/config/__init__.py
new file mode 100644
index 00000000..b124dfa9
--- /dev/null
+++ b/config/__init__.py
@@ -0,0 +1,8 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
diff --git a/setup.py b/setup.py
index d9852c95..5e32b238 100644
--- a/setup.py
+++ b/setup.py
@@ -7,38 +7,40 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-'''This file realize the function of how to setup bottlenecks to your environment
-This use setuptools tool to setup'''
+'''This file realize the function of how to setup bottlenecks
+to your environment. This use setuptools tool to setup'''
from setuptools import setup, find_packages
setup(
- name="bottlenecks",
- version="master",
- py_modules=['bottlenecks_cli'],
- packages=find_packages(),
- include_package_data=True,
- package_data={
- 'utils': [
- 'utils/infra_setup/heat/*.py',
- 'utils/infra_setup/runner/*.py'
- ],
- 'config': [
- '*.yaml'
- ],
- 'testsuites': [
- 'posca/testcase_cfg/*',
- 'posca/testcase_script/*',
- 'posca/testsuite_story/*',
- 'posca/testcase_dashboard/*'
- ],
- },
- url="https://www.opnfv.org",
- install_requires=["click"],
- entry_points={
- 'console_scripts': [
- 'bottlenecks=cli.bottlenecks_cli:main'
- ],
- },
+ name="bottlenecks",
+ version="master",
+ py_modules=['bottlenecks_cli'],
+ packages=find_packages(),
+ include_package_data=True,
+ package_data={
+ 'utils': [
+ 'utils/infra_setup/heat/*.py',
+ 'utils/infra_setup/runner/*.py',
+ 'utils/*.py'
+ ],
+ 'config': [
+ '*.yaml'
+ ],
+ 'testsuites': [
+ 'posca/testcase_cfg/*',
+ 'posca/testcase_script/*',
+ 'posca/testsuite_story/*',
+ 'posca/testcase_dashboard/*'
+ ],
+ },
+ url="https://www.opnfv.org",
+ install_requires=["click"],
+ entry_points={
+ 'console_scripts': [
+ 'bottlenecks=cli.bottlenecks_cli:main'
+ ],
+ },
)
+
diff --git a/testsuites/posca/__init__.py b/testsuites/posca/__init__.py
index efcda782..b124dfa9 100644
--- a/testsuites/posca/__init__.py
+++ b/testsuites/posca/__init__.py
@@ -6,4 +6,3 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
diff --git a/testsuites/posca/run_posca.py b/testsuites/posca/run_posca.py
index fcf35d5b..a687e00e 100755
--- a/testsuites/posca/run_posca.py
+++ b/testsuites/posca/run_posca.py
@@ -39,15 +39,9 @@ def posca_run(test_level, test_name):
elif test_level == "teststory":
config = conf_parser.Parser.story_read("posca", test_name)
for testcase in config:
- print(config[testcase])
+ LOG.info("Begin to run %s testcase in POSCA testsuite", testcase)
posca_testcase_run(testcase, config[testcase])
- if con_dic["dashboard"] == "y":
- cmd = '/home/opnfv/bottlenecks/testsuites/posca/testcase_dashboard/\
-system_bandwidth.py'
- pargs = [INTERPRETER, cmd]
- LOG.info("\nBegin to establish dashboard.")
- sub_result = subprocess.Popen(pargs)
- sub_result.wait()
+ LOG.info("End of %s testcase in POSCA testsuite", testcase)
def main():
@@ -58,4 +52,3 @@ def main():
if __name__ == '__main__':
main()
-
diff --git a/testsuites/posca/testcase_script/posca_factor_system_bandwidth.py b/testsuites/posca/testcase_script/posca_factor_system_bandwidth.py
index ed4de180..aebfa962 100644
--- a/testsuites/posca/testcase_script/posca_factor_system_bandwidth.py
+++ b/testsuites/posca/testcase_script/posca_factor_system_bandwidth.py
@@ -16,10 +16,11 @@ import os
import time
import utils.logger as log
import utils.infra_setup.runner.yardstick as Runner
+from utils.parser import Parser as conf_parser
# --------------------------------------------------
# logging configuration
# --------------------------------------------------
-LOG = log.Logger(__name__)
+LOG = log.Logger(__name__).getLogger()
test_dict = {
"action": "runTestCase",
@@ -41,7 +42,7 @@ def do_test(test_config, con_dic):
Task_id = Runner.Send_Data(test_dict, con_dic['runner_config'])
time.sleep(con_dic['test_config']['test_time'])
Data_Reply = Runner.Get_Reply(con_dic['runner_config'], Task_id)
- test_date = Data_Reply[con_dic['runner_config']['testcase']][0]
+ test_date = Data_Reply[con_dic['runner_config']['yardstick_testcase']][0]
return test_date
@@ -60,6 +61,9 @@ def run(con_dic):
data_return = {}
data_max = {}
data_return["throughput"] = 1
+ if con_dic["runner_config"]["yardstick_test_ip"] is None:
+ con_dic["runner_config"]["yardstick_test_ip"] =\
+ conf_parser.ip_parser("yardstick_test_ip")
for test_x in data["tx_pkt_sizes"]:
data_max["throughput"] = 1
bandwidth_tmp = 1
@@ -88,12 +92,3 @@ def run(con_dic):
pre_role_result = cur_role_result
print("date_id is %d,id return success\n" % date_id)
return data_return
-
-
-def main():
- run(con_dic)
-
-
-if __name__ == '__main__':
- main()
-
diff --git a/utils/logger.py b/utils/logger.py
index 80392f59..5ce64238 100644
--- a/utils/logger.py
+++ b/utils/logger.py
@@ -19,7 +19,8 @@
import logging
import os
-from utils.parser import Parser as conf
+from utils.parser import Parser as conf_parser
+conf_parser.config_init()
class Logger:
@@ -47,7 +48,7 @@ class Logger:
ch.setLevel(logging.INFO)
self.logger.addHandler(ch)
- result_path = conf.bottlenecks_config["log_dir"]
+ result_path = conf_parser.bottlenecks_config["log_dir"]
if not os.path.exists(result_path):
os.makedirs(result_path)
result_file = os.path.join(result_path, 'bottlenecks.log')
diff --git a/utils/parser.py b/utils/parser.py
index 7b1f4e2e..a9098a98 100644
--- a/utils/parser.py
+++ b/utils/parser.py
@@ -14,6 +14,7 @@ Second is reading config file.'''
import os
import yaml
+from pyroute2 import IPDB
class Parser():
@@ -82,6 +83,16 @@ class Parser():
# TO-DO add cli parameters to stack_config.
return test_cfg, stack_cfg
+ @staticmethod
+ def ip_parser(ip_type):
+ with IPDB() as ip:
+ GATEWAY_IP = ip.routes['default'].gateway
+ if ip_type is "dashboard":
+ TEST_IP = GATEWAY_IP + ":9200"
+ elif ip_type is "yardstick_test_ip":
+ TEST_IP = GATEWAY_IP + ":8888"
+ return TEST_IP
+
class HeatTemplate_Parser():
"""parser a Heat template and a method to deploy template to a stack"""
@@ -282,4 +293,3 @@ class HeatTemplate_Parser():
def get_template_date(self):
return self.heat_date
-