conftest.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. import contextlib
  2. import logging
  3. import os
  4. import pathlib
  5. import re
  6. import shlex
  7. import socket
  8. import subprocess
  9. import time
  10. from io import StringIO
  11. from typing import Iterator, List, Optional
  12. import backoff
  13. import docker.errors
  14. import pytest
  15. import requests
  16. from _pytest.fixtures import FixtureRequest
  17. from docker import DockerClient
  18. from docker.models.containers import Container
  19. from docker.models.networks import Network
  20. from packaging.version import Version
  21. from requests import Response
  22. from urllib3.util.connection import HAS_IPV6
  23. logging.basicConfig(level=logging.INFO)
  24. logging.getLogger('backoff').setLevel(logging.INFO)
  25. logging.getLogger('DNS').setLevel(logging.DEBUG)
  26. logging.getLogger('requests.packages.urllib3.connectionpool').setLevel(logging.WARN)
  27. CA_ROOT_CERTIFICATE = pathlib.Path(__file__).parent.joinpath("certs/ca-root.crt")
  28. PYTEST_RUNNING_IN_CONTAINER = os.environ.get('PYTEST_RUNNING_IN_CONTAINER') == "1"
  29. FORCE_CONTAINER_IPV6 = False # ugly global state to consider containers' IPv6 address instead of IPv4
  30. DOCKER_COMPOSE = os.environ.get('DOCKER_COMPOSE', 'docker compose')
  31. docker_client = docker.from_env()
  32. # Name of pytest container to reference if it's being used for running tests
  33. test_container = 'nginx-proxy-pytest'
  34. ###############################################################################
  35. #
  36. # utilities
  37. #
  38. ###############################################################################
  39. @contextlib.contextmanager
  40. def ipv6(force_ipv6: bool = True):
  41. """
  42. Meant to be used as a context manager to force IPv6 sockets:
  43. with ipv6():
  44. nginxproxy.get("http://something.nginx-proxy.example") # force use of IPv6
  45. with ipv6(False):
  46. nginxproxy.get("http://something.nginx-proxy.example") # legacy behavior
  47. """
  48. global FORCE_CONTAINER_IPV6
  49. FORCE_CONTAINER_IPV6 = force_ipv6
  50. yield
  51. FORCE_CONTAINER_IPV6 = False
  52. class RequestsForDocker:
  53. """
  54. Proxy for calling methods of the requests module.
  55. When an HTTP response failed due to HTTP Error 404 or 502, retry a few times.
  56. Provides method `get_conf` to extract the nginx-proxy configuration content.
  57. """
  58. def __init__(self):
  59. self.session = requests.Session()
  60. if CA_ROOT_CERTIFICATE.is_file():
  61. self.session.verify = CA_ROOT_CERTIFICATE.as_posix()
  62. @staticmethod
  63. def get_nginx_proxy_container() -> Container:
  64. """
  65. Return list of containers
  66. """
  67. nginx_proxy_containers = docker_client.containers.list(filters={"ancestor": "nginxproxy/nginx-proxy:test"})
  68. if len(nginx_proxy_containers) > 1:
  69. pytest.fail("Too many running nginxproxy/nginx-proxy:test containers", pytrace=False)
  70. elif len(nginx_proxy_containers) == 0:
  71. pytest.fail("No running nginxproxy/nginx-proxy:test container", pytrace=False)
  72. return nginx_proxy_containers.pop()
  73. def get_conf(self) -> bytes:
  74. """
  75. Return the nginx config file
  76. """
  77. nginx_proxy_container = self.get_nginx_proxy_container()
  78. return get_nginx_conf_from_container(nginx_proxy_container)
  79. def get_ip(self) -> str:
  80. """
  81. Return the nginx container ip address
  82. """
  83. nginx_proxy_container = self.get_nginx_proxy_container()
  84. return container_ip(nginx_proxy_container)
  85. def get(self, *args, **kwargs) -> Response:
  86. with ipv6(kwargs.pop('ipv6', False)):
  87. @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None)
  88. def _get(*_args, **_kwargs):
  89. return self.session.get(*_args, **_kwargs)
  90. return _get(*args, **kwargs)
  91. def post(self, *args, **kwargs) -> Response:
  92. with ipv6(kwargs.pop('ipv6', False)):
  93. @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None)
  94. def _post(*_args, **_kwargs):
  95. return self.session.post(*_args, **_kwargs)
  96. return _post(*args, **kwargs)
  97. def put(self, *args, **kwargs) -> Response:
  98. with ipv6(kwargs.pop('ipv6', False)):
  99. @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None)
  100. def _put(*_args, **_kwargs):
  101. return self.session.put(*_args, **_kwargs)
  102. return _put(*args, **kwargs)
  103. def head(self, *args, **kwargs) -> Response:
  104. with ipv6(kwargs.pop('ipv6', False)):
  105. @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None)
  106. def _head(*_args, **_kwargs):
  107. return self.session.head(*_args, **_kwargs)
  108. return _head(*args, **kwargs)
  109. def delete(self, *args, **kwargs) -> Response:
  110. with ipv6(kwargs.pop('ipv6', False)):
  111. @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None)
  112. def _delete(*_args, **_kwargs):
  113. return self.session.delete(*_args, **_kwargs)
  114. return _delete(*args, **kwargs)
  115. def options(self, *args, **kwargs) -> Response:
  116. with ipv6(kwargs.pop('ipv6', False)):
  117. @backoff.on_predicate(backoff.constant, lambda r: r.status_code in (404, 502), interval=.3, max_tries=30, jitter=None)
  118. def _options(*_args, **_kwargs):
  119. return self.session.options(*_args, **_kwargs)
  120. return _options(*args, **kwargs)
  121. def __getattr__(self, name):
  122. return getattr(requests, name)
  123. def container_ip(container: Container) -> str:
  124. """
  125. return the IP address of a container.
  126. If the global FORCE_CONTAINER_IPV6 flag is set, return the IPv6 address
  127. """
  128. global FORCE_CONTAINER_IPV6
  129. if FORCE_CONTAINER_IPV6:
  130. if not HAS_IPV6:
  131. pytest.skip("This system does not support IPv6")
  132. ip = container_ipv6(container)
  133. if ip == '':
  134. pytest.skip(f"Container {container.name} has no IPv6 address")
  135. else:
  136. return ip
  137. else:
  138. net_info = container.attrs["NetworkSettings"]["Networks"]
  139. if "bridge" in net_info:
  140. return net_info["bridge"]["IPAddress"]
  141. # container is running in host network mode
  142. if "host" in net_info:
  143. return "127.0.0.1"
  144. # not default bridge network, fallback on first network defined
  145. network_name = list(net_info.keys())[0]
  146. return net_info[network_name]["IPAddress"]
  147. def container_ipv6(container: Container) -> str:
  148. """
  149. return the IPv6 address of a container.
  150. """
  151. net_info = container.attrs["NetworkSettings"]["Networks"]
  152. if "bridge" in net_info:
  153. return net_info["bridge"]["GlobalIPv6Address"]
  154. # container is running in host network mode
  155. if "host" in net_info:
  156. return "::1"
  157. # not default bridge network, fallback on first network defined
  158. network_name = list(net_info.keys())[0]
  159. return net_info[network_name]["GlobalIPv6Address"]
  160. def nginx_proxy_dns_resolver(domain_name: str) -> Optional[str]:
  161. """
  162. if "nginx-proxy" if found in host, return the ip address of the docker container
  163. issued from the docker image nginxproxy/nginx-proxy:test.
  164. :return: IP or None
  165. """
  166. log = logging.getLogger('DNS')
  167. log.debug(f"nginx_proxy_dns_resolver({domain_name!r})")
  168. if 'nginx-proxy' in domain_name:
  169. nginxproxy_containers = docker_client.containers.list(filters={"status": "running", "ancestor": "nginxproxy/nginx-proxy:test"})
  170. if len(nginxproxy_containers) == 0:
  171. log.warning(f"no container found from image nginxproxy/nginx-proxy:test while resolving {domain_name!r}")
  172. exited_nginxproxy_containers = docker_client.containers.list(filters={"status": "exited", "ancestor": "nginxproxy/nginx-proxy:test"})
  173. if len(exited_nginxproxy_containers) > 0:
  174. exited_nginxproxy_container_logs = exited_nginxproxy_containers[0].logs()
  175. log.warning(f"nginxproxy/nginx-proxy:test container might have exited unexpectedly. Container logs: " + "\n" + exited_nginxproxy_container_logs.decode())
  176. return None
  177. nginxproxy_container = nginxproxy_containers[0]
  178. ip = container_ip(nginxproxy_container)
  179. log.info(f"resolving domain name {domain_name!r} as IP address {ip} of nginx-proxy container {nginxproxy_container.name}")
  180. return ip
  181. def docker_container_dns_resolver(domain_name: str) -> Optional[str]:
  182. """
  183. if domain name is of the form "XXX.container.docker" or "anything.XXX.container.docker", return the ip address of the docker container
  184. named XXX.
  185. :return: IP or None
  186. """
  187. log = logging.getLogger('DNS')
  188. log.debug(f"docker_container_dns_resolver({domain_name!r})")
  189. match = re.search(r'(^|.+\.)(?P<container>[^.]+)\.container\.docker$', domain_name)
  190. if not match:
  191. log.debug(f"{domain_name!r} does not match")
  192. return None
  193. container_name = match.group('container')
  194. log.debug(f"looking for container {container_name!r}")
  195. try:
  196. container = docker_client.containers.get(container_name)
  197. except docker.errors.NotFound:
  198. log.warning(f"container named {container_name!r} not found while resolving {domain_name!r}")
  199. return None
  200. log.debug(f"container {container.name!r} found ({container.short_id})")
  201. ip = container_ip(container)
  202. log.info(f"resolving domain name {domain_name!r} as IP address {ip} of container {container.name}")
  203. return ip
  204. def monkey_patch_urllib_dns_resolver():
  205. """
  206. Alter the behavior of the urllib DNS resolver so that any domain name
  207. containing substring 'nginx-proxy' will resolve to the IP address
  208. of the container created from image 'nginxproxy/nginx-proxy:test'.
  209. """
  210. prv_getaddrinfo = socket.getaddrinfo
  211. dns_cache = {}
  212. def new_getaddrinfo(*args):
  213. logging.getLogger('DNS').debug(f"resolving domain name {repr(args)}")
  214. _args = list(args)
  215. # Fail early when querying IP directly, and it is forced ipv6 when not supported,
  216. # Otherwise a pytest container not using the host network fails to pass `test_raw-ip-vhost`.
  217. if FORCE_CONTAINER_IPV6 and not HAS_IPV6:
  218. pytest.skip("This system does not support IPv6")
  219. # custom DNS resolvers
  220. ip = nginx_proxy_dns_resolver(args[0])
  221. if ip is None:
  222. ip = docker_container_dns_resolver(args[0])
  223. if ip is not None:
  224. _args[0] = ip
  225. # call on original DNS resolver, with eventually the original host changed to the wanted IP address
  226. try:
  227. return dns_cache[tuple(_args)]
  228. except KeyError:
  229. res = prv_getaddrinfo(*_args)
  230. dns_cache[tuple(_args)] = res
  231. return res
  232. socket.getaddrinfo = new_getaddrinfo
  233. return prv_getaddrinfo
  234. def restore_urllib_dns_resolver(getaddrinfo_func):
  235. socket.getaddrinfo = getaddrinfo_func
  236. def get_nginx_conf_from_container(container: Container) -> bytes:
  237. """
  238. return the nginx /etc/nginx/conf.d/default.conf file content from a container
  239. """
  240. import tarfile
  241. from io import BytesIO
  242. strm_generator, stat = container.get_archive('/etc/nginx/conf.d/default.conf')
  243. strm_fileobj = BytesIO(b"".join(strm_generator))
  244. with tarfile.open(fileobj=strm_fileobj) as tf:
  245. conffile = tf.extractfile('default.conf')
  246. return conffile.read()
  247. def __prepare_and_execute_compose_cmd(compose_files: List[str], project_name: str, cmd: str):
  248. """
  249. Prepare and execute the Docker Compose command with the provided compose files and project name.
  250. """
  251. compose_cmd = StringIO()
  252. compose_cmd.write(DOCKER_COMPOSE)
  253. compose_cmd.write(f" --project-name {project_name}")
  254. for compose_file in compose_files:
  255. compose_cmd.write(f" --file {compose_file}")
  256. compose_cmd.write(f" {cmd}")
  257. logging.info(compose_cmd.getvalue())
  258. try:
  259. subprocess.check_output(shlex.split(compose_cmd.getvalue()), stderr=subprocess.STDOUT)
  260. except subprocess.CalledProcessError as e:
  261. pytest.fail(f"Error while running '{compose_cmd.getvalue()}':\n{e.output}", pytrace=False)
  262. def docker_compose_up(compose_files: List[str], project_name: str):
  263. """
  264. Execute compose up --detach with the provided compose files and project name.
  265. """
  266. if compose_files is None or len(compose_files) == 0:
  267. pytest.fail(f"No compose file passed to docker_compose_up", pytrace=False)
  268. __prepare_and_execute_compose_cmd(compose_files, project_name, cmd="up --detach")
  269. def docker_compose_down(compose_files: List[str], project_name: str):
  270. """
  271. Execute compose down --volumes with the provided compose files and project name.
  272. """
  273. if compose_files is None or len(compose_files) == 0:
  274. pytest.fail(f"No compose file passed to docker_compose_up", pytrace=False)
  275. __prepare_and_execute_compose_cmd(compose_files, project_name, cmd="down --volumes")
  276. def wait_for_nginxproxy_to_be_ready():
  277. """
  278. If one (and only one) container started from image nginxproxy/nginx-proxy:test is found,
  279. wait for its log to contain substring "Watching docker events"
  280. """
  281. containers = docker_client.containers.list(filters={"ancestor": "nginxproxy/nginx-proxy:test"})
  282. if len(containers) != 1:
  283. return
  284. container = containers[0]
  285. for line in container.logs(stream=True):
  286. if b"Watching docker events" in line:
  287. logging.debug("nginx-proxy ready")
  288. break
  289. @pytest.fixture
  290. def docker_compose_files(request: FixtureRequest) -> List[str]:
  291. """Fixture returning the docker compose files to consider:
  292. If a YAML file exists with the same name as the test module (with the `.py` extension
  293. replaced with `.base.yml`, ie `test_foo.py`-> `test_foo.base.yml`) and in the same
  294. directory as the test module, use only that file.
  295. Otherwise, merge the following files in this order:
  296. - the `compose.base.yml` file in the parent `test` directory.
  297. - if present in the same directory as the test module, the `compose.base.override.yml` file.
  298. - the YAML file named after the current test module (ie `test_foo.py`-> `test_foo.yml`)
  299. Tests can override this fixture to specify a custom location.
  300. """
  301. compose_files: List[str] = []
  302. test_module_path = pathlib.Path(request.module.__file__).parent
  303. module_base_file = test_module_path.joinpath(f"{request.module.__name__}.base.yml")
  304. if module_base_file.is_file():
  305. return [module_base_file.as_posix()]
  306. global_base_file = test_module_path.parent.joinpath("compose.base.yml")
  307. if global_base_file.is_file():
  308. compose_files.append(global_base_file.as_posix())
  309. module_base_override_file = test_module_path.joinpath("compose.base.override.yml")
  310. if module_base_override_file.is_file():
  311. compose_files.append(module_base_override_file.as_posix())
  312. module_compose_file = test_module_path.joinpath(f"{request.module.__name__}.yml")
  313. if module_compose_file.is_file():
  314. compose_files.append(module_compose_file.as_posix())
  315. if not module_base_file.is_file() and not module_compose_file.is_file():
  316. logging.error(
  317. f"Could not find any docker compose file named '{module_base_file.name}' or '{module_compose_file.name}'"
  318. )
  319. logging.debug(f"using docker compose files {compose_files}")
  320. return compose_files
  321. def connect_to_network(network: Network) -> Optional[Network]:
  322. """
  323. If we are running from a container, connect our container to the given network
  324. :return: the name of the network we were connected to, or None
  325. """
  326. if PYTEST_RUNNING_IN_CONTAINER:
  327. try:
  328. my_container = docker_client.containers.get(test_container)
  329. except docker.errors.NotFound:
  330. logging.warning(f"container {test_container} not found")
  331. return None
  332. # figure out our container networks
  333. my_networks = list(my_container.attrs["NetworkSettings"]["Networks"].keys())
  334. # If the pytest container is using host networking, it cannot connect to container networks (not required with host network)
  335. if 'host' in my_networks:
  336. return None
  337. # Make sure our container is connected to the nginx-proxy's network,
  338. # but avoid connecting to `none` network (not valid) with `test_server-down` tests
  339. if network.name not in my_networks and network.name != 'none':
  340. logging.info(f"Connecting to docker network: {network.name}")
  341. network.connect(my_container)
  342. return network
  343. def disconnect_from_network(network: Network = None):
  344. """
  345. If we are running from a container, disconnect our container from the given network.
  346. :param network: name of a docker network to disconnect from
  347. """
  348. if PYTEST_RUNNING_IN_CONTAINER and network is not None:
  349. try:
  350. my_container = docker_client.containers.get(test_container)
  351. except docker.errors.NotFound:
  352. logging.warning(f"container {test_container} not found")
  353. return
  354. # figure out our container networks
  355. my_networks_names = list(my_container.attrs["NetworkSettings"]["Networks"].keys())
  356. # disconnect our container from the given network
  357. if network.name in my_networks_names:
  358. logging.info(f"Disconnecting from network {network.name}")
  359. network.disconnect(my_container)
  360. def connect_to_all_networks() -> List[Network]:
  361. """
  362. If we are running from a container, connect our container to all current docker networks.
  363. :return: a list of networks we connected to
  364. """
  365. if not PYTEST_RUNNING_IN_CONTAINER:
  366. return []
  367. else:
  368. # find the list of docker networks
  369. networks = [network for network in docker_client.networks.list(greedy=True) if len(network.containers) > 0 and network.name != 'bridge']
  370. return [connect_to_network(network) for network in networks]
  371. class DockerComposer(contextlib.AbstractContextManager):
  372. def __init__(self):
  373. self._networks = None
  374. self._docker_compose_files = None
  375. self._project_name = None
  376. def __exit__(self, *exc_info):
  377. self._down()
  378. def _down(self):
  379. if self._docker_compose_files is None:
  380. return
  381. for network in self._networks:
  382. disconnect_from_network(network)
  383. docker_compose_down(self._docker_compose_files, self._project_name)
  384. self._docker_compose_file = None
  385. self._project_name = None
  386. def compose(self, docker_compose_files: List[str], project_name: str):
  387. if docker_compose_files == self._docker_compose_files and project_name == self._project_name:
  388. return
  389. self._down()
  390. if docker_compose_files is None or project_name is None:
  391. return
  392. docker_compose_up(docker_compose_files, project_name)
  393. self._networks = connect_to_all_networks()
  394. wait_for_nginxproxy_to_be_ready()
  395. time.sleep(3) # give time to containers to be ready
  396. self._docker_compose_files = docker_compose_files
  397. self._project_name = project_name
  398. ###############################################################################
  399. #
  400. # Py.test fixtures
  401. #
  402. ###############################################################################
  403. @pytest.fixture(scope="module")
  404. def docker_composer() -> Iterator[DockerComposer]:
  405. with DockerComposer() as d:
  406. yield d
  407. @pytest.fixture
  408. def ca_root_certificate() -> Iterator[str]:
  409. yield CA_ROOT_CERTIFICATE
  410. @pytest.fixture
  411. def monkey_patched_dns():
  412. original_dns_resolver = monkey_patch_urllib_dns_resolver()
  413. yield
  414. restore_urllib_dns_resolver(original_dns_resolver)
  415. @pytest.fixture
  416. def docker_compose(
  417. request: FixtureRequest,
  418. monkeypatch,
  419. monkey_patched_dns,
  420. docker_composer,
  421. docker_compose_files
  422. ) -> Iterator[DockerClient]:
  423. """
  424. Ensures containers necessary for the test module are started in a compose project,
  425. and set the environment variable `PYTEST_MODULE_PATH` to the test module's parent folder.
  426. A list of custom docker compose files path can be specified by overriding
  427. the `docker_compose_file` fixture.
  428. Also, in the case where pytest is running from a docker container, this fixture
  429. makes sure our container will be attached to all the docker networks.
  430. """
  431. pytest_module_path = pathlib.Path(request.module.__file__).parent
  432. monkeypatch.setenv("PYTEST_MODULE_PATH", pytest_module_path.as_posix())
  433. project_name = request.module.__name__
  434. docker_composer.compose(docker_compose_files, project_name)
  435. yield docker_client
  436. @pytest.fixture
  437. def nginxproxy() -> Iterator[RequestsForDocker]:
  438. """
  439. Provides the `nginxproxy` object that can be used in the same way the requests module is:
  440. r = nginxproxy.get("https://foo.com")
  441. The difference is that in case an HTTP requests has status code 404 or 502 (which mostly
  442. indicates that nginx has just reloaded), we retry up to 30 times the query.
  443. Also, the nginxproxy methods accept an additional keyword parameter: `ipv6` which forces requests
  444. made against containers to use the containers IPv6 address when set to `True`. If IPv6 is not
  445. supported by the system or docker, that particular test will be skipped.
  446. """
  447. yield RequestsForDocker()
  448. @pytest.fixture
  449. def acme_challenge_path() -> Iterator[str]:
  450. """
  451. Provides fake Let's Encrypt ACME challenge path used in certain tests
  452. """
  453. yield ".well-known/acme-challenge/test-filename"
  454. ###############################################################################
  455. #
  456. # Py.test hooks
  457. #
  458. ###############################################################################
  459. # pytest hook to display additional stuff in test report
  460. def pytest_runtest_logreport(report):
  461. if report.failed:
  462. test_containers = docker_client.containers.list(all=True, filters={"ancestor": "nginxproxy/nginx-proxy:test"})
  463. for container in test_containers:
  464. report.longrepr.addsection('nginx-proxy logs', container.logs().decode())
  465. report.longrepr.addsection('nginx-proxy conf', get_nginx_conf_from_container(container).decode())
  466. # Py.test `incremental` marker, see http://stackoverflow.com/a/12579625/107049
  467. def pytest_runtest_makereport(item, call):
  468. if "incremental" in item.keywords:
  469. if call.excinfo is not None:
  470. parent = item.parent
  471. parent._previousfailed = item
  472. def pytest_runtest_setup(item):
  473. previousfailed = getattr(item.parent, "_previousfailed", None)
  474. if previousfailed is not None:
  475. pytest.xfail(f"previous test failed ({previousfailed.name})")
  476. ###############################################################################
  477. #
  478. # Check requirements
  479. #
  480. ###############################################################################
  481. try:
  482. docker_client.images.get('nginxproxy/nginx-proxy:test')
  483. except docker.errors.ImageNotFound:
  484. pytest.exit("The docker image 'nginxproxy/nginx-proxy:test' is missing")
  485. if Version(docker.__version__) < Version("7.0.0"):
  486. pytest.exit("This test suite is meant to work with the python docker module v7.0.0 or later")