diff options
author | 2016-09-13 11:40:12 +0800 | |
---|---|---|
committer | 2016-09-13 11:41:53 +0800 | |
commit | b731e2f1dd0972409b136aebc7b463dd72c9cfad (patch) | |
tree | 5107d7d80c19ad8076c2c97c2b5ef8d1cf3ab903 /framework/src/onos/tools/test/bin/flow-tester.py | |
parent | ee93993458266114c29271a481ef9ce7ce621b2a (diff) |
ONOSFW-171
O/S-SFC-ONOS scenario documentation
Change-Id: I51ae1cf736ea24ab6680f8edca1b2bf5dd598365
Signed-off-by: CNlucius <lukai1@huawei.com>
Diffstat (limited to 'framework/src/onos/tools/test/bin/flow-tester.py')
-rw-r--r-- | framework/src/onos/tools/test/bin/flow-tester.py | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/framework/src/onos/tools/test/bin/flow-tester.py b/framework/src/onos/tools/test/bin/flow-tester.py deleted file mode 100644 index d77a861b..00000000 --- a/framework/src/onos/tools/test/bin/flow-tester.py +++ /dev/null @@ -1,45 +0,0 @@ -import concurrent.futures -import requests, json -from optparse import OptionParser - -def run(url, request): - data = json.dumps(request) - r = requests.post(url, data) - return r - -def runTasks(flowPerDevice, neighbours, url, servers, doJson, remove): - # We can use a with statement to ensure threads are cleaned up promptly - with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: - # Start the load operations and mark each future with its URL - request = { "flowsPerDevice" : flowPerDevice, "neighbours" : neighbours, "remove" : remove } - future_to_url = {executor.submit(run, url % (server), request) for server in servers} - for f in concurrent.futures.as_completed(future_to_url): - try: - response = f.result() - server = response.url.split('//')[1].split(':')[0] - if (doJson): - print (json.dumps({ "server" : server, "elapsed" : response.json()['elapsed'] })) - else: - print ("%s -> %sms" % (server, response.json()['elapsed'])) - except Exception as exc: - print("Execution failed -> %s" % exc) - -if __name__ == "__main__": - parser = OptionParser() - parser.add_option("-u", "--url", dest="url", help="set the url for the request", - default="http://%s:8181/onos/demo/intents/flowTest") - parser.add_option("-f", "--flows", dest="flows", help="Number of flows to install per device", - default=100, type="int") - parser.add_option("-n", "--neighbours", dest="neighs", help="Number of neighbours to communicate to", - default=0, type="int") - parser.add_option("-s", "--servers", dest="servers", help="List of servers to hit", - default=[], action="append") - parser.add_option("-r", "--remove", dest="remove", help="Do not remove flows after installation", - default=True, action="store_false") - parser.add_option("-j", "--json", dest="doJson", help="Print results in json", - default=False, action="store_true") - - (options, args) = parser.parse_args() - if (len(options.servers) == 0): - options.servers.append("localhost") - runTasks(options.flows, options.neighs, options.url, options.servers, options.doJson, options.remove) |