Пример #1
0
    def _scylla_service_is_up(self):
        srv_manager = service.ServiceManager()
        try:
            journalctl_cmd = path.find_command('journalctl')
            timestamp = '--since "%s"' % self.start_time if self.start_time else ''
            result = process.run('sudo %s --no-tail '
                                 '-u scylla-io-setup.service '
                                 '-u scylla-server.service '
                                 '-u scylla-ami-setup.service '
                                 '-u scylla-housekeeping-daily.service '
                                 '-u scylla-housekeeping-restart.service '
                                 '-u scylla-jmx.service '
                                 '%s' % (journalctl_cmd, timestamp),
                                 ignore_status=True)
        except path.CmdNotFoundError:
            result = process.run('cat /var/log/syslog | grep scylla',
                                 shell=True,
                                 ignore_status=True)
        error_list = [
            'I/O Scheduler is not properly configured!',
            'Failed to start Scylla Server', 'failed to write into /proc/irq'
        ]
        for err in error_list:
            if err in result.stdout:
                raise StartServiceError(
                    'Fail to start scylla-server, err: %s' % err)

        for srv in self.services:
            srv_manager.status(srv)
        return not network.is_port_free(9042, 'localhost')
Пример #2
0
 def register_port(self, port):
     if ((port not in self.retained_ports)
             and (network.is_port_free(port, self.address))):
         self.retained_ports.append(port)
     else:
         raise ValueError('Port %d in use' % port)
     return port
Пример #3
0
 def register_port(self, port):
     if ((port not in self.retained_ports) and
             (network.is_port_free(port, self.address))):
         self.retained_ports.append(port)
     else:
         raise ValueError('Port %d in use' % port)
     return port
Пример #4
0
 def find_free_port(self, start_port=None):
     if start_port is None:
         start_port = self.start_port
     port = start_port
     while ((port in self.retained_ports)
            or (not network.is_port_free(port, self.address))):
         port += 1
     self.retained_ports.append(port)
     return port
Пример #5
0
 def find_free_port(self, start_port=None):
     if start_port is None:
         start_port = self.start_port
     port = start_port
     while ((port in self.retained_ports) or
            (not network.is_port_free(port, self.address))):
         port += 1
     self.retained_ports.append(port)
     return port
Пример #6
0
 def test_is_port_free(self):
     port = network.find_free_port(sequent=False)
     self.assertTrue(network.is_port_free(port, "localhost"))
     local_addrs = get_all_local_addrs()
     ipv4_addrs = ["localhost", ""] + list(local_addrs[0])
     ipv6_addrs = ["localhost", ""] + list(local_addrs[1])
     good = []
     bad = []
     skip = []
     sock = None
     for family in network.FAMILIES:
         if family == socket.AF_INET:
             addrs = ipv4_addrs
         else:
             addrs = ipv6_addrs
         for addr in addrs:
             for protocol in network.PROTOCOLS:
                 try:
                     sock = socket.socket(family, protocol)
                     sock.bind((addr, port))
                     if network.is_port_free(port, "localhost"):
                         bad.append("%s, %s, %s: reports free" %
                                    (family, protocol, addr))
                     else:
                         good.append("%s, %s, %s" %
                                     (family, protocol, addr))
                 except Exception as exc:
                     if getattr(exc, 'errno', None) in (-2, 2, 22, 94):
                         skip.append("%s, %s, %s: Not supported: %s" %
                                     (family, protocol, addr, exc))
                     else:
                         bad.append("%s, %s, %s: Failed to bind: %s" %
                                    (family, protocol, addr, exc))
                 finally:
                     if sock is not None:
                         sock.close()
     self.assertFalse(
         bad, "Following combinations failed:\n%s\n\n"
         "Following combinations passed:\n%s\n\n"
         "Following combinations were skipped:\n%s" %
         ("\n".join(bad), "\n".join(good), "\n".join(skip)))
Пример #7
0
 def test_is_port_free(self):
     port = network.find_free_port(sequent=False)
     self.assertTrue(network.is_port_free(port, "localhost"))
     local_addrs = get_all_local_addrs()
     ipv4_addrs = ["localhost", ""] + list(local_addrs[0])
     ipv6_addrs = ["localhost", ""] + list(local_addrs[1])
     good = []
     bad = []
     skip = []
     sock = None
     for family in network.FAMILIES:
         if family == socket.AF_INET:
             addrs = ipv4_addrs
         else:
             addrs = ipv6_addrs
         for addr in addrs:
             for protocol in network.PROTOCOLS:
                 try:
                     sock = socket.socket(family, protocol)
                     sock.bind((addr, port))
                     if network.is_port_free(port, "localhost"):
                         bad.append("%s, %s, %s: reports free"
                                    % (family, protocol, addr))
                     else:
                         good.append("%s, %s, %s" % (family, protocol,
                                                     addr))
                 except Exception as exc:
                     if getattr(exc, 'errno', None) in (-2, 2, 22, 94):
                         skip.append("%s, %s, %s: Not supported: %s"
                                     % (family, protocol, addr, exc))
                     else:
                         bad.append("%s, %s, %s: Failed to bind: %s"
                                    % (family, protocol, addr, exc))
                 finally:
                     if sock is not None:
                         sock.close()
     self.assertFalse(bad, "Following combinations failed:\n%s\n\n"
                      "Following combinations passed:\n%s\n\n"
                      "Following combinations were skipped:\n%s"
                      % ("\n".join(bad), "\n".join(good), "\n".join(skip)))
Пример #8
0
def start_metrics_server(port=9389):
    """
    https://github.com/prometheus/prometheus/wiki/Default-port-allocations
    Occupied port 9389 for SCT
    """
    hostname = socket.gethostname()
    if not network.is_port_free(port, hostname):
        port = network.find_free_port(8001, 10000)

    try:
        logger.debug('Try to start prometheus API server on port: %s', port)
        prometheus_client.start_http_server(port)
        ip = socket.gethostbyname(hostname)
        return '{}:{}'.format(ip, port)
    except Exception as ex:
        logger.error('Cannot start local http metrics server: %s', ex)

    return None
Пример #9
0
def start_metrics_server(port=9389):
    """
    https://github.com/prometheus/prometheus/wiki/Default-port-allocations
    Occupied port 9389 for SCT
    """
    hostname = socket.gethostname()
    if not network.is_port_free(port, hostname):
        port = network.find_free_port(8001, 10000)

    try:
        logger.debug('Try to start prometheus API server on port: %s', port)
        prometheus_client.start_http_server(port)
        ip = socket.gethostbyname(hostname)
        return '{}:{}'.format(ip, port)
    except Exception as ex:
        logger.error('Cannot start local http metrics server: %s', ex)

    return None
 def _scylla_service_is_up(self):
     srv_manager = service.ServiceManager()
     for srv in self.services:
         srv_manager.status(srv)
     return not network.is_port_free(9042, 'localhost')