+def testcase_parser(out_file="yardstick.out", **parameter_info):
+ cmd = ('yardstick task start /home/opnfv/repos/yardstick/'
+ 'samples/netperf_bottlenecks.yaml --output-file ' + out_file)
+ cmd = cmd + " --task-args " + '"' + str(parameter_info) + '"'
+ LOG.info("yardstick test cmd is: %s" % cmd)
+ return cmd
+
+
+def do_test(test_config, Use_Dashboard, context_conf):
+ yardstick_container = docker_env.yardstick_info['container']
+ out_file = ("/tmp/yardstick_" + str(uuid.uuid4()) + ".out")
+ cmd = testcase_parser(out_file=out_file, **test_config)
+ stdout = docker_env.docker_exec_cmd(yardstick_container, cmd)
+ LOG.info(stdout)
+ loop_value = 0
+ while loop_value < 60:
+ time.sleep(2)
+ loop_value = loop_value + 1
+ with open(out_file) as f:
+ data = json.load(f)
+ if data["status"] == 1:
+ LOG.info("yardstick run success")
+ break
+ elif data["status"] == 2:
+ LOG.error("yardstick error exit")
+ exit()
+
+ save_data = config_to_result(test_config, data['result'][1])
+ if Use_Dashboard is True:
+ DashBoard.dashboard_send_data(context_conf, save_data)
+
+ return save_data["data_body"]
+
+
+def run(test_config):
+ con_dic = test_config["load_manager"]
+ env_pre(None)
+ if test_config["contexts"]["yardstick_ip"] is None:
+ con_dic["contexts"]["yardstick_ip"] =\
+ conf_parser.ip_parser("yardstick_test_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")
+ Use_Dashboard = True
+ DashBoard.dashboard_system_bandwidth(test_config["contexts"])
+