コード例 #1
0
    def configure_rsyslog(cls, node, enable_ngrok=False):
        ContainerManager.run_container(node, "rsyslog", logdir=cls.logdir())
        cls._link_running_syslog_logdir(node.rsyslog_log_dir)
        port = node.rsyslog_port
        LOGGER.info("rsyslog listen on port %s (config: %s)", port,
                    node.rsyslog_confpath)

        if enable_ngrok:
            requests.delete('http://localhost:4040/api/tunnels/rsyslogd')

            tunnel = {
                "addr": port,
                "proto": "tcp",
                "name": "rsyslogd",
                "bind_tls": False
            }
            res = requests.post('http://localhost:4040/api/tunnels',
                                json=tunnel)
            assert res.ok, "failed to add a ngrok tunnel [{}, {}]".format(
                res, res.text)
            ngrok_address = res.json()['public_url'].replace('tcp://', '')

            address, port = ngrok_address.split(':')
        else:
            address = get_my_ip()

        cls.RSYSLOG_ADDRESS = (address, port)
コード例 #2
0
 def configure_syslogng(cls, node):
     ContainerManager.run_container(node, "syslogng", logdir=cls.logdir())
     cls._link_running_syslog_logdir(node.syslogng_log_dir)
     port = node.syslogng_port
     LOGGER.info("syslog-ng listen on port %s (config: %s)", port,
                 node.syslogng_confpath)
     address = get_my_ip()
     cls.RSYSLOG_ADDRESS = (address, port)
コード例 #3
0
 def configure_ldap(cls, node, use_ssl=False):
     ContainerManager.run_container(node, "ldap")
     if use_ssl:
         port = node.ldap_ports['ldap_ssl_port']
     else:
         port = node.ldap_ports['ldap_port']
     address = get_my_ip()
     cls.LDAP_ADDRESS = (address, port)
     if ContainerManager.get_container(node, 'ldap').exec_run("timeout 30s container/tool/wait-process")[0] != 0:
         raise LdapServerNotReady("LDAP server didn't finish its startup yet...")
コード例 #4
0
def start_metrics_server():
    """
    https://github.com/prometheus/prometheus/wiki/Default-port-allocations
    Occupied port 9389 for SCT
    """
    try:
        LOGGER.debug('Try to start prometheus API server')
        httpd = start_http_server(0)
        port = httpd.server_port
        ip = get_my_ip()
        LOGGER.info('prometheus API server running on port: %s', port)
        return '{}:{}'.format(ip, port)
    except Exception as ex:  # pylint: disable=broad-except
        LOGGER.error('Cannot start local http metrics server: %s', ex)

    return None
コード例 #5
0
    def from_sct_config(cls, test_id: UUID, test_module_path: str,
                        sct_config: SCTConfiguration) -> TestRunWithHeartbeat:
        # pylint: disable=too-many-locals
        if cls.TESTRUN_INSTANCE:
            raise ArgusTestRunError("Instance already initialized")

        release_name = os.getenv("GIT_BRANCH", get_git_current_branch()).split("/")[-1]
        if release_name not in cls.AVAILABLE_RELEASES:
            raise ArgusTestRunError("Refusing to track a non-whitelisted branch", release_name, cls.AVAILABLE_RELEASES)
        LOGGER.info("Preparing Test Details...")
        test_group, *_ = test_module_path.split(".")
        config_files = sct_config.get("config_files")
        job_name = get_job_name()
        job_url = get_job_url()
        started_by = get_username()

        details = TestDetails(name=get_test_name(), scm_revision_id=get_git_commit_id(), started_by=started_by,
                              build_job_name=job_name, build_job_url=job_url,
                              yaml_test_duration=sct_config.get("test_duration"), start_time=int(time.time()),
                              config_files=config_files, packages=[])
        LOGGER.info("Preparing Resource Setup...")
        backend = sct_config.get("cluster_backend")
        raw_regions = sct_config.get("region_name") or sct_config.get("gce_datacenter") or "undefined_region"
        regions = raw_regions.split()
        primary_region = regions[0]

        sct_runner_info = CloudInstanceDetails(public_ip=get_sct_runner_ip(), provider=backend,
                                               region=primary_region, private_ip=get_my_ip())

        cloud_setup = cls.BACKEND_MAP.get(backend, _prepare_unknown_resource_setup)(sct_config)

        setup_details = TestResourcesSetup(sct_runner_host=sct_runner_info, region_name=regions,
                                           cloud_setup=cloud_setup)

        logs = TestLogs()
        resources = TestResources()
        results = TestResults(status=TestStatus.CREATED)

        run_info = TestRunInfo(details=details, setup=setup_details, resources=resources, logs=logs, results=results)
        LOGGER.info("Initializing TestRun...")
        cls.TESTRUN_INSTANCE = TestRunWithHeartbeat(test_id=test_id, group=test_group, release_name=release_name,
                                                    assignee="",
                                                    run_info=run_info,
                                                    config=cls.config())

        return cls.TESTRUN_INSTANCE
コード例 #6
0
    def from_sct_config(cls, test_id: UUID,
                        sct_config: SCTConfiguration) -> TestRunWithHeartbeat:
        # pylint: disable=too-many-locals
        if cls.TESTRUN_INSTANCE:
            raise ArgusTestRunError("Instance already initialized")

        LOGGER.info("Preparing Test Details...")
        job_name = get_job_name()
        job_url = get_job_url()
        if job_name == "local_run":
            raise ArgusTestRunError("Will not track a locally run job")

        config_files = sct_config.get("config_files")
        started_by = get_username()

        details = TestDetails(
            scm_revision_id=get_git_commit_id(),
            started_by=started_by,
            build_job_url=job_url,
            yaml_test_duration=sct_config.get("test_duration"),
            start_time=datetime.utcnow().replace(microsecond=0),
            config_files=config_files,
            packages=[])

        LOGGER.info("Preparing Resource Setup...")
        backend = sct_config.get("cluster_backend")
        region_key = cls.REGION_PROPERTY_MAP.get(
            backend, cls.REGION_PROPERTY_MAP["default"])
        raw_regions = sct_config.get(region_key) or "undefined_region"
        regions = raw_regions.split() if isinstance(raw_regions,
                                                    str) else raw_regions
        primary_region = regions[0]

        sct_runner_info = CloudInstanceDetails(public_ip=get_sct_runner_ip(),
                                               provider=backend,
                                               region=primary_region,
                                               private_ip=get_my_ip())

        cloud_setup = cls.BACKEND_MAP.get(
            backend, _prepare_unknown_resource_setup)(sct_config)

        setup_details = TestResourcesSetup(sct_runner_host=sct_runner_info,
                                           region_name=regions,
                                           cloud_setup=cloud_setup)

        logs = TestLogs()
        resources = TestResources()
        results = TestResults(status=TestStatus.CREATED)

        run_info = TestRunInfo(details=details,
                               setup=setup_details,
                               resources=resources,
                               logs=logs,
                               results=results)
        LOGGER.info("Initializing TestRun...")
        cls.TESTRUN_INSTANCE = TestRunWithHeartbeat(test_id=test_id,
                                                    build_id=job_name,
                                                    assignee=None,
                                                    run_info=run_info,
                                                    config=cls.config())

        return cls.TESTRUN_INSTANCE