summaryrefslogtreecommitdiffstats
path: root/testsuites/posca/testcase_script
diff options
context:
space:
mode:
authorliyin <liyin11@huawei.com>2017-02-18 22:24:18 +0800
committerAce Lee <liyin11@huawei.com>2017-02-20 11:00:13 +0000
commitbffdc13b667abc6eb8bccdcc1aa82cf963a5dfa8 (patch)
treeb8fdcc9be40e622e5a8a1ddb859eb03a53b10cbc /testsuites/posca/testcase_script
parent58c97253eaaf72f73924837fca4ddcb5cb8a5d94 (diff)
stress_test_dashboard_code
JIRA:BOTTLENECK-138 Those codes will create dashboard for stress test. And we have fixed a bug, that we will increace env prepare in this patch besides: we also add some code of how to yardstick api. Change-Id: I64bb249ee0df9fe37e998a784ba346719bf25197 Signed-off-by: liyin <liyin11@huawei.com>
Diffstat (limited to 'testsuites/posca/testcase_script')
-rw-r--r--testsuites/posca/testcase_script/posca_stress_ping.py46
1 files changed, 43 insertions, 3 deletions
diff --git a/testsuites/posca/testcase_script/posca_stress_ping.py b/testsuites/posca/testcase_script/posca_stress_ping.py
index abf8044a..02244a37 100644
--- a/testsuites/posca/testcase_script/posca_stress_ping.py
+++ b/testsuites/posca/testcase_script/posca_stress_ping.py
@@ -16,9 +16,11 @@ import uuid
import json
import os
import multiprocessing
+import docker
+import datetime
import utils.infra_setup.runner.yardstick as Runner
from utils.parser import Parser as conf_parser
-import docker
+import testsuites.posca.testcase_dashboard.posca_stress_ping as DashBoard
# --------------------------------------------------
# logging configuration
# --------------------------------------------------
@@ -33,10 +35,16 @@ test_dict = {
"testcase": "ping_bottlenecks"
}
}
+testfile = os.path.basename(__file__)
+testcase, file_format = os.path.splitext(testfile)
def env_pre(con_dic):
- Runner.yardstick_env_prepare(con_dic['contexts'])
+ client = docker.from_env()
+ con = client.containers.get('bottleneckcompose_yardstick_1')
+ cmd = ('yardstick env prepare')
+ stdout = con.exec_run(cmd)
+ LOG.debug(stdout)
def do_test(test_config, con_dic):
@@ -59,6 +67,18 @@ def do_test(test_config, con_dic):
return out_value
+def config_to_result(num, out_num, during_date):
+ testdata = {}
+ test_result = {}
+ test_result["number_of_users"] = float(num)
+ test_result["success_times"] = out_num
+ test_result["success_rate"] = out_num / num
+ test_result["duration_time"] = during_date
+ testdata["data_body"] = test_result
+ testdata["testcase"] = testcase
+ return testdata
+
+
def func_run(condic):
test_config = {}
test_date = do_test(test_config, condic)
@@ -72,19 +92,39 @@ def run(test_config):
con_dic["contexts"]["yardstick_test_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"] =\
+ conf_parser.ip_parser("dashboard")
+ LOG.info("Create Dashboard data")
+ DashBoard.posca_stress_ping(test_config["dashboard"])
+
+ LOG.info("yardstick envrionment prepare!")
env_pre(con_dic)
- for num in test_num:
+ for value in test_num:
result = []
out_num = 0
+ num = int(value)
pool = multiprocessing.Pool(processes=num)
+
+ starttime = datetime.datetime.now()
for i in range(0, int(num)):
result.append(pool.apply_async(func_run, (con_dic, )))
pool.close()
pool.join()
for res in result:
out_num = out_num + float(res.get())
+
+ endtime = datetime.datetime.now()
LOG.info("%s thread success %d times" % (num, out_num))
+ 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)
+ conf_parser.result_to_file(data_reply, test_config["out_file"])
+
if out_num < num:
success_rate = ('%d/%d' % (out_num, num))
LOG.error('error thread: %d '