2 The purpose of this script to create enough traffic in config datastore
3 to trigger creation of Snapshot.
4 This script uses PUT http method for handling/replacing "moving segment" of cars.
5 The car data is minimal, containing only an ID (car-<num>).
17 The main function that does it all.
19 TODO: Move argument parsing to a separate function,
20 so allow the main logic to be started programmatically?
24 car_entry_template = string.Template(
30 patch_data_template = string.Template(
41 parser = argparse.ArgumentParser(description="Config datastore" "scale test script")
45 help="Host where odl controller is running." "(default: 127.0.0.1)",
50 help="Port on which odl's RESTCONF is listening" "(default: 8181)",
56 help="ID number of the first car. (default:1)",
62 help="Number of cars in segment. (default:1)",
68 help="How many times the segment sent. (default:1)",
74 help="Each segment has IDs moved by this. (default:1)",
76 parser.add_argument("--user", help="Restconf user name", default="admin")
77 parser.add_argument("--password", help="Restconf password", default="admin")
79 args = parser.parse_args()
82 url = "http://" + args.host + ":" + args.port + "/restconf/config/car:cars"
83 auth = (args.user, args.password)
84 headers = {"Content-Type": "application/json"}
85 session = requests.Session()
86 for iteration in range(args.iterations):
88 for num_entry in range(args.segment_size):
89 num_id = args.start_id + iteration * args.move_per_iter + num_entry
90 entry_list.append(car_entry_template.substitute({"NUM": str(num_id)}))
91 mapping = {"ID": str(iteration), "ENTRIES": ",\n".join(entry_list)}
92 data = patch_data_template.substitute(mapping)
93 response = session.put(url=url, auth=auth, headers=headers, data=data)
94 if response.status_code not in [200, 201, 204]:
95 print("status: {}".format(response.status_code))
96 print("text: {}".format(response.text))
100 if __name__ == "__main__":