Пример #1
0
    def wait_start(self):
        """Start the process and wait for it to respond on HTTP."""

        for _ in xrange(0, self.START_RETRIES):
            self.port = environment.get_port(self.port_name)
            if environment.get_protocol() == "grpc":
                self.grpc_port = environment.get_port(self.port_name, protocol="grpc")
            else:
                self.grpc_port = None
            logs_subdirectory = environment.get_logs_directory(self.directory)
            cmd = [self.binary, "-port", "%u" % self.port, "-log_dir", logs_subdirectory]
            if environment.get_protocol() == "grpc":
                cmd.extend(["-grpc_port", "%u" % self.grpc_port])
            cmd.extend(self.extraparams)
            logging.info("Starting process: %s", cmd)
            stdout = os.path.join(logs_subdirectory, "%s.%d.log" % (self.name, self.port))
            self.stdout = open(stdout, "w")
            self.process = subprocess.Popen(cmd, stdout=self.stdout, stderr=subprocess.STDOUT)
            timeout = time.time() + 60.0
            while time.time() < timeout:
                if environment.process_is_healthy(self.name, self.addr()) and self.get_vars():
                    logging.info("%s started.", self.name)
                    return
                elif self.process.poll() is not None:
                    logging.error("%s process exited prematurely.", self.name)
                    break
                time.sleep(0.3)

            logging.error("cannot start %s process on time: %s ", self.name, socket.getfqdn())
            self.kill()

        raise Exception("Failed %d times to run %s" % (self.START_RETRIES, self.name))
Пример #2
0
    def wait_start(self):
        """Start the process and wait for it to respond on HTTP."""

        for _ in xrange(0, self.START_RETRIES):
            self.port = environment.get_port(self.port_name,
                                             instance=self.port_instance)
            if environment.get_protocol() == 'grpc':
                self.grpc_port = environment.get_port(
                    self.port_name,
                    instance=self.port_instance,
                    protocol='grpc')
            else:
                self.grpc_port = None
            logs_subdirectory = environment.get_logs_directory(self.directory)
            cmd = [
                self.binary,
                '-port',
                '%u' % self.port,
                '-log_dir',
                logs_subdirectory,
            ]
            if environment.get_protocol() == 'grpc':
                cmd.extend(['-grpc_port', '%u' % self.grpc_port])
            cmd.extend(self.extraparams)
            logging.info('Starting process: %s', cmd)
            stdout = os.path.join(logs_subdirectory,
                                  '%s.%d.log' % (self.name, self.port))
            self.stdout = open(stdout, 'w')
            self.process = subprocess.Popen(cmd,
                                            stdout=self.stdout,
                                            stderr=subprocess.STDOUT)
            timeout = time.time() + 60.0
            while time.time() < timeout:
                if environment.process_is_healthy(
                        self.name, self.addr()) and self.get_vars():
                    logging.info('%s started.', self.name)
                    return
                elif self.process.poll() is not None:
                    logging.error('%s process exited prematurely.', self.name)
                    break
                time.sleep(0.3)

            logging.error('cannot start %s process on time: %s ', self.name,
                          socket.getfqdn())
            self.kill()

        raise Exception('Failed %d times to run %s' %
                        (self.START_RETRIES, self.name))
Пример #3
0
 def __init__(self,
              directory,
              topology,
              mysql_db,
              schema_dir,
              charset,
              web_dir=None,
              web_dir2=None):
     VtProcess.__init__(self,
                        'vtcombo-%s' % os.environ['USER'],
                        directory,
                        environment.vtcombo_binary,
                        port_name='vtcombo')
     self.extraparams = [
         '-db-config-app-charset',
         charset,
         '-db-config-app-uname',
         mysql_db.username(),
         '-db-config-app-pass',
         mysql_db.password(),
         '-db-config-dba-charset',
         charset,
         '-db-config-dba-uname',
         mysql_db.username(),
         '-db-config-dba-pass',
         mysql_db.password(),
         '-proto_topo',
         text_format.MessageToString(topology, as_one_line=True),
         '-mycnf_server_id',
         '1',
         '-mycnf_socket_file',
         mysql_db.unix_socket(),
         '-normalize_queries',
     ] + self.QUERYSERVER_PARAMETERS + environment.extra_vtcombo_parameters(
     )
     if schema_dir:
         self.extraparams.extend(['-schema_dir', schema_dir])
     if web_dir:
         self.extraparams.extend(['-web_dir', web_dir])
     if web_dir2:
         self.extraparams.extend(['-web_dir2', web_dir2])
     if mysql_db.unix_socket():
         self.extraparams.extend([
             '-db-config-app-unixsocket',
             mysql_db.unix_socket(), '-db-config-dba-unixsocket',
             mysql_db.unix_socket()
         ])
     else:
         self.extraparams.extend([
             '-db-config-app-host',
             mysql_db.hostname(), '-db-config-app-port',
             str(mysql_db.port()), '-db-config-dba-host',
             mysql_db.hostname(), '-db-config-dba-port',
             str(mysql_db.port())
         ])
     self.vtcombo_mysql_port = environment.get_port('vtcombo_mysql_port')
     self.extraparams.extend([
         '-mysql_auth_server_impl', 'none', '-mysql_server_port',
         str(self.vtcombo_mysql_port)
     ])
Пример #4
0
    def setup(self):
        """Create a MySQL instance and all Vitess processes."""
        mysql_port = environment.get_port('mysql')
        self.directory = environment.get_test_directory()
        self.mysql_db = environment.mysql_db_class(self.directory, mysql_port,
                                                   self.extra_my_cnf,
                                                   self.snapshot_file)

        self.mysql_db.setup()
        if not self.snapshot_file:
            self.create_databases()
            self.load_schema()
        if self.init_data_options is not None:
            self.rng = random.Random(self.init_data_options.rng_seed)
            self.populate_with_random_data()
        if self.mysql_only:
            return

        vt_processes.start_vt_processes(
            self.directory,
            self.topology,
            self.mysql_db,
            self.schema_dir,
            charset=self.charset,
            web_dir=self.web_dir,
            web_dir2=self.web_dir2,
            mysql_server_bind_address=self.mysql_server_bind_address)
Пример #5
0
 def __init__(self, directory, topology, mysql_db, schema_dir, charset,
              mysql_server_bind_address=None):
   VtProcess.__init__(self, 'vtcombo-%s' % os.environ['USER'], directory,
                      environment.vtcombo_binary, port_name='vtcombo')
   self.extraparams = [
       '-db_charset', charset,
       '-db_app_user', mysql_db.username(),
       '-db_app_password', mysql_db.password(),
       '-db_dba_user', mysql_db.username(),
       '-db_dba_password', mysql_db.password(),
       '-proto_topo', text_format.MessageToString(topology, as_one_line=True),
       '-mycnf_server_id', '1',
       '-mycnf_socket_file', mysql_db.unix_socket(),
       '-normalize_queries',
   ] + self.QUERYSERVER_PARAMETERS + environment.extra_vtcombo_parameters()
   if schema_dir:
     self.extraparams.extend(['-schema_dir', schema_dir])
   if mysql_db.unix_socket():
     self.extraparams.extend(['-db_socket', mysql_db.unix_socket()])
   else:
     self.extraparams.extend(
         ['-db_host', mysql_db.hostname(),
          '-db_port', str(mysql_db.port())])
   self.vtcombo_mysql_port = environment.get_port('vtcombo_mysql_port')
   if mysql_server_bind_address:
       # Binding to 0.0.0.0 instead of localhost makes it possible to connect to vtgate from outside a docker container
       self.extraparams.extend(['-mysql_server_bind_address', mysql_server_bind_address])
   else:
       self.extraparams.extend(['-mysql_server_bind_address', 'localhost'])
   self.extraparams.extend(
       ['-mysql_auth_server_impl', 'none',
        '-mysql_server_port', str(self.vtcombo_mysql_port)])
Пример #6
0
  def setup(self):
    """Create a MySQL instance and all Vitess processes."""
    mysql_port = environment.get_port('mysql')
    self.directory = environment.get_test_directory()
    self.mysql_db = environment.mysql_db_class(self.directory, mysql_port)

    self.mysql_db.setup()
    self.create_databases()
    self.load_schema()

    vt_processes.start_vt_processes(self.directory, self.shards, self.mysql_db)
Пример #7
0
    def setup(self):
        """Create a MySQL instance and all Vitess processes."""
        mysql_port = environment.get_port('mysql')
        self.directory = environment.get_test_directory()
        self.mysql_db = environment.mysql_db_class(self.directory, mysql_port)

        self.mysql_db.setup()
        self.create_databases()
        self.load_schema()

        vt_processes.start_vt_processes(self.directory, self.shards,
                                        self.mysql_db)
Пример #8
0
  def setup(self):
    """Create a MySQL instance and all Vitess processes."""
    mysql_port = environment.get_port('mysql')
    self.directory = environment.get_test_directory()
    self.mysql_db = environment.mysql_db_class(self.directory, mysql_port)

    self.mysql_db.setup()
    self.create_databases()
    self.load_schema()
    if self.init_data_options is not None:
      self.rng = random.Random(self.init_data_options.rng_seed)
      self.populate_with_random_data()
    if self.mysql_only:
      return

    vt_processes.start_vt_processes(self.directory, self.topology,
                                    self.mysql_db, self.vschema,
                                    web_dir=self.web_dir)
Пример #9
0
  def wait_start(self):
    """Start the process and wait for it to respond on HTTP."""

    for _ in xrange(0, self.START_RETRIES):
      self.port = environment.get_port(self.port_name,
                                       instance=self.port_instance)
      logs_subdirectory = environment.get_logs_directory(self.directory)
      cmd = [
          self.binary,
          '-port', '%u' % self.port,
          '-log_dir', logs_subdirectory,
          ]
      cmd.extend(self.extraparams)
      logging.info('Starting process: %s', cmd)
      stdout = os.path.join(logs_subdirectory, '%s.%d.log' %
                            (self.name, self.port))
      self.stdout = open(stdout, 'w')
      self.process = subprocess.Popen(cmd,
                                      stdout=self.stdout,
                                      stderr=subprocess.STDOUT)
      timeout = time.time() + 20.0
      while time.time() < timeout:
        if environment.process_is_healthy(self.name, self.addr()) and self.get_vars():
          logging.info('%s started.', self.name)
          return
        elif self.process.poll() is not None:
          logging.error('%s process exited prematurely.', self.name)
          break
        time.sleep(0.3)

      logging.error('cannot start %s process on time: %s ',
                    self.name, socket.getfqdn())
      self.kill()

    raise Exception('Failed %d times to run %s' % (
        self.START_RETRIES,
        self.name))
Пример #10
0
 def __init__(self, directory, topology, mysql_db, schema_dir, charset,
              web_dir=None, web_dir2=None):
   VtProcess.__init__(self, 'vtcombo-%s' % os.environ['USER'], directory,
                      environment.vtcombo_binary, port_name='vtcombo')
   self.extraparams = [
       '-db-config-app-charset', charset,
       '-db-config-app-uname', mysql_db.username(),
       '-db-config-app-pass', mysql_db.password(),
       '-db-config-dba-charset', charset,
       '-db-config-dba-uname', mysql_db.username(),
       '-db-config-dba-pass', mysql_db.password(),
       '-proto_topo', text_format.MessageToString(topology, as_one_line=True),
       '-mycnf_server_id', '1',
       '-mycnf_socket_file', mysql_db.unix_socket(),
       '-normalize_queries',
   ] + self.QUERYSERVER_PARAMETERS + environment.extra_vtcombo_parameters()
   if schema_dir:
     self.extraparams.extend(['-schema_dir', schema_dir])
   if web_dir:
     self.extraparams.extend(['-web_dir', web_dir])
   if web_dir2:
     self.extraparams.extend(['-web_dir2', web_dir2])
   if mysql_db.unix_socket():
     self.extraparams.extend(
         ['-db-config-app-unixsocket', mysql_db.unix_socket(),
          '-db-config-dba-unixsocket', mysql_db.unix_socket()])
   else:
     self.extraparams.extend(
         ['-db-config-app-host', mysql_db.hostname(),
          '-db-config-app-port', str(mysql_db.port()),
          '-db-config-dba-host', mysql_db.hostname(),
          '-db-config-dba-port', str(mysql_db.port())])
   self.vtcombo_mysql_port = environment.get_port('vtcombo_mysql_port')
   self.extraparams.extend(
       ['-mysql_auth_server_impl', 'none',
        '-mysql_server_port', str(self.vtcombo_mysql_port)])