MCPcopy Index your code
hub / github.com/certbot/certbot / _setup_primary_node

Function _setup_primary_node

certbot-ci/src/certbot_integration_tests/conftest.py:62–103  ·  view source on GitHub ↗

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

(config)

Source from the content-addressed store, hash-verified

60
61
62def _setup_primary_node(config):
63 """
64 Setup the environment for integration tests.
65
66 This function will:
67 - check runtime compatibility (Docker, docker compose, Nginx)
68 - create a temporary workspace and the persistent GIT repositories space
69 - configure and start a DNS server using Docker, if configured
70 - configure and start paralleled ACME CA servers using Docker
71 - transfer ACME CA and DNS servers configurations to pytest nodes using env variables
72
73 This function modifies `config` by injecting the ACME CA and DNS server configurations,
74 in addition to cleanup functions for those servers.
75
76 :param config: Configuration of the pytest primary node. Is modified by this function.
77 """
78 # Parameter numprocesses is added to option by pytest-xdist
79 workers = ['primary'] if not config.option.numprocesses\
80 else ['gw{0}'.format(i) for i in range(config.option.numprocesses)]
81
82 # If a non-default DNS server is configured, start it and feed it to the ACME server
83 dns_server = None
84 acme_dns_server = None
85 if config.option.dns_server == 'bind':
86 dns_server = dns_lib.DNSServer(workers)
87 config.add_cleanup(dns_server.stop)
88 print('DNS xdist config:\n{0}'.format(dns_server.dns_xdist))
89 dns_server.start()
90 acme_dns_server = '{}:{}'.format(
91 dns_server.dns_xdist['address'],
92 dns_server.dns_xdist['port']
93 )
94
95 # By calling setup_acme_server we ensure that all necessary acme server instances will be
96 # fully started. This runtime is reflected by the acme_xdist returned.
97 acme_server = acme_lib.ACMEServer(workers, dns_server=acme_dns_server)
98 config.add_cleanup(acme_server.stop)
99 print('ACME xdist config:\n{0}'.format(acme_server.acme_xdist))
100 acme_server.start()
101
102 config.acme_xdist = acme_server.acme_xdist
103 config.dns_xdist = dns_server.dns_xdist if dns_server else None

Callers 1

pytest_configureFunction · 0.85

Calls 3

startMethod · 0.95
startMethod · 0.95
formatMethod · 0.80

Tested by

no test coverage detected