class VerifierTasks(TaskSet): hubTasks = None def on_start(self): self.hubTasks = HubTasks(BatchUser(), self.client) self.hubTasks.start() @task(10000) def write(self): bulk = "" for x in range(0, 50): bulk += "--abcdefg\r\n" bulk += "Content-Type: application/json\r\n\r\n" bulk += '{"name":"' + self.hubTasks.payload + '", "count": ' + str( self.hubTasks.count) + '}\r\n' self.hubTasks.count += 1 bulk += "--abcdefg--\r\n" with self.client.post( "/channel/" + self.hubTasks.channel + "/bulk", data=bulk, headers={"Content-Type": "multipart/mixed; boundary=abcdefg"}, catch_response=True, name="post_bulk") as postResponse: if postResponse.status_code != 201: postResponse.failure("Got wrong response on post: " + str(postResponse.status_code)) links = postResponse.json() uris = links['_links']['uris'] for uri in uris: self.hubTasks.append_href(uri) # todo add read functionality return uris @task(10) def next_10(self): self.hubTasks.next_10() @task(10) def minute_query(self): self.hubTasks.minute_query() @task(10) def second_query(self): self.hubTasks.second_query() @task(10) def verify_callback_length(self): self.hubTasks.verify_callback_length(50000) @web.app.route("/callback", methods=['GET']) def get_channels(): return HubTasks.get_channels() @web.app.route("/callback/<channel>", methods=['GET', 'POST']) def callback(channel): return HubTasks.callback(channel)
class VerifierTasks(TaskSet): hubTasks = None def on_start(self): self.hubTasks = HubTasks(BatchUser(), self.client) self.hubTasks.start() @task(10000) def write(self): bulk = "" for x in range(0, 50): bulk += "--abcdefg\r\n" bulk += "Content-Type: application/json\r\n\r\n" bulk += '{"name":"' + self.hubTasks.payload + '", "count": ' + str(self.hubTasks.count) + '}\r\n' self.hubTasks.count += 1 bulk += "--abcdefg--\r\n" with self.client.post("/channel/" + self.hubTasks.channel + "/bulk", data=bulk, headers={"Content-Type": "multipart/mixed; boundary=abcdefg"}, catch_response=True, name="post_bulk") as postResponse: if postResponse.status_code != 201: postResponse.failure("Got wrong response on post: " + str(postResponse.status_code)) links = get_response_as_json(postResponse) logger.debug('item POSTed: ' + links['_links']['self']['href']) uris = links['_links']['uris'] for uri in uris: self.hubTasks.append_href(uri, 'websockets') self.hubTasks.append_href(uri, 'webhooks') # todo add read functionality return uris @task(10) def next_10(self): self.hubTasks.next_10() @task(10) def minute_query(self): self.hubTasks.minute_query() @task(10) def second_query(self): self.hubTasks.second_query() @task(10) def verify_callback_length(self): self.hubTasks.verify_callback_length(50000) @web.app.route("/callback", methods=['GET']) def get_channels(): logger.debug(utils.get_client_address(request) + ' | ' + request.method + ' | /callback') return HubTasks.get_channels() @web.app.route("/callback/<channel>", methods=['GET', 'POST']) def callback(channel): logger.debug(utils.get_client_address(request) + ' | ' + request.method + ' | /callback/' + channel + ' | ' + request.get_data().strip()) return HubTasks.callback(channel) @web.app.route('/store/<name>', methods=['GET']) def get_store(name): return Response(HubTasks.get_store(name), mimetype='application/json')