mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 01:38:15 +00:00
tests: standardize file structure & naming
This commit is contained in:
parent
35e2d21527
commit
eb09876f97
@ -1 +0,0 @@
|
|||||||
This directory contains tests that showcase scenarios known to break the expected behavior of nginx-proxy.
|
|
@ -1,8 +1,8 @@
|
|||||||
"""
|
"""
|
||||||
Test that nginx-proxy-tester can build successfully
|
Test that nginx-proxy-tester can build successfully
|
||||||
"""
|
"""
|
||||||
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import os
|
|
||||||
|
|
||||||
import docker
|
import docker
|
||||||
import pytest
|
import pytest
|
||||||
@ -13,12 +13,13 @@ client = docker.from_env()
|
|||||||
@pytest.fixture(scope = "session")
|
@pytest.fixture(scope = "session")
|
||||||
def docker_build(request):
|
def docker_build(request):
|
||||||
# Define Dockerfile path
|
# Define Dockerfile path
|
||||||
dockerfile_path = os.path.join(os.path.dirname(__file__), "requirements/")
|
current_file_path = pathlib.Path(__file__)
|
||||||
|
dockerfile_path = current_file_path.parent.parent.joinpath("requirements")
|
||||||
dockerfile_name = "Dockerfile-nginx-proxy-tester"
|
dockerfile_name = "Dockerfile-nginx-proxy-tester"
|
||||||
|
|
||||||
# Build the Docker image
|
# Build the Docker image
|
||||||
image, logs = client.images.build(
|
image, logs = client.images.build(
|
||||||
path = dockerfile_path,
|
path = dockerfile_path.as_posix(),
|
||||||
dockerfile = dockerfile_name,
|
dockerfile = dockerfile_name,
|
||||||
rm = True, # Remove intermediate containers
|
rm = True, # Remove intermediate containers
|
||||||
tag = "nginx-proxy-tester-ci", # Tag for the built image
|
tag = "nginx-proxy-tester-ci", # Tag for the built image
|
@ -22,7 +22,7 @@ def web1(docker_compose):
|
|||||||
},
|
},
|
||||||
ports={"81/tcp": None}
|
ports={"81/tcp": None}
|
||||||
)
|
)
|
||||||
docker_compose.networks.get("test_default").connect(container)
|
docker_compose.networks.get("test_events-net").connect(container)
|
||||||
sleep(2) # give it some time to initialize and for docker-gen to detect it
|
sleep(2) # give it some time to initialize and for docker-gen to detect it
|
||||||
yield container
|
yield container
|
||||||
try:
|
try:
|
||||||
@ -47,7 +47,7 @@ def web2(docker_compose):
|
|||||||
},
|
},
|
||||||
ports={"82/tcp": None}
|
ports={"82/tcp": None}
|
||||||
)
|
)
|
||||||
docker_compose.networks.get("test_default").connect(container)
|
docker_compose.networks.get("test_events-net").connect(container)
|
||||||
sleep(2) # give it some time to initialize and for docker-gen to detect it
|
sleep(2) # give it some time to initialize and for docker-gen to detect it
|
||||||
yield container
|
yield container
|
||||||
try:
|
try:
|
@ -1,3 +1,7 @@
|
|||||||
|
networks:
|
||||||
|
default:
|
||||||
|
name: test_events-net
|
||||||
|
|
||||||
services:
|
services:
|
||||||
nginxproxy:
|
nginxproxy:
|
||||||
image: nginxproxy/nginx-proxy:test
|
image: nginxproxy/nginx-proxy:test
|
@ -1,16 +1,16 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
def test_loadbalance_hash(docker_compose, nginxproxy):
|
def test_loadbalance_hash(docker_compose, nginxproxy):
|
||||||
conf = nginxproxy.get_conf().decode('ASCII')
|
conf = nginxproxy.get_conf().decode('ASCII')
|
||||||
r1 = nginxproxy.get("http://loadbalance-enabled.nginx-proxy.tld")
|
r1 = nginxproxy.get("http://loadbalance-enabled.nginx-proxy.tld")
|
||||||
r2 = nginxproxy.get("http://loadbalance-enabled.nginx-proxy.tld")
|
r2 = nginxproxy.get("http://loadbalance-enabled.nginx-proxy.tld")
|
||||||
assert re.search(r"hash \$remote_addr\;", conf)
|
assert re.search(r"hash \$remote_addr\;", conf)
|
||||||
assert r1.status_code == 200
|
assert r1.status_code == 200
|
||||||
assert r2.text == r1.text
|
assert r2.text == r1.text
|
||||||
|
|
||||||
def test_loadbalance_roundrobin(docker_compose, nginxproxy):
|
def test_loadbalance_roundrobin(docker_compose, nginxproxy):
|
||||||
r1 = nginxproxy.get("http://loadbalance-disabled.nginx-proxy.tld")
|
r1 = nginxproxy.get("http://loadbalance-disabled.nginx-proxy.tld")
|
||||||
r2 = nginxproxy.get("http://loadbalance-disabled.nginx-proxy.tld")
|
r2 = nginxproxy.get("http://loadbalance-disabled.nginx-proxy.tld")
|
||||||
assert r1.status_code == 200
|
assert r1.status_code == 200
|
||||||
assert r2.text != r1.text
|
assert r2.text != r1.text
|
@ -1,27 +1,27 @@
|
|||||||
services:
|
services:
|
||||||
loadbalance-hash:
|
loadbalance-hash:
|
||||||
image: web
|
image: web
|
||||||
expose:
|
expose:
|
||||||
- "81"
|
- "81"
|
||||||
environment:
|
environment:
|
||||||
WEB_PORTS: 81
|
WEB_PORTS: 81
|
||||||
VIRTUAL_HOST: loadbalance-enabled.nginx-proxy.tld
|
VIRTUAL_HOST: loadbalance-enabled.nginx-proxy.tld
|
||||||
labels:
|
labels:
|
||||||
com.github.nginx-proxy.nginx-proxy.loadbalance: "hash $$remote_addr;"
|
com.github.nginx-proxy.nginx-proxy.loadbalance: "hash $$remote_addr;"
|
||||||
deploy:
|
deploy:
|
||||||
replicas: 2
|
replicas: 2
|
||||||
|
|
||||||
loadbalance-roundrobin:
|
loadbalance-roundrobin:
|
||||||
image: web
|
image: web
|
||||||
expose:
|
expose:
|
||||||
- "82"
|
- "82"
|
||||||
environment:
|
environment:
|
||||||
WEB_PORTS: 82
|
WEB_PORTS: 82
|
||||||
VIRTUAL_HOST: loadbalance-disabled.nginx-proxy.tld
|
VIRTUAL_HOST: loadbalance-disabled.nginx-proxy.tld
|
||||||
deploy:
|
deploy:
|
||||||
replicas: 2
|
replicas: 2
|
||||||
|
|
||||||
sut:
|
sut:
|
||||||
image: nginxproxy/nginx-proxy:test
|
image: nginxproxy/nginx-proxy:test
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
@ -3,7 +3,7 @@ services:
|
|||||||
image: nginxproxy/nginx-proxy:test
|
image: nginxproxy/nginx-proxy:test
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||||
- ./test_location-override.vhost.d:/etc/nginx/vhost.d:ro
|
- ./vhost.d:/etc/nginx/vhost.d:ro
|
||||||
|
|
||||||
explicit-root:
|
explicit-root:
|
||||||
image: web
|
image: web
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user