Beispiel #1
0
 def deploy(self, vardir=None, silent=True, need_init=True):
     self.vardir = vardir
     if not os.access(self.vardir, os.F_OK):
         os.makedirs(self.vardir)
     if self.lua_libs:
         for i in self.lua_libs:
             source = os.path.join(self.testdir, i)
             try:
                 if os.path.isdir(source):
                     shutil.copytree(source,
                                     os.path.join(self.vardir,
                                                  os.path.basename(source)))
                 else:
                     shutil.copy(source, self.vardir)
             except IOError as e:
                 if (e.errno == errno.ENOENT):
                     continue
                 raise
     if self.use_unix_sockets_iproto:
         path = os.path.join(self.vardir, self.name + ".socket-iproto")
         warn_unix_socket(path)
         self.iproto = path
     else:
         self.iproto = str(find_port())
     shutil.copy(os.path.join(self.TEST_RUN_DIR, 'test_run.lua'),
                 self.vardir)
Beispiel #2
0
    def install(self, silent=True):
        if self._start_against_running:
            self._iproto = self._start_against_running
            self._admin = int(self._start_against_running) + 1
            return
        color_log('Installing the server ...\n', schema='serv_text')
        color_log('    Found executable at ', schema='serv_text')
        color_log(self.binary + '\n', schema='path')
        color_log('    Found tarantoolctl at  ', schema='serv_text')
        color_log(self.ctl_path + '\n', schema='path')
        color_log('    Creating and populating working directory in ',
                  schema='serv_text')
        color_log(self.vardir + ' ...\n', schema='path')
        if not os.path.exists(self.vardir):
            os.makedirs(self.vardir)
        else:
            color_log('    Found old vardir, deleting ...\n',
                      schema='serv_text')
            self.kill_old_server()
            self.cleanup()
        self.copy_files()

        if self.use_unix_sockets:
            self._admin = os.path.join(self.vardir, "socket-admin")
        else:
            self._admin = find_port()

        self._iproto = find_port()

        # these sockets will be created by tarantool itself
        path = os.path.join(self.vardir, self.name + '.control')
        warn_unix_socket(path)
Beispiel #3
0
 def _new_connection(self):
     result = None
     # https://github.com/tarantool/tarantool/issues/3806
     # We should set FD_CLOEXEC before connect(), because connect() is
     # blocking operation and with gevent it can wakeup another greenlet,
     # including one in which we do Popen. When FD_CLOEXEC was set after
     # connect() we observed socket file descriptors leaking into tarantool
     # server in case of unix socket. It was not observed in case of tcp
     # sockets for unknown reason, so now we leave setting FD_CLOEXEC after
     # connect for tcp sockets and fix it only for unix sockets.
     if self.host == 'unix/' or re.search(r'^/', str(self.port)):
         warn_unix_socket(self.port)
         result = gsocket.socket(gsocket.AF_UNIX, gsocket.SOCK_STREAM)
         set_fd_cloexec(result.fileno())
         result.connect(self.port)
     else:
         result = gsocket.create_connection((self.host, self.port))
         result.setsockopt(gsocket.SOL_TCP, gsocket.TCP_NODELAY, 1)
         set_fd_cloexec(result.fileno())
     return result
Beispiel #4
0
    def install(self, silent=True):
        if self._start_against_running:
            self._iproto = self._start_against_running
            self._admin = int(self._start_against_running) + 1
            return
        color_log('Installing the server ...\n', schema='serv_text')
        color_log('    Found executable at ', schema='serv_text')
        color_log(self.binary + '\n', schema='path')
        color_log('    Found tarantoolctl at  ', schema='serv_text')
        color_log(self.ctl_path + '\n', schema='path')
        color_log('    Creating and populating working directory in ',
                  schema='serv_text')
        color_log(self.vardir + ' ...\n', schema='path')
        if not os.path.exists(self.vardir):
            os.makedirs(self.vardir)
        else:
            color_log('    Found old workdir, deleting ...\n',
                      schema='serv_text')
            self.kill_old_server()
            self.cleanup()
        self.copy_files()

        if self.use_unix_sockets:
            path = os.path.join(self.vardir, self.name + ".socket-admin")
            warn_unix_socket(path)
            self._admin = path
        else:
            self._admin = find_port()

        if self.use_unix_sockets_iproto:
            path = os.path.join(self.vardir, self.name + ".socket-iproto")
            warn_unix_socket(path)
            self._iproto = path
        else:
            self._iproto = find_port()

        # these sockets will be created by tarantool itself
        path = os.path.join(self.vardir, self.name + '.control')
        warn_unix_socket(path)
Beispiel #5
0
    def install(self, silent=True):
        if self._start_against_running:
            self._iproto = self._start_against_running
            self._admin = int(self._start_against_running) + 1
            return
        color_log('DEBUG: [Instance {}] Installing the server...\n'.format(
            self.name), schema='info')
        color_log(' | Found executable at {}\n'.format(self.binary))
        color_log(' | Found tarantoolctl at {}\n'.format(self.ctl_path))
        color_log(' | Creating and populating working directory in '
                  '{}...\n'.format(self.vardir))
        if not os.path.exists(self.vardir):
            os.makedirs(self.vardir)
        else:
            color_log(' | Found old workdir, deleting...\n')
            self.kill_old_server()
            self.cleanup()
        self.copy_files()

        if self.use_unix_sockets:
            path = os.path.join(self.vardir, self.name + ".socket-admin")
            warn_unix_socket(path)
            self._admin = path
        else:
            self._admin = find_port()

        if self.use_unix_sockets_iproto:
            path = os.path.join(self.vardir, self.name + ".socket-iproto")
            warn_unix_socket(path)
            self._iproto = path
        else:
            self._iproto = find_port()

        # these sockets will be created by tarantool itself
        path = os.path.join(self.vardir, self.name + '.control')
        warn_unix_socket(path)
Beispiel #6
0
 def __init__(self, host, port):
     self.host = host
     self.port = port
     self.is_connected = False
     if self.host == 'unix/' or re.search(r'^/', str(self.port)):
         warn_unix_socket(self.port)