def start(self, port): assert self.proc is None _plano.make_dir(self.output_dir) self.output = open(self.output_file, "w") command = [ "quiver-server", "//localhost:{}/q0".format(port), "--impl", self.impl, "--ready-file", self.ready_file, "--verbose", ] _plano.write(self.command_file, "{}\n".format(" ".join(command))) self.proc = _plano.start_process(command, stdout=self.output, stderr=self.output) for i in range(30): if _plano.read(self.ready_file) == "ready\n": break _plano.sleep(0.2) else: raise _Timeout("Timed out waiting for server to be ready")
def init(self): super(QuiverBenchCommand, self).init() self.output_dir = self.args.output if self.output_dir is None: prefix = _plano.program_name() datestamp = _time.strftime('%Y-%m-%d', _time.localtime()) self.output_dir = "{}-{}".format(prefix, datestamp) _plano.make_dir(self.output_dir) self.client_server = True self.peer_to_peer = True if self.args.client_server: self.peer_to_peer = False if self.args.peer_to_peer: self.client_server = False self.mixed_pairs = self.args.mixed_pairs self.init_impl_attributes() self.init_common_test_attributes() self.init_common_tool_attributes() if not self.verbose: _plano.enable_logging("warn") self.failures = list()
def start(self, port): assert self.proc is None _plano.make_dir(self.output_dir) self.output = open(self.output_file, "w") command = [ "quiver-server", "//127.0.0.1:{}/q0".format(port), "--impl", self.impl, "--ready-file", self.ready_file, "--verbose", ] _plano.write(self.command_file, "{}\n".format(" ".join(command))) self.proc = _plano.start_process(command, stdout=self.output, stderr=self.output) for i in range(30): if _plano.read(self.ready_file) == "ready\n": break _plano.sleep(0.2) else: raise _Timeout("Timed out waiting for server to be ready")
def run(self, port, args): _plano.make_dir(self.output_dir) command = [ "quiver", "//127.0.0.1:{}/q0".format(port), "--sender", self.sender_impl, "--receiver", self.receiver_impl, "--count", args.count, "--duration", args.duration, "--body-size", args.body_size, "--credit", args.credit, "--timeout", args.timeout, ] if self.peer_to_peer: command += ["--peer-to-peer"] if self.command.verbose: command += ["--verbose"] command += [ "--output", self.output_dir, ] _plano.write(self.command_file, "{}\n".format(" ".join(command))) with open(self.output_file, "w") as f: try: _plano.call(command, stdout=f, stderr=f) except: _plano.write(self.status_file, "FAILED\n") raise _plano.write(self.status_file, "PASSED\n")
def init_output_dir(self): self.output_dir = self.args.output if self.output_dir is None: self.output_dir = _tempfile.mkdtemp(prefix="quiver-") _plano.make_dir(self.output_dir)
def run(self, port, args): _plano.make_dir(self.output_dir) command = [ "quiver", "//127.0.0.1:{}/q0".format(port), "--sender", self.sender_impl, "--receiver", self.receiver_impl, "--messages", args.messages, "--body-size", args.body_size, "--credit", args.credit, "--timeout", args.timeout, "--output", self.output_dir, ] if self.peer_to_peer: command.append("--peer-to-peer") _plano.write(self.command_file, "{}\n".format(" ".join(command))) with open(self.output_file, "w") as f: try: _plano.call(command, stdout=f, stderr=f) except: _plano.write(self.status_file, "FAILED\n") raise _plano.write(self.status_file, "PASSED\n")
def run(self, port, args): _plano.make_dir(self.output_dir) command = [ "quiver", "--sender", self.sender_impl, "--receiver", self.receiver_impl, "--count", args.count, "--duration", args.duration, "--body-size", args.body_size, "--credit", args.credit, "--timeout", args.timeout, ] if self.command.verbose: command += ["--verbose"] command += [ "--output", self.output_dir, ] if not self.peer_to_peer: command += ["//localhost:{}/q0".format(port)] _plano.write(self.command_file, "{}\n".format(" ".join(command))) with open(self.output_file, "w") as f: try: _plano.call(command, stdout=f, stderr=f) except: _plano.write(self.status_file, "FAILED\n") raise _plano.write(self.status_file, "PASSED\n")
def run_test(self, sender_impl, server_impl, receiver_impl): peer_to_peer = server_impl is None port = _plano.random_port() server = None if server_impl == "activemq": if sender_impl == "activemq-jms" and receiver_impl == "activemq-jms": port = 61616 else: port = 5672 if peer_to_peer: summary = "{} -> {} ".format(sender_impl, receiver_impl) server_name = "none" else: summary = "{} -> {} -> {} ".format(sender_impl, server_impl, receiver_impl) server_name = server_impl test_dir = _plano.join(self.output_dir, sender_impl, server_name, receiver_impl) pair_dir = _plano.join(test_dir, "pair") server_dir = _plano.join(test_dir, "server") pair = _TestPair(pair_dir, sender_impl, receiver_impl, peer_to_peer) if not peer_to_peer: server = _TestServer(server_dir, server_impl) _plano.make_dir(server.output_dir) print("{:.<113} ".format(summary), end="") _plano.flush() if server is not None: out = open(server.output_file, "w") try: server.start(port, out) except _Timeout as e: self.failures.append(str(e)) # XXX capture the combo print("FAILED") if self.verbose: if server is not None: server.print_summary() try: pair.run(port, self.args) print("PASSED") except KeyboardInterrupt: raise except _plano.CalledProcessError as e: self.failures.append(str(e)) # XXX capture the combo print("FAILED") if self.verbose: pair.print_summary() if server is not None: server.print_summary() except: _traceback.print_exc() finally: _plano.flush() if server is not None: server.stop() out.close() self.report(pair, server)