Merge "Add virtual enviroment support for cli"
authorYu Yang (Gabriel) <Gabriel.yuyang@huawei.com>
Thu, 1 Dec 2016 02:20:00 +0000 (02:20 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Thu, 1 Dec 2016 02:20:00 +0000 (02:20 +0000)
docker/Dockerfile
run_tests.sh
testsuites/posca/run_posca.py
testsuites/posca/testcase_dashboard/__init__.py [new file with mode: 0644]
testsuites/posca/testcase_dashboard/system_bandwidth.py [new file with mode: 0755]
testsuites/posca/testcase_script/common_script.py [new file with mode: 0644]
testsuites/posca/testcase_script/posca_factor_system_bandwidth.py

index f5ac0e8..6288cf8 100644 (file)
@@ -15,6 +15,9 @@ LABEL image=opnfv/bottlenecks
 # GIT repo directory
 ENV REPOS_DIR /home/opnfv
 
+# CI docker image label
+ARG BRANCH=master
+
 # Bottlenecks repo
 ENV BOTTLENECKS_REPO_DIR ${REPOS_DIR}/bottlenecks
 ENV RELENG_REPO_DIR ${REPOS_DIR}/releng
index 62f8738..c03b198 100755 (executable)
@@ -121,7 +121,7 @@ function run_test(){
                 #adjust config parameters
                 #run test case
                 file=${BASEDIR}/testsuites/posca/testcase_cfg/${i}.yaml
-                python /home/opnfv/bottlenecks/testsuites/posca/run_posca.py -c $file
+                python /home/opnfv/bottlenecks/testsuites/posca/run_posca.py -c ${i}
             done
         ;;
     esac
index 48376b5..e5e11e9 100755 (executable)
@@ -19,10 +19,11 @@ INTERPRETER = "/usr/bin/python"
 \r
 def posca_run(arg):\r
     print("========== run posca ==========")\r
-    if(arg == "factor_system_bandwidth"):\r
+    print(arg)\r
+    if(arg == "posca_factor_system_bandwidth"):\r
         print("========== run posca_system_bandwidth ===========")\r
         cmd = '/home/opnfv/bottlenecks/testsuites/posca/testcase_script/\\r
-                posca_factor_system_bandwidth.py'\r
+posca_factor_system_bandwidth.py'\r
         pargs = [INTERPRETER, cmd]\r
         sub_result = subprocess.Popen(pargs)\r
         sub_result.wait()\r
@@ -34,7 +35,7 @@ def posca_env_check():
 \r
 def main():\r
     # para_testname = sys.argv[0]\r
-    para_test_arg = sys.argv[1]\r
+    para_test_arg = sys.argv[2]\r
     posca_env_check()\r
     posca_run(para_test_arg)\r
     sys.exit(0)\r
diff --git a/testsuites/posca/testcase_dashboard/__init__.py b/testsuites/posca/testcase_dashboard/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testsuites/posca/testcase_dashboard/system_bandwidth.py b/testsuites/posca/testcase_dashboard/system_bandwidth.py
new file mode 100755 (executable)
index 0000000..708820d
--- /dev/null
@@ -0,0 +1,103 @@
+#!/usr/bin/python
+##############################################################################
+# Copyright (c) 2015 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
+##############################################################################
+import ConfigParser
+from elasticsearch import Elasticsearch
+
+config = ConfigParser.ConfigParser()
+file_str = "testcase_cfg/posca_factor_system_bandwidth.yaml"
+with open(file_str, "rd") as cfgfile:
+    config.readfp(cfgfile)
+    ES_ip_a = config.get("config", "ES_ip")
+
+es_ip = ES_ip_a.split(':')
+es = Elasticsearch([{'host':es_ip[0]}])
+doc={
+    "title": "bottlenecks",
+    "timeFieldName": "time",
+    "fields": "[{\"name\":\"runner_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"tx_cache_size\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"task_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"scenarios\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"local_cpu_util\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"rx_cache_size\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"local_transport_retrans\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"host\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"throughput\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"throughput_units\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"mean_latency\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"tx_msg_size\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"version\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"deploy_scenario\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"pod_name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"target\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"rx_msg_size\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"installer\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"remote_cpu_util\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false}]"
+}
+
+res = es.index(index=".kibana",doc_type="index-pattern",id="bottlenecks",body=doc)
+print(res['created'])
+
+doc={
+    "buildNum": 10146,
+    "defaultIndex": "bottlenecks"
+}
+res = es.index(index=".kibana",doc_type="config",id="4.6.1",body=doc)
+print(res['created'])
+doc={
+"title": "system_bandwidth",
+    "description": "",
+    "version": 1,
+}
+res = es.index(index=".kibana",doc_type="search",id="system_bandwidth",body=doc)
+print(res['created'])
+
+doc = {
+    "title": "system_bandwidth_line-date",
+    "visState": "{\"title\":\"system_bandwidth_line-date\",\"type\":\"line\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"showCircles\":true,\"smoothLines\":false,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"sum\",\"schema\":\"metric\",\"params\":{\"field\":\"throughput\"}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"time\",\"size\":100,\"order\":\"asc\",\"orderBy\":\"_term\"}},{\"id\":\"3\",\"type\":\"sum\",\"schema\":\"metric\",\"params\":{\"field\":\"rx_msg_size\"}}],\"listeners\":{}}",
+    "uiStateJSON": "{}",
+    "description": "",
+    "version": 1,
+    "kibanaSavedObjectMeta": {
+      "searchSourceJSON": "{\"index\":\"bottlenecks\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"
+    }
+}
+res = es.index(
+    index=".kibana", doc_type="visualization", id="system_bandwidth_line-date", body=doc)
+print(res['created'])
+
+doc = {
+    "title": "system_bandwidth_line-char",
+    "visState": "{\"title\":\"system_bandwidth_line-char\",\"type\":\"line\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"showCircles\":true,\"smoothLines\":false,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"sum\",\"schema\":\"metric\",\"params\":{\"field\":\"throughput\"}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"rx_msg_size\",\"size\":30,\"order\":\"asc\",\"orderBy\":\"_term\"}},{\"id\":\"3\",\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"tx_msg_size\",\"size\":30,\"order\":\"desc\",\"orderBy\":\"_term\"}}],\"listeners\":{}}",
+    "uiStateJSON": "{}",
+    "description": "",
+    "version": 1,
+    "kibanaSavedObjectMeta": {
+      "searchSourceJSON": "{\"index\":\"bottlenecks\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"
+    }
+}
+
+res = es.index(
+    index=".kibana", doc_type="visualization", id="system_bandwidth_line-char", body=doc)
+print(res['created'])
+
+doc = {
+    "title": "system_bandwidth_terms_data",
+    "visState": "{\"title\":\"system_bandwidth_terms_data\",\"type\":\"table\",\"params\":{\"perPage\":80,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"sum\",\"schema\":\"metric\",\"params\":{\"field\":\"throughput\"}},{\"id\":\"4\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"tx_msg_size\",\"size\":200,\"order\":\"asc\",\"orderBy\":\"_term\"}},{\"id\":\"5\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"rx_msg_size\",\"size\":200,\"order\":\"asc\",\"orderBy\":\"_term\"}},{\"id\":\"6\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"mean_latency\",\"size\":5,\"order\":\"asc\",\"orderBy\":\"_term\"}},{\"id\":\"7\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"local_cpu_util\",\"size\":20,\"order\":\"desc\",\"orderBy\":\"_term\"}},{\"id\":\"8\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"remote_cpu_util\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"_term\"}}],\"listeners\":{}}",
+    "uiStateJSON": "{}",
+    "description": "",
+    "version": 1,
+    "kibanaSavedObjectMeta": {
+      "searchSourceJSON": "{\"index\":\"bottlenecks\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"
+    }
+}
+
+res = es.index(
+    index=".kibana", doc_type="visualization", id="system_bandwidth_terms_data", body=doc)
+print(res['created'])
+
+doc = {
+    "title": "system_bandwidth_dashboard",
+    "hits": 0,
+    "description": "",
+    "panelsJSON": "[{\"id\":\"system_bandwidth_line-char\",\"type\":\"visualization\",\"panelIndex\":3,\"size_x\":7,\"size_y\":4,\"col\":1,\"row\":1},{\"id\":\"system_bandwidth_line-date\",\"type\":\"visualization\",\"panelIndex\":4,\"size_x\":7,\"size_y\":4,\"col\":1,\"row\":5},{\"id\":\"system_bandwidth_terms_data\",\"type\":\"visualization\",\"panelIndex\":5,\"size_x\":5,\"size_y\":8,\"col\":8,\"row\":1}]",
+    "optionsJSON": "{\"darkTheme\":false}",
+    "uiStateJSON": "{}",
+    "version": 1,
+    "kibanaSavedObjectMeta": {
+      "searchSourceJSON": "{\"filter\":[{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}}}]}"
+    }
+}
+
+res = es.index(
+    index=".kibana", doc_type="dashboard", id="system_bandwidth_dashboard", body=doc)
+print(res['created'])
diff --git a/testsuites/posca/testcase_script/common_script.py b/testsuites/posca/testcase_script/common_script.py
new file mode 100644 (file)
index 0000000..6d5c893
--- /dev/null
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+##############################################################################
+# Copyright (c) 2016 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
+##############################################################################
+
+import json
+import requests
+import time
+import subprocess as sub
+from pyroute2 import IPDB
+import sys
+
+headers = {"Content-Type": "application/json"}
+
+
+def posca_tran_data(ES_ip, file_name):
+        p = sub.Popen(['curl', '-s', '-XPOST', "%s/_bulk" % ES_ip,
+                       '--data-binary', "@" + file_name], stdout=sub.PIPE)
+        for line in iter(p.stdout.readline, b''):
+            ret_dict = json.loads(line)
+            if not ret_dict['errors']:
+                print("INFO: %6s lines no errors, total cost %d ms."
+                      % (len(ret_dict['items']), ret_dict['took']))
+                return len(ret_dict['items'])
+            else:
+                print("ERROR: %6s lines have errors, total cost %d ms."
+                      % (len(ret_dict['items']), ret_dict['took']))
+
+
+def posca_config_read(config_str, con_str, config):
+    print("========== posca system bandwidth config read ===========")
+    con_dic = {}
+    print(config_str)
+    idx = 0
+    with open(config_str, "rd") as cfgfile:
+        config.readfp(cfgfile)
+        while idx < len(con_str):
+            con_dic[str(con_str[idx])] = \
+                            config.get("config", str(con_str[idx]))
+            idx += 1
+    with IPDB() as ip:
+        GATEWAY_IP = ip.routes['default'].gateway
+    if str(con_dic["test_ip"]) is "":
+        con_dic["test_ip"] = GATEWAY_IP+":3333"
+        print("test_ip is null get local ip is %s" %(con_dic["test_ip"]))
+    if con_dic["ES_ip"] is "":
+        con_dic["ES_ip"] = GATEWAY_IP+":9200"
+        print("ES_ip is null get local ip is %s" %(con_dic["ES_ip"]))
+    return con_dic
+
+
+def posca_output_result(file_config, data_reply):
+    data_head = {}
+    data_head["index"] = {}
+    data_head["index"]["_index"] = "bottlenecks"
+    data_head["index"]["_type"] = file_config["test_type"]
+    data_head["index"]["_id"] = file_config["test_id"]
+
+    data_reply["throughput"] = float(data_reply["throughput"])
+    data_reply["mean_latency"] = float(data_reply["mean_latency"])
+    data_reply["remote_cpu_util"] = float(data_reply["remote_cpu_util"])
+    data_reply["local_cpu_util"] = float(data_reply["local_cpu_util"])
+    data_reply["local_transport_retrans"] =\
+        float(data_reply["local_transport_retrans"])
+    with open(file_config["file_path"], "a") as f:
+        f.write(json.dumps(data_head, f))
+        f.write("\n")
+        f.write(json.dumps(data_reply, f))
+        f.write("\n")
+        f.close()
+
+
+def posca_get_reply(con_dic, task_id, time_test=1):
+    reply_url = "http://%s/yardstick/result/action?action=getResult&task_id=%s\
+&measurement=tc100" % (con_dic["test_ip"], task_id)
+    time.sleep(float(con_dic["test_time"]))
+    reply_response = requests.get(reply_url)
+    reply_data = json.loads(reply_response.text)
+    print(reply_data)
+    if reply_data["status"] == 1:
+        return(reply_data["result"][0])
+    if reply_data["status"] == 0:
+        if time_test == 3:
+            print("yardstick time out")
+            sys.exit()
+        posca_get_reply(con_dic, task_id, time_test=time_test+1)
+    if reply_data["status"] == 2:
+        print("yardstick error exit")
+        sys.exit()
+
+def posca_send_data(con_dic, test_config, file_config):
+    base_url = "http://%s/yardstick/test/action" % (con_dic['test_ip'])
+    print(con_dic["test_ip"])
+    test_dict = {
+            "action":"runTestCase",
+            "args":{
+                "opts": {
+                    "task-args": {
+                        'tx_msg_size': '%s' % str(test_config["tx_msg_size"]),
+                        'rx_msg_size': '%s' % str(test_config["rx_msg_size"]),
+                        'test_time': '%s' % str(int(con_dic["test_time"]) - 20),
+                        'host': 'node3.LF',
+                        'target': 'node4.LF'
+                        }
+                 },
+                 "testcase":"tc100"
+            }
+    }
+    # print(base_url)
+    reponse = requests.post(
+                        base_url, data=json.dumps(test_dict), headers=headers)
+    ask_data = json.loads(reponse.text)
+    task_id = ask_data["task_id"]
+    data_reply = posca_get_reply(con_dic, task_id)
+    data_reply.update(test_config)
+    posca_output_result(file_config, data_reply)
+    return data_reply
+
+
+def posca_create_incluxdb(con_dic):
+    base_url = "http://%s/yardstick/env/action" % (con_dic['test_ip'])
+    test_dict = {
+            "action":"createInfluxDBContainer",
+    }
+    reponse = requests.post(
+                        base_url, data=json.dumps(test_dict), headers=headers)
index f3e950b..74bea8f 100644 (file)
@@ -13,7 +13,9 @@ import argparse
 import time
 import logging
 import ConfigParser
-import json
+import common_script
+import datetime
+import subprocess
 
 # ------------------------------------------------------
 # parser for configuration files in each test case
@@ -22,14 +24,12 @@ parser = argparse.ArgumentParser()
 parser.add_argument("-c", "--conf",
                     help="configuration files for the testcase,\
                         in yaml format",
-                    default="/home/opnfv/bottlenecks/testsuites/posca/\
-                        testcase_cfg/posca_factor_tx_pkt_size.yaml")
+                    default="/home/opnfv/bottlenecks/testsuites/posca\
+/testcase_cfg/posca_factor_system_bandwidth.yaml")
 args = parser.parse_args()
+headers = {"Content-Type": "application/json"}
+INTERPRETER = "/usr/bin/python"
 
-cmd = "curl -i"
-order_arg = "-H \"Content-Type: application/json\" -X POST -d \'{\"cmd\": \
-            \"start\", \"opts\":{\"output-file\": \"/tem/yardstick.out\"}, \
-            \"args\": \"../samples/netperf.yaml\"}'"
 
 # --------------------------------------------------
 # logging configuration
@@ -43,94 +43,73 @@ def posca_env_check():
     if os.path.exists(filepath):
         return True
     else:
-        os.mkdirs(r'/home/opnfv/bottlenecks/testsuites/posca/test_result/')
-
-
-def posca_output_result(time_new, input_1, input_2, input_3,
-                        input_4, input_5, input_6):
-    save_dic = {}
-    save_dic['tx_pkt_size'] = input_1
-    save_dic['rx_cache_size'] = input_2
-    save_dic['tx_cache_size'] = input_3
-    save_dic['throughput '] = input_4
-    save_dic['latency'] = input_5
-    save_dic['cpu_load'] = input_6
-    with open("/home/opnfv/bottlenecks/testsuites/posca/test_result/\
-            factor_tx_cache_size_%s.json" % (time_new), "a") as f:
-        f.write(json.dumps(save_dic, f))
-        f.write("\n")
-
-
-def posca_config_read(config_str):
-    print("========== posca system bandwidth config read ===========")
-    con_dic = {}
-    config = ConfigParser.ConfigParser()
-    with open(config_str, "rd") as cfgfile:
-        config.readfp(cfgfile)
-        con_dic['test_ip'] = config.get("config", "test_ip")
-        con_dic['test_tool'] = config.get("config", "tool")
-        con_dic['test_time'] = config.get("config", "test_time")
-        con_dic['test_protocol'] = config.get("config", "protocol")
-        con_dic['test_tx_pkt_s'] = config.get("config", "tx pkt sizes")
-        con_dic['test_rx_pkt_s'] = config.get("config", "rx pkt sizes")
-        con_dic['test_tx_cache_s'] = config.get("config", "tx cache sizes")
-        con_dic['test_rx_cache_s'] = config.get("config", "rx cache sizes")
-        con_dic['test_cpu_load'] = config.get("config", "cpu load")
-        con_dic['test_latency'] = config.get("config", "latency")
-
-    return con_dic
+        os.mkdir(r'/home/opnfv/bottlenecks/testsuites/posca/test_result/')
+
+
+def system_pkt_bandwidth(test_id, data, file_config, con_dic):
+    date_id = test_id
+    print("package test is is begin from %d" % test_id)
+    cur_role_result = 1
+    pre_role_result = 1
+    pre_reply = {}
+    data_return = {}
+    data_max = {}
+    data_return["throughput"] = 1
+    for test_x in data["tx_pkt_sizes"]:
+        data_max["throughput"] = 1
+        bandwidth_tmp = 1
+        for test_y in data["rx_pkt_sizes"]:
+            test_config = {
+                        "tx_msg_size": float(test_x),
+                        "rx_msg_size": float(test_y),
+                    }
+            date_id = date_id + 1
+            file_config["test_id"] = date_id
+            data_reply = common_script.posca_send_data(
+                   con_dic, test_config, file_config)
+            bandwidth = data_reply["throughput"]
+            if (data_max["throughput"] < bandwidth):
+                data_max = data_reply
+            if (abs(bandwidth_tmp - bandwidth)/bandwidth_tmp < 0.025):
+                print(pre_reply)
+                break
+            else:
+                pre_reply = data_reply
+                bandwidth_tmp = bandwidth
+        cur_role_result = pre_reply["throughput"]
+        if (abs(pre_role_result - cur_role_result)/pre_role_result < 0.025):
+            print("date_id is %d,package return at line 111\n" % date_id)
+            # return data_return
+        if data_return["throughput"] < data_max["throughput"]:
+            data_return = data_max
+        pre_role_result = cur_role_result
+    print("date_id is %d,id return success\n" % date_id)
+    return data_return
 
 
 def posca_run(con_dic):
     print("========== run posca system bandwidth ===========")
-
-    test_rx_pkt_s_e = 87380
-    test_tx_pkt_s_a = con_dic['test_tx_pkt_s'].split(',')
-    test_tx_cache_s_a = con_dic['test_tx_cache_s'].split(',')
-    test_rx_cache_s_a = con_dic['test_rx_cache_s'].split(',')
+    test_con_id = 0
+    file_config = {}
+    data = {}
+    rx_pkt_s_a = con_dic['rx_pkt_sizes'].split(',')
+    tx_pkt_s_a = con_dic['tx_pkt_sizes'].split(',')
     time_new = time.strftime('%H_%M', time.localtime(time.time()))
-    bandwidth_tmp = 1
-
-    for test_rx_cache_s_e in test_rx_cache_s_a:
-        for test_tx_cache_s_e in test_tx_cache_s_a:
-            for test_tx_pkt_s_e in test_tx_pkt_s_a:
-                print("%s,%s,%s") % (test_tx_pkt_s_e, test_rx_cache_s_e,
-                                     test_tx_cache_s_e)
-                order_excute = os.popen("%s %s http://%s/api/v3/yardstick/\
-                    tasks/task %s %s %s" % (cmd, order_arg, con_dic['test_ip'],
-                                            test_rx_pkt_s_e, test_rx_cache_s_e,
-                                            test_tx_cache_s_e))
-                order_result = order_excute.read()
-                task_id = order_result.find("task_id")
-                time.sleep(con_dic['test_time'])
-                cmd_excute = os.popen("%s http://%s/api/v3/yardstick/testre\
-                    sults?task_id=%s" % (cmd, con_dic['test_ip'], task_id))
-                bandwidth = cmd_excute.find("bandwidth")
-                cpu_load = cmd_excute.find("cpu_load")
-                latency = cmd_excute.find("latency")
-                posca_output_result(time_new, test_rx_pkt_s_e,
-                                    test_rx_cache_s_e,
-                                    bandwidth, latency, cpu_load)
-                if (cpu_load < con_dic['test_cpu_load\
-                        ']) and (latency < con_dic['test_latency']):
-                    if (abs(bandwidth_tmp-bandwidth)/bandwidth < 0.05):
-                        print("%s,%s,%s,%s,%s,%s") % (test_rx_pkt_s_e,
-                                                      test_rx_cache_s_e,
-                                                      test_tx_cache_s_e,
-                                                      bandwidth,
-                                                      latency,
-                                                      cpu_load)
-                        return True
-                    else:
-                        bandwidth_tmp = bandwidth
-                else:
-                    print("%s,%s,%s,%s,%s,%s") % (test_rx_pkt_s_e,
-                                                  test_rx_cache_s_e,
-                                                  test_tx_cache_s_e,
-                                                  bandwidth,
-                                                  latency,
-                                                  cpu_load)
-                    return True
+    file_config["file_path"] = "/home/opnfv/bottlenecks/testsuites/posca/\
+test_result/factor_system_system_bandwidth_%s.json" % (time_new)
+    file_config["test_type"] = "system_bandwidth_biggest"
+    data["rx_pkt_sizes"] = rx_pkt_s_a
+    data["tx_pkt_sizes"] = tx_pkt_s_a
+    print("######test package begin######")
+    pkt_reply = system_pkt_bandwidth(
+        test_con_id, data, file_config, con_dic)
+
+    print("######find system bandwidth######")
+    print("rx_msg_size:%d  tx_msg_size:%d\n" %
+          (pkt_reply["rx_msg_size"], pkt_reply["tx_msg_size"]))
+    date_tran = common_script.posca_tran_data(
+                            con_dic['ES_ip'], file_config["file_path"])
+    return True
 
 
 def main():
@@ -141,11 +120,28 @@ def main():
     else:
         testcase_cfg = args.conf
 
-    con_dic = posca_config_read(testcase_cfg)
+    con_str = [
+            'test_ip', 'tool', 'test_time', 'protocol',
+            'tx_pkt_sizes', 'rx_pkt_sizes', 'cpu_load',
+            'latency', 'ES_ip', 'dashboard'
+    ]
+    starttime = datetime.datetime.now()
+    config = ConfigParser.ConfigParser()
+    con_dic = common_script.posca_config_read(testcase_cfg, con_str, config)
+    common_script.posca_create_incluxdb(con_dic)
     posca_env_check()
     posca_run(con_dic)
-
+    endtime = datetime.datetime.now()
+    if con_dic["dashboard"] == "y":
+        cmd = '/home/opnfv/bottlenecks/testsuites/posca/testcase_dashboard/\
+system_bandwidth.py'
+        pargs = [INTERPRETER, cmd]
+        print("Begin to establish dashboard, False means already exist.\n")
+        sub_result = subprocess.Popen(pargs)
+        sub_result.wait()
+    print("System Bandwidth testing time : %s" %(endtime - starttime))
     time.sleep(5)
 
 if __name__ == '__main__':
     main()
+