summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/posca/testcase_cfg/posca_factor_ping.yaml10
-rw-r--r--testsuites/posca/testcase_script/posca_factor_ping.py70
-rw-r--r--[-rwxr-xr-x]testsuites/run_testsuite.py (renamed from testsuites/posca/run_posca.py)38
3 files changed, 75 insertions, 43 deletions
diff --git a/testsuites/posca/testcase_cfg/posca_factor_ping.yaml b/testsuites/posca/testcase_cfg/posca_factor_ping.yaml
index 7e6bf027..ed1e3475 100644
--- a/testsuites/posca/testcase_cfg/posca_factor_ping.yaml
+++ b/testsuites/posca/testcase_cfg/posca_factor_ping.yaml
@@ -19,13 +19,13 @@ load_manager:
num_stack: 5, 10, 20
package_loss: 10%
- contexts:
+ runners:
stack_create: yardstick
flavor:
- yardstick_test_ip:
yardstick_test_dir: "samples"
yardstick_testcase: "ping_bottlenecks"
-dashboard:
- dashboard: "y"
- dashboard_ip:
+contexts:
+ dashboard: "Bottlenecks-ELK"
+ yardstick: "Bottlenecks-Yardstick"
+ yardstick_envpre: True
diff --git a/testsuites/posca/testcase_script/posca_factor_ping.py b/testsuites/posca/testcase_script/posca_factor_ping.py
index 732422ea..5f56cdae 100644
--- a/testsuites/posca/testcase_script/posca_factor_ping.py
+++ b/testsuites/posca/testcase_script/posca_factor_ping.py
@@ -15,13 +15,15 @@ import utils.logger as log
import uuid
import json
import os
+import time
import multiprocessing
-import docker
import datetime
from utils.parser import Parser as conf_parser
import utils.env_prepare.quota_prepare as quota_prepare
import utils.env_prepare.stack_prepare as stack_prepare
+
import testsuites.posca.testcase_dashboard.posca_stress_ping as DashBoard
+import utils.infra_setup.runner.docker_env as docker_env
# --------------------------------------------------
# logging configuration
# --------------------------------------------------
@@ -40,34 +42,44 @@ testfile = os.path.basename(__file__)
testcase, file_format = os.path.splitext(testfile)
-def env_pre(con_dic):
- stack_prepare._prepare_env_daemon()
+def env_pre(test_config):
+ test_yardstick = False
+ if "yardstick" in test_config["contexts"].keys():
+ test_yardstick = True
+ stack_prepare._prepare_env_daemon(test_yardstick)
quota_prepare.quota_env_prepare()
- client = docker.from_env()
- con = client.containers.get('bottleneckcompose_yardstick_1')
cmd = ('yardstick env prepare')
LOG.info("yardstick envrionment prepare!")
- stdout = con.exec_run(cmd)
- LOG.debug(stdout)
+ if(test_config["contexts"]['yardstick_envpre']):
+ yardstick_container = docker_env.yardstick_info['container']
+ stdout = docker_env.docker_exec_cmd(yardstick_container, cmd)
+ LOG.debug(stdout)
def do_test(test_config, con_dic):
out_file = ("/tmp/yardstick_" + str(uuid.uuid4()) + ".out")
- client = docker.from_env()
- con = client.containers.get('bottleneckcompose_yardstick_1')
+ yardstick_container = docker_env.yardstick_info['container']
cmd = ('yardstick task start /home/opnfv/repos/yardstick/'
'samples/ping_bottlenecks.yaml --output-file ' + out_file)
- stdout = con.exec_run(cmd)
- LOG.debug(stdout)
- with open(out_file) as f:
- data = json.load(f)
- if data["status"] == 1:
- LOG.info("yardstick run success")
- out_value = 1
- else:
- LOG.error("yardstick error exit")
- out_value = 0
- os.remove(out_file)
+ stdout = docker_env.docker_exec_cmd(yardstick_container, cmd)
+ LOG.info(stdout)
+ out_value = 0
+ loop_walue = 0
+ while loop_walue < 150:
+ time.sleep(2)
+ with open(out_file) as f:
+ loop_walue = loop_walue + 1
+ data = json.load(f)
+ if data["status"] == 1:
+ if data["result"]["criteria"] == "PASS":
+ LOG.info("yardstick run success")
+ out_value = 1
+ else:
+ LOG.error("task error exit")
+ out_value = 0
+ break
+ elif data["status"] == 2:
+ LOG.error("yardstick error exit")
return out_value
@@ -92,19 +104,19 @@ def func_run(condic):
def run(test_config):
con_dic = test_config["load_manager"]
test_num = con_dic['scenarios']['num_stack'].split(',')
- if con_dic["contexts"]["yardstick_test_ip"] is None:
- con_dic["contexts"]["yardstick_test_ip"] =\
+ if test_config["contexts"]["yardstick_ip"] is None:
+ con_dic["contexts"]["yardstick_ip"] =\
conf_parser.ip_parser("yardstick_test_ip")
- if test_config["dashboard"]["dashboard"] == 'y':
- if test_config["dashboard"]["dashboard_ip"] is None:
- test_config["dashboard"]["dashboard_ip"] =\
+ if "dashboard" in test_config["contexts"].keys():
+ if test_config["contexts"]["dashboard_ip"] is None:
+ test_config["contexts"]["dashboard_ip"] =\
conf_parser.ip_parser("dashboard")
LOG.info("Create Dashboard data")
- DashBoard.posca_stress_ping(test_config["dashboard"])
+ DashBoard.posca_stress_ping(test_config["contexts"])
LOG.info("bottlenecks envrionment prepare!")
- env_pre(con_dic)
+ env_pre(test_config)
LOG.info("yardstick envrionment prepare done!")
for value in test_num:
@@ -127,8 +139,8 @@ def run(test_config):
during_date = (endtime - starttime).seconds
data_reply = config_to_result(num, out_num, during_date)
- if test_config['dashboard']['dashboard'] == 'y':
- DashBoard.dashboard_send_data(test_config['dashboard'], data_reply)
+ if "dashboard" in test_config["contexts"].keys():
+ DashBoard.dashboard_send_data(test_config['contexts'], data_reply)
conf_parser.result_to_file(data_reply, test_config["out_file"])
if out_num < num:
diff --git a/testsuites/posca/run_posca.py b/testsuites/run_testsuite.py
index b1dba140..7ec67eff 100755..100644
--- a/testsuites/posca/run_posca.py
+++ b/testsuites/run_testsuite.py
@@ -7,7 +7,7 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-'''This file realize the function of how to run posca.
+'''This file realize the function of how to run testsuite.
In this file, The first thing is to read testcase config
for example: you could run this by use
posca_run('testcase', "Which testcase you will run")
@@ -21,11 +21,13 @@ import os
from oslo_serialization import jsonutils
import json
+import time
import requests
import datetime
import utils.parser as conf_parser
import utils.logger as log
+import utils.infra_setup.runner.docker_env as docker_env
INTERPRETER = "/usr/bin/python"
LOG = log.Logger(__name__).getLogger()
@@ -34,9 +36,10 @@ LOG = log.Logger(__name__).getLogger()
# ------------------------------------------------------
-def posca_testcase_run(testcase_script, test_config):
+def posca_testcase_run(testsuite, testcase_script, test_config):
- module_string = "testsuites.posca.testcase_script.%s" % (testcase_script)
+ module_string = "testsuites.%s.testcase_script.%s" % (testsuite,
+ testcase_script)
module = importlib.import_module(module_string)
module.run(test_config)
@@ -73,20 +76,37 @@ def report(testcase, start_date, stop_date, criteria, details_doc):
LOG.exception('Failed to record result data: %s', err)
-def posca_run(test_level, test_name, REPORT="False"):
+def docker_env_prepare(config):
+ if 'contexts' in config.keys() and config["contexts"] is not None:
+ context_config = config["contexts"]
+ if 'yardstick' in context_config.keys() and \
+ context_config["yardstick"] is not None:
+ docker_env.env_yardstick(context_config['yardstick'])
+ conf_parser.Parser.convert_docker_env(config, "yardstick")
+ if 'dashboard' in context_config.keys() and \
+ context_config["dashboard"] is not None:
+ docker_env.env_elk(context_config['dashboard'])
+ conf_parser.Parser.convert_docker_env(config, "dashboard")
+ LOG.debug('Waiting for ELK init')
+ time.sleep(15)
+ return
+
+
+def testsuite_run(test_level, test_name, REPORT="False"):
+ tester_parser = test_name.split("_")
if test_level == "testcase":
- config = conf_parser.Parser.testcase_read("posca", test_name)
+ config = conf_parser.Parser.testcase_read(tester_parser[0], test_name)
elif test_level == "teststory":
- config = conf_parser.Parser.story_read("posca", test_name)
+ config = conf_parser.Parser.story_read(tester_parser[0], test_name)
for testcase in config:
LOG.info("Begin to run %s testcase in POSCA testsuite", testcase)
config[testcase]['out_file'] =\
conf_parser.Parser.testcase_out_dir(testcase)
start_date = datetime.datetime.now()
- posca_testcase_run(testcase, config[testcase])
+ docker_env_prepare(config[testcase])
+ posca_testcase_run(tester_parser[0], testcase, config[testcase])
stop_date = datetime.datetime.now()
LOG.info("End of %s testcase in POSCA testsuite", testcase)
-
criteria = "FAIL"
if REPORT == "True":
details_doc = []
@@ -102,7 +122,7 @@ def main():
test_level = sys.argv[1]
test_name = sys.argv[2]
REPORT = sys.argv[3]
- posca_run(test_level, test_name, REPORT)
+ testsuite_run(test_level, test_name, REPORT)
if __name__ == '__main__':