コード例 #1
0
def _setup_primary_node(config):
    """
    Setup the environment for integration tests.

    This function will:
        - check runtime compatibility (Docker, docker-compose, Nginx)
        - create a temporary workspace and the persistent GIT repositories space
        - configure and start a DNS server using Docker, if configured
        - configure and start paralleled ACME CA servers using Docker
        - transfer ACME CA and DNS servers configurations to pytest nodes using env variables

    This function modifies `config` by injecting the ACME CA and DNS server configurations,
    in addition to cleanup functions for those servers.

    :param config: Configuration of the pytest primary node. Is modified by this function.
    """
    # Check for runtime compatibility: some tools are required to be available in PATH
    if 'boulder' in config.option.acme_server:
        try:
            subprocess.check_output(['docker', '-v'], stderr=subprocess.STDOUT)
        except (subprocess.CalledProcessError, OSError):
            raise ValueError(
                'Error: docker is required in PATH to launch the integration tests on'
                'boulder, but is not installed or not available for current user.'
            )

        try:
            subprocess.check_output(['docker-compose', '-v'],
                                    stderr=subprocess.STDOUT)
        except (subprocess.CalledProcessError, OSError):
            raise ValueError(
                'Error: docker-compose is required in PATH to launch the integration tests, '
                'but is not installed or not available for current user.')

    # Parameter numprocesses is added to option by pytest-xdist
    workers = ['primary'] if not config.option.numprocesses\
        else ['gw{0}'.format(i) for i in range(config.option.numprocesses)]

    # If a non-default DNS server is configured, start it and feed it to the ACME server
    dns_server = None
    acme_dns_server = None
    if config.option.dns_server == 'bind':
        dns_server = dns_lib.DNSServer(workers)
        config.add_cleanup(dns_server.stop)
        print('DNS xdist config:\n{0}'.format(dns_server.dns_xdist))
        dns_server.start()
        acme_dns_server = '{}:{}'.format(dns_server.dns_xdist['address'],
                                         dns_server.dns_xdist['port'])

    # By calling setup_acme_server we ensure that all necessary acme server instances will be
    # fully started. This runtime is reflected by the acme_xdist returned.
    acme_server = acme_lib.ACMEServer(config.option.acme_server,
                                      workers,
                                      dns_server=acme_dns_server)
    config.add_cleanup(acme_server.stop)
    print('ACME xdist config:\n{0}'.format(acme_server.acme_xdist))
    acme_server.start()

    config.acme_xdist = acme_server.acme_xdist
    config.dns_xdist = dns_server.dns_xdist if dns_server else None
コード例 #2
0
def main(args=None):
    if not args:
        args = sys.argv[1:]
    with acme_server.ACMEServer('pebble', [], False) as acme_xdist:
        environ = os.environ.copy()
        environ['SERVER'] = acme_xdist['directory_url']
        command = [os.path.join(SCRIPT_DIRNAME, 'apache-conf-test')]
        command.extend(args)
        return subprocess.call(command, env=environ)
コード例 #3
0
def _setup_primary_node(config):
    """
    Setup the environment for integration tests.
    Will:
        - check runtime compatiblity (Docker, docker-compose, Nginx)
        - create a temporary workspace and the persistent GIT repositories space
        - configure and start paralleled ACME CA servers using Docker
        - transfer ACME CA servers configurations to pytest nodes using env variables
    :param config: Configuration of the pytest primary node
    """
    # Check for runtime compatibility: some tools are required to be available in PATH
    if 'boulder' in config.option.acme_server:
        try:
            subprocess.check_output(['docker', '-v'], stderr=subprocess.STDOUT)
        except (subprocess.CalledProcessError, OSError):
            raise ValueError(
                'Error: docker is required in PATH to launch the integration tests on'
                'boulder, but is not installed or not available for current user.'
            )

        try:
            subprocess.check_output(['docker-compose', '-v'],
                                    stderr=subprocess.STDOUT)
        except (subprocess.CalledProcessError, OSError):
            raise ValueError(
                'Error: docker-compose is required in PATH to launch the integration tests, '
                'but is not installed or not available for current user.')

    # Parameter numprocesses is added to option by pytest-xdist
    workers = ['primary'] if not config.option.numprocesses\
        else ['gw{0}'.format(i) for i in range(config.option.numprocesses)]

    # By calling setup_acme_server we ensure that all necessary acme server instances will be
    # fully started. This runtime is reflected by the acme_xdist returned.
    acme_server = acme_lib.ACMEServer(config.option.acme_server, workers)
    config.add_cleanup(acme_server.stop)
    print('ACME xdist config:\n{0}'.format(acme_server.acme_xdist))
    acme_server.start()

    return acme_server.acme_xdist