def start(self): args = environment.binary_args('vtctld') + [ '-debug', '-templates', environment.vttop + '/go/cmd/vtctld/templates', '-log_dir', environment.vtlogroot, '-port', str(self.port), ] + \ environment.topo_server_flags() + \ environment.tablet_manager_protocol_flags() stderr_fd = open(os.path.join(environment.tmproot, "vtctld.stderr"), "w") self.proc = run_bg(args, stderr=stderr_fd) # wait for the process to listen to RPC timeout = 30 while True: v = get_vars(self.port) if v: break timeout = wait_step('waiting for vtctld to start', timeout, sleep_time=0.2) # save the running instance so vtctl commands can be remote executed now global vtctld, vtctld_connection if not vtctld: vtctld = self vtctld_connection = vtctl_client.connect( environment.vtctl_client_protocol(), 'localhost:%u' % self.port, 30) return self.proc
def start(self): args = environment.binary_args('vtctld') + [ '-debug', '-templates', environment.vttop + '/go/cmd/vtctld/templates', '-log_dir', environment.vtlogroot, '-port', str(self.port), ] + \ environment.topo_server().flags() + \ protocols_flavor().tablet_manager_protocol_flags() stderr_fd = open(os.path.join(environment.tmproot, "vtctld.stderr"), "w") self.proc = run_bg(args, stderr=stderr_fd) # wait for the process to listen to RPC timeout = 30 while True: v = get_vars(self.port) if v: break timeout = wait_step('waiting for vtctld to start', timeout, sleep_time=0.2) # save the running instance so vtctl commands can be remote executed now global vtctld, vtctld_connection if not vtctld: vtctld = self vtctld_connection = vtctl_client.connect( protocols_flavor().vtctl_client_protocol(), 'localhost:%u' % self.port, 30) return self.proc
def start(self, enable_schema_change_dir=False): args = environment.binary_args('vtctld') + [ '-enable_queries', '-cell', 'test_nj', '-web_dir', environment.vttop + '/web/vtctld', '--log_dir', environment.vtlogroot, '--port', str(self.port), '-tablet_manager_protocol', protocols_flavor().tablet_manager_protocol(), '-tablet_protocol', protocols_flavor().tabletconn_protocol(), '-throttler_client_protocol', protocols_flavor().throttler_client_protocol(), '-vtgate_protocol', protocols_flavor().vtgate_protocol(), ] + environment.topo_server().flags() if enable_schema_change_dir: args += [ '--schema_change_dir', self.schema_change_dir, '--schema_change_controller', 'local', '--schema_change_check_interval', '1', ] if protocols_flavor().service_map(): args.extend( ['-service_map', ','.join(protocols_flavor().service_map())]) if protocols_flavor().vtctl_client_protocol() == 'grpc': args.extend(['-grpc_port', str(self.grpc_port)]) stdout_fd = open(os.path.join(environment.tmproot, 'vtctld.stdout'), 'w') stderr_fd = open(os.path.join(environment.tmproot, 'vtctld.stderr'), 'w') self.proc = run_bg(args, stdout=stdout_fd, stderr=stderr_fd) # wait for the process to listen to RPC timeout = 30 while True: v = get_vars(self.port) if v: break if self.proc.poll() is not None: raise TestError('vtctld died while starting') timeout = wait_step('waiting for vtctld to start', timeout, sleep_time=0.2) # save the running instance so vtctl commands can be remote executed now global vtctld, vtctld_connection if not vtctld: vtctld = self protocol, endpoint = self.rpc_endpoint(python=True) vtctld_connection = vtctl_client.connect(protocol, endpoint, 30) return self.proc
def start(self, enable_schema_change_dir=False): # Note the vtctld2 web dir is set to 'dist', which is populated # when a toplevel 'make build_web' is run. This is meant to test # the development version of the UI. The real checked-in app is in # app/. args = environment.binary_args('vtctld') + [ '-enable_queries', '-cell', 'test_nj', '-web_dir', environment.vttop + '/web/vtctld', '-web_dir2', environment.vttop + '/web/vtctld2/dist', '--log_dir', environment.vtlogroot, '--port', str(self.port), '-tablet_manager_protocol', protocols_flavor().tablet_manager_protocol(), '-tablet_protocol', protocols_flavor().tabletconn_protocol(), '-throttler_client_protocol', protocols_flavor().throttler_client_protocol(), '-vtgate_protocol', protocols_flavor().vtgate_protocol(), '-workflow_manager_init', '-workflow_manager_use_election', ] + environment.topo_server().flags() # TODO(b/26388813): Remove the next two lines once vtctl WaitForDrain is # integrated in the vtctl MigrateServed* commands. args.extend(['--wait_for_drain_sleep_rdonly', '0s']) args.extend(['--wait_for_drain_sleep_replica', '0s']) if enable_schema_change_dir: args += [ '--schema_change_dir', self.schema_change_dir, '--schema_change_controller', 'local', '--schema_change_check_interval', '1', ] if protocols_flavor().service_map(): args.extend(['-service_map', ','.join(protocols_flavor().service_map())]) if protocols_flavor().vtctl_client_protocol() == 'grpc': args.extend(['-grpc_port', str(self.grpc_port)]) stdout_fd = open(os.path.join(environment.tmproot, 'vtctld.stdout'), 'w') stderr_fd = open(os.path.join(environment.tmproot, 'vtctld.stderr'), 'w') self.proc = run_bg(args, stdout=stdout_fd, stderr=stderr_fd) # wait for the process to listen to RPC timeout = 30 while True: v = get_vars(self.port) if v: break if self.proc.poll() is not None: raise TestError('vtctld died while starting') timeout = wait_step('waiting for vtctld to start', timeout, sleep_time=0.2) # save the running instance so vtctl commands can be remote executed now global vtctld, vtctld_connection if not vtctld: vtctld = self protocol, endpoint = self.rpc_endpoint(python=True) vtctld_connection = vtctl_client.connect(protocol, endpoint, 30) return self.proc
def test_interrupt_vtctl_command(self): """An interrupted streaming vtctl command should work.""" protocol, endpoint = utils.vtctld.rpc_endpoint(python=True) vtctld_connection = vtctl_client.connect(protocol, endpoint, 30) for i, event in enumerate( vtctld_connection.execute_vtctl_command(['ListAllTablets', 'test_nj'])): logging.debug('got event %d %s', i, event.value) if i == 1: break vtctld_connection.close()
def start(self): args = ( environment.binary_args("vtctld") + [ "-debug", "-web_dir", environment.vttop + "/web/vtctld", "--log_dir", environment.vtlogroot, "--port", str(self.port), "--schema_change_dir", self.schema_change_dir, "--schema_change_controller", "local", "--schema_change_check_interval", "1", "-tablet_manager_protocol", protocols_flavor().tablet_manager_protocol(), "-vtgate_protocol", protocols_flavor().vtgate_protocol(), "-tablet_protocol", protocols_flavor().tabletconn_protocol(), ] + environment.topo_server().flags() ) if protocols_flavor().service_map(): args.extend(["-service_map", ",".join(protocols_flavor().service_map())]) if protocols_flavor().vtctl_client_protocol() == "grpc": args.extend(["-grpc_port", str(self.grpc_port)]) stdout_fd = open(os.path.join(environment.tmproot, "vtctld.stdout"), "w") stderr_fd = open(os.path.join(environment.tmproot, "vtctld.stderr"), "w") self.proc = run_bg(args, stdout=stdout_fd, stderr=stderr_fd) # wait for the process to listen to RPC timeout = 30 while True: v = get_vars(self.port) if v: break if self.proc.poll() is not None: raise TestError("vtctld died while starting") timeout = wait_step("waiting for vtctld to start", timeout, sleep_time=0.2) # save the running instance so vtctl commands can be remote executed now global vtctld, vtctld_connection if not vtctld: vtctld = self protocol, endpoint = self.rpc_endpoint(python=True) vtctld_connection = vtctl_client.connect(protocol, endpoint, 30) return self.proc
def start(self, enable_schema_change_dir=False): args = environment.binary_args('vtctld') + [ '-enable_queries', '-cell', 'test_nj', '-web_dir', environment.vttop + '/web/vtctld', '--log_dir', environment.vtlogroot, '--port', str(self.port), '-tablet_manager_protocol', protocols_flavor().tablet_manager_protocol(), '-tablet_protocol', protocols_flavor().tabletconn_protocol(), '-throttler_client_protocol', protocols_flavor().throttler_client_protocol(), '-vtgate_protocol', protocols_flavor().vtgate_protocol(), ] + environment.topo_server().flags() if enable_schema_change_dir: args += [ '--schema_change_dir', self.schema_change_dir, '--schema_change_controller', 'local', '--schema_change_check_interval', '1', ] if protocols_flavor().service_map(): args.extend(['-service_map', ','.join(protocols_flavor().service_map())]) if protocols_flavor().vtctl_client_protocol() == 'grpc': args.extend(['-grpc_port', str(self.grpc_port)]) stdout_fd = open(os.path.join(environment.tmproot, 'vtctld.stdout'), 'w') stderr_fd = open(os.path.join(environment.tmproot, 'vtctld.stderr'), 'w') self.proc = run_bg(args, stdout=stdout_fd, stderr=stderr_fd) # wait for the process to listen to RPC timeout = 30 while True: v = get_vars(self.port) if v: break if self.proc.poll() is not None: raise TestError('vtctld died while starting') timeout = wait_step('waiting for vtctld to start', timeout, sleep_time=0.2) # save the running instance so vtctl commands can be remote executed now global vtctld, vtctld_connection if not vtctld: vtctld = self protocol, endpoint = self.rpc_endpoint(python=True) vtctld_connection = vtctl_client.connect(protocol, endpoint, 30) return self.proc
def start(self): args = environment.binary_args('vtctld') + [ '-debug', '--templates', environment.vttop + '/go/cmd/vtctld/templates', '--log_dir', environment.vtlogroot, '--port', str(self.port), '--schema_change_dir', self.schema_change_dir, '--schema_change_controller', 'local', '--schema_change_check_interval', '1', '-tablet_manager_protocol', protocols_flavor().tablet_manager_protocol(), ] + \ environment.topo_server().flags() + \ protocols_flavor().vtgate_protocol_flags() if protocols_flavor().service_map(): args.extend( ['-service_map', ",".join(protocols_flavor().service_map())]) if protocols_flavor().vtctl_client_protocol() == 'grpc': args.extend(['-grpc_port', str(self.grpc_port)]) stderr_fd = open(os.path.join(environment.tmproot, 'vtctld.stderr'), 'w') self.proc = run_bg(args, stderr=stderr_fd) # wait for the process to listen to RPC timeout = 30 while True: v = get_vars(self.port) if v: break timeout = wait_step('waiting for vtctld to start', timeout, sleep_time=0.2) # save the running instance so vtctl commands can be remote executed now protocol = protocols_flavor().vtctl_python_client_protocol() port = self.port if protocol == "grpc": # import the grpc vtctl client implementation, change the port from vtctl import grpc_vtctl_client port = self.grpc_port global vtctld, vtctld_connection if not vtctld: vtctld = self vtctld_connection = vtctl_client.connect(protocol, 'localhost:%u' % port, 30) return self.proc
def start(self): args = environment.binary_args('vtctld') + [ '-debug', '--templates', environment.vttop + '/go/cmd/vtctld/templates', '--log_dir', environment.vtlogroot, '--port', str(self.port), '--schema_change_dir', self.schema_change_dir, '--schema_change_controller', 'local', '--schema_change_check_interval', '1', '-tablet_manager_protocol', protocols_flavor().tablet_manager_protocol(), ] + \ environment.topo_server().flags() + \ protocols_flavor().vtgate_protocol_flags() if protocols_flavor().service_map(): args.extend(['-service_map', ",".join(protocols_flavor().service_map())]) if protocols_flavor().vtctl_client_protocol() == 'grpc': args.extend(['-grpc_port', str(self.grpc_port)]) stderr_fd = open(os.path.join(environment.tmproot, 'vtctld.stderr'), 'w') self.proc = run_bg(args, stderr=stderr_fd) # wait for the process to listen to RPC timeout = 30 while True: v = get_vars(self.port) if v: break timeout = wait_step('waiting for vtctld to start', timeout, sleep_time=0.2) # save the running instance so vtctl commands can be remote executed now protocol = protocols_flavor().vtctl_client_protocol() if protocol == "grpc": # import the grpc vtctl client implementation, disabled for now: # from vtctl import grpc_vtctl_client # temporary protocol override until python client support works protocol = "gorpc" global vtctld, vtctld_connection if not vtctld: vtctld = self vtctld_connection = vtctl_client.connect( protocol, 'localhost:%u' % self.port, 30) return self.proc
def start(self): args = environment.binary_args('vtctld') + [ '-debug', '-templates', environment.vttop + '/go/cmd/vtctld/templates', '-log_dir', environment.vtlogroot, '-port', str(self.port), ] + \ environment.topo_server().flags() + \ protocols_flavor().tablet_manager_protocol_flags() if protocols_flavor().vtctl_client_protocol() == "grpc": args += [ '-grpc_port', str(self.grpc_port), '-service_map', 'grpc-vtctl' ] stderr_fd = open(os.path.join(environment.tmproot, "vtctld.stderr"), "w") self.proc = run_bg(args, stderr=stderr_fd) # wait for the process to listen to RPC timeout = 30 while True: v = get_vars(self.port) if v: break timeout = wait_step('waiting for vtctld to start', timeout, sleep_time=0.2) # save the running instance so vtctl commands can be remote executed now protocol = protocols_flavor().vtctl_client_protocol() if protocol == "grpc": # import the grpc vtctl client implementation, disabled for now: # from vtctl import grpc_vtctl_client # temporary protocol override until python client support works protocol = "gorpc" global vtctld, vtctld_connection if not vtctld: vtctld = self vtctld_connection = vtctl_client.connect( protocol, 'localhost:%u' % self.port, 30) return self.proc
def start(self): args = environment.binary_args('vtctld') + [ '-debug', '-templates', environment.vttop + '/go/cmd/vtctld/templates', '-log_dir', environment.vtlogroot, '-port', str(self.port), ] + \ environment.topo_server().flags() + \ protocols_flavor().tablet_manager_protocol_flags() if protocols_flavor().vtctl_client_protocol() == "grpc": args += ['-grpc_port', str(self.grpc_port), '-service_map', 'grpc-vtctl'] stderr_fd = open(os.path.join(environment.tmproot, "vtctld.stderr"), "w") self.proc = run_bg(args, stderr=stderr_fd) # wait for the process to listen to RPC timeout = 30 while True: v = get_vars(self.port) if v: break timeout = wait_step('waiting for vtctld to start', timeout, sleep_time=0.2) # save the running instance so vtctl commands can be remote executed now protocol = protocols_flavor().vtctl_client_protocol() # temporary protocol override until python client support works if protocol == "grpc": protocol = "gorpc" global vtctld, vtctld_connection if not vtctld: vtctld = self vtctld_connection = vtctl_client.connect( protocol, 'localhost:%u' % self.port, 30) return self.proc
def __init__(self, protocol, vtctl_addr): self.protocol = protocol self.client = None self.vtctl_addr = vtctl_addr if vtctl_addr and protocol != 'grpc': self.client = vtctl_client.connect(protocol, vtctl_addr, 30)