test_vhost-in-multiple-networks.py 1.1 KB

1234567891011121314151617181920212223242526272829
  1. import pytest
  2. import logging
  3. import time
  4. def test_forwards_to_web1(docker_compose, nginxproxy):
  5. r = nginxproxy.get("http://web1.nginx-proxy.local/port")
  6. assert r.status_code == 200
  7. assert r.text == "answer from port 81\n"
  8. def test_nginx_config_remains_the_same_after_restart(docker_compose, nginxproxy):
  9. """
  10. Restarts the Web container and returns nginx-proxy config after restart
  11. """
  12. def get_conf_after_web_container_restart():
  13. web_containers = docker_compose.containers.list(filters={"ancestor": "web:latest"})
  14. assert len(web_containers) == 1
  15. web_containers[0].restart()
  16. time.sleep(3)
  17. return nginxproxy.get_conf()
  18. config_before_restart = nginxproxy.get_conf()
  19. for i in range(1, 8):
  20. logging.info(f"Checking for the {i}-st time that config is the same")
  21. config_after_restart = get_conf_after_web_container_restart()
  22. if config_before_restart != config_after_restart:
  23. logging.debug(f"{config_before_restart!r} \n\n {config_after_restart!r}")
  24. pytest.fail("nginx-proxy config before and after restart of a web container does not match", pytrace=False)