1
0
Fork 0

Migrate examples to tests_e2e directory structure

- Relocated all files and scripts from `examples` to `tests_e2e` for better organization.
- Updated references and paths in configurations, scripts, and test files.
- Adjusted `bump-version.sh` to handle the new `tests_e2e` structure.
- Updated `.gitignore` to reflect path changes.
This commit is contained in:
Joao Gilberto Magalhaes 2026-02-12 17:05:04 -05:00
parent b34d7822e4
commit d66c4f8595
51 changed files with 35 additions and 35 deletions

18
.gitignore vendored
View file

@ -15,12 +15,12 @@ dist/
build/ build/
*.egg-info/ *.egg-info/
/examples/static/conf/config.yml /tests_e2e/static/conf/config.yml
/examples/docker/certs/haproxy/.place_holder_cert.pem /tests_e2e/docker/certs/haproxy/.place_holder_cert.pem
/examples/static/host1.local.pem /tests_e2e/static/host1.local.pem
/examples/swarm/certs/host1.local.pem /tests_e2e/swarm/certs/host1.local.pem
/examples/docker/host2.local.pem /tests_e2e/docker/host2.local.pem
/examples/swarm/certs/host2.local.pem /tests_e2e/swarm/certs/host2.local.pem
/examples/docker/jwt_private.pem /tests_e2e/docker/jwt_private.pem
/examples/docker/jwt_pubkey.pem /tests_e2e/docker/jwt_pubkey.pem
/examples/docker/cloudflare_ips.lst /tests_e2e/docker/cloudflare_ips.lst

View file

@ -152,7 +152,7 @@ Click on the image to see the videos (use HD for better visualization)
[![Static Configuration](docs/video-static.png)](https://youtu.be/B_bYZnRTGJM) [![Static Configuration](docs/video-static.png)](https://youtu.be/B_bYZnRTGJM)
[![TCP Mode](docs/video-tcp-mysql.png)](https://youtu.be/JHqcq9crbDI) [![TCP Mode](docs/video-tcp-mysql.png)](https://youtu.be/JHqcq9crbDI)
[Here is the code](https://gist.github.com/byjg/e125e478a0562190176d69ea795fd3d4) applied in the examples above. [Here is the code](https://gist.github.com/byjg/e125e478a0562190176d69ea795fd3d4) applied in the test examples above.
---- ----

View file

@ -94,7 +94,7 @@ if [[ "$MODE" == "verify" ]]; then
check_contains "easy-haproxy:$NEW_VERSION" deploy/docker/docker-compose.yml "Docker compose image tag" check_contains "easy-haproxy:$NEW_VERSION" deploy/docker/docker-compose.yml "Docker compose image tag"
check_contains "version = \"$NEW_VERSION\"" pyproject.toml "pyproject.toml version" check_contains "version = \"$NEW_VERSION\"" pyproject.toml "pyproject.toml version"
if grep -R "byjg/easy-haproxy:" examples | grep -v "$NEW_VERSION" >/dev/null; then if grep -R "byjg/easy-haproxy:" tests_e2e | grep -v "$NEW_VERSION" >/dev/null; then
echo "❌ Examples still reference a different tag. Run bump-version.sh to update." echo "❌ Examples still reference a different tag. Run bump-version.sh to update."
STATUS=1 STATUS=1
else else
@ -122,9 +122,9 @@ sed -i "s#^version = \"[a-zA-Z0-9\\.-]*\"#version = \"$NEW_VERSION\"#g" pyprojec
sed -i "s#appVersion: \"[a-zA-Z0-9\\.-]*\"#appVersion: \"$NEW_VERSION\"#g" "$CHART_FILE" sed -i "s#appVersion: \"[a-zA-Z0-9\\.-]*\"#appVersion: \"$NEW_VERSION\"#g" "$CHART_FILE"
# Update examples # Update examples
find examples -type f -name '*.yml' -exec sed -i "s#\\(byjg/easy-haproxy:\\)[a-zA-Z0-9\\.-]*#\\1$NEW_VERSION#g" {} \; -print find tests_e2e -type f -name '*.yml' -exec sed -i "s#\\(byjg/easy-haproxy:\\)[a-zA-Z0-9\\.-]*#\\1$NEW_VERSION#g" {} \; -print
# Update raw GitHub URLs in Kubernetes examples # Update raw GitHub URLs in Kubernetes examples
find examples/kubernetes -type f -name '*.yml' -exec sed -i "s#raw.githubusercontent.com/byjg/docker-easy-haproxy/[a-zA-Z0-9\\.\\-]*/deploy/kubernetes/easyhaproxy-daemonset.yml#raw.githubusercontent.com/byjg/docker-easy-haproxy/$NEW_VERSION/deploy/kubernetes/easyhaproxy-daemonset.yml#g" {} \; find tests_e2e/kubernetes -type f -name '*.yml' -exec sed -i "s#raw.githubusercontent.com/byjg/docker-easy-haproxy/[a-zA-Z0-9\\.\\-]*/deploy/kubernetes/easyhaproxy-daemonset.yml#raw.githubusercontent.com/byjg/docker-easy-haproxy/$NEW_VERSION/deploy/kubernetes/easyhaproxy-daemonset.yml#g" {} \;
# Bump chart version (patch) # Bump chart version (patch)
SANITIZED_CHART_VERSION="${CURRENT_CHART_VERSION%\.}" SANITIZED_CHART_VERSION="${CURRENT_CHART_VERSION%\.}"

View file

@ -11,7 +11,7 @@
# REQUIREMENTS (run these first): # REQUIREMENTS (run these first):
# ```bash # ```bash
# # Generate SSL certificates and JWT keys (from project root) # # Generate SSL certificates and JWT keys (from project root)
# cd ../.. && ./examples/generate-keys.sh && cd examples/docker # cd ../.. && ./tests_e2e/generate-keys.sh && cd tests_e2e/docker
# ``` # ```
# #
# HOW TO START: # HOW TO START:

View file

@ -13,7 +13,7 @@
# REQUIREMENTS (run these first): # REQUIREMENTS (run these first):
# ```bash # ```bash
# # Generate SSL certificates and JWT keys (from project root) # # Generate SSL certificates and JWT keys (from project root)
# cd ../.. && ./examples/generate-keys.sh && cd examples/docker # cd ../.. && ./tests_e2e/generate-keys.sh && cd tests_e2e/docker
# #
# # Download Cloudflare IPs (idempotent - overwrites if exists) # # Download Cloudflare IPs (idempotent - overwrites if exists)
# curl -s https://www.cloudflare.com/ips-v4 > cloudflare_ips.lst # curl -s https://www.cloudflare.com/ips-v4 > cloudflare_ips.lst

View file

@ -11,7 +11,7 @@
# REQUIREMENTS (run these first): # REQUIREMENTS (run these first):
# #
# # Generate SSL certificates # # Generate SSL certificates
# cd ../.. && ./examples/generate-keys.sh && cd examples/docker # cd ../.. && ./tests_e2e/generate-keys.sh && cd tests_e2e/docker
# ``` # ```
# #
# HOW TO START: # HOW TO START:

View file

@ -60,7 +60,7 @@ curl http://localhost:8080
## Used By ## Used By
- `examples/docker/docker-compose-cloudflare.yml` - `tests_e2e/docker/docker-compose-cloudflare.yml`
- `examples/docker/test_docker_compose.py::TestCloudflare` - `tests_e2e/test_docker_compose.py::TestCloudflare`
- `examples/kubernetes/cloudflare.yml` - `tests_e2e/kubernetes/cloudflare.yml`
- `examples/kubernetes/test_kubernetes.py::TestCloudflare` - `tests_e2e/test_kubernetes.py::TestCloudflare`

View file

@ -31,7 +31,7 @@ Choose one of these pre-made configurations:
## Prerequisites ## Prerequisites
- SSL certificates generated (`./examples/generate-keys.sh`) - SSL certificates generated (`./tests_e2e/generate-keys.sh`)
- `/etc/hosts` entry for `host1.local` - `/etc/hosts` entry for `host1.local`
- Backend container running on port 8080 - Backend container running on port 8080
@ -50,7 +50,7 @@ The docker-compose.yml file contains:
```bash ```bash
# 1. Generate certificates # 1. Generate certificates
cd ../.. && ./examples/generate-keys.sh && cd examples/static cd ../.. && ./tests_e2e/generate-keys.sh && cd tests_e2e/static
# 2. Choose a configuration # 2. Choose a configuration
cp conf/config-basic.yml conf/config.yml cp conf/config-basic.yml conf/config.yml

View file

@ -10,7 +10,7 @@
# REQUIREMENTS (run these first): # REQUIREMENTS (run these first):
# ```bash # ```bash
# # Generate SSL certificates # # Generate SSL certificates
# cd ../.. && ./examples/generate-keys.sh && cd examples/static # cd ../.. && ./tests_e2e/generate-keys.sh && cd tests_e2e/static
# #
# # Add to /etc/hosts (idempotent) # # Add to /etc/hosts (idempotent)
# grep -q "host1.local" /etc/hosts || echo "127.0.0.1 host1.local" | sudo tee -a /etc/hosts # grep -q "host1.local" /etc/hosts || echo "127.0.0.1 host1.local" | sudo tee -a /etc/hosts

View file

@ -14,7 +14,7 @@
# docker stack deploy -c easyhaproxy.yml easyhaproxy # docker stack deploy -c easyhaproxy.yml easyhaproxy
# #
# # Generate SSL certificates # # Generate SSL certificates
# cd ../.. && ./examples/generate-keys.sh && cd examples/swarm # cd ../.. && ./tests_e2e/generate-keys.sh && cd tests_e2e/swarm
# #
# # Add to /etc/hosts (idempotent) # # Add to /etc/hosts (idempotent)
# grep -q "host1.local" /etc/hosts || echo "127.0.0.1 host1.local host2.local" | sudo tee -a /etc/hosts # grep -q "host1.local" /etc/hosts || echo "127.0.0.1 host1.local host2.local" | sudo tee -a /etc/hosts

View file

@ -44,16 +44,16 @@ def generate_ssl_certificates():
Generate SSL certificates once for all tests that require them. Generate SSL certificates once for all tests that require them.
This runs automatically at the start of the test session. This runs automatically at the start of the test session.
""" """
script_path = BASE_DIR.parent / "generate-keys.sh" script_path = BASE_DIR / "generate-keys.sh"
# Check if script exists # Check if script exists
if not script_path.exists(): if not script_path.exists():
pytest.skip(f"SSL certificate generation script not found: {script_path}") pytest.skip(f"SSL certificate generation script not found: {script_path}")
# Run the script from the examples directory # Run the script from the tests_e2e directory
result = subprocess.run( result = subprocess.run(
["bash", str(script_path)], ["bash", str(script_path)],
cwd=BASE_DIR.parent, cwd=BASE_DIR,
capture_output=True, capture_output=True,
text=True text=True
) )
@ -69,7 +69,7 @@ class DockerComposeFixture:
"""Helper class to manage docker-compose lifecycle""" """Helper class to manage docker-compose lifecycle"""
def __init__(self, compose_file: str, startup_wait: int = 3, build: bool = True): def __init__(self, compose_file: str, startup_wait: int = 3, build: bool = True):
self.compose_file = str(BASE_DIR / compose_file) self.compose_file = str(BASE_DIR / "docker" / compose_file)
self.startup_wait = startup_wait self.startup_wait = startup_wait
self.build = build self.build = build
@ -152,7 +152,7 @@ def docker_compose_ip_whitelist() -> Generator[None, None, None]:
def docker_compose_cloudflare() -> Generator[None, None, None]: def docker_compose_cloudflare() -> Generator[None, None, None]:
"""Fixture for docker-compose-cloudflare.yml""" """Fixture for docker-compose-cloudflare.yml"""
# Set up cloudflare_ips.lst with Docker network for testing # Set up cloudflare_ips.lst with Docker network for testing
cloudflare_ips_path = BASE_DIR / "cloudflare_ips.lst" cloudflare_ips_path = BASE_DIR / "docker" / "cloudflare_ips.lst"
# Download Cloudflare IPs # Download Cloudflare IPs
subprocess.run( subprocess.run(
@ -184,7 +184,7 @@ def docker_compose_cloudflare() -> Generator[None, None, None]:
@pytest.fixture @pytest.fixture
def jwt_token() -> str: def jwt_token() -> str:
"""Generate a valid JWT token for testing""" """Generate a valid JWT token for testing"""
private_key_path = BASE_DIR / "jwt_private.pem" private_key_path = BASE_DIR / "docker" / "jwt_private.pem"
with open(private_key_path, 'r') as f: with open(private_key_path, 'r') as f:
private_key = f.read() private_key = f.read()

View file

@ -40,7 +40,7 @@ except ImportError:
# Base directory for Kubernetes manifests # Base directory for Kubernetes manifests
BASE_DIR = Path(__file__).parent.absolute() BASE_DIR = Path(__file__).parent.absolute()
BIN_DIR = BASE_DIR / ".kind" BIN_DIR = BASE_DIR / "kubernetes" / ".kind"
KIND_BIN = BIN_DIR / "kind" KIND_BIN = BIN_DIR / "kind"
KUBECTL_BIN = BIN_DIR / "kubectl" KUBECTL_BIN = BIN_DIR / "kubectl"
HELM_BIN = BIN_DIR / "helm" HELM_BIN = BIN_DIR / "helm"
@ -468,7 +468,7 @@ class KubernetesFixture:
"""Helper class to manage Kubernetes manifest lifecycle""" """Helper class to manage Kubernetes manifest lifecycle"""
def __init__(self, manifest_file: str, kubectl_cmd: str, namespace: str = "default", wait_time: int = 5): def __init__(self, manifest_file: str, kubectl_cmd: str, namespace: str = "default", wait_time: int = 5):
self.manifest_file = str(BASE_DIR / manifest_file) self.manifest_file = str(BASE_DIR / "kubernetes" / manifest_file)
self.kubectl = kubectl_cmd self.kubectl = kubectl_cmd
self.namespace = namespace self.namespace = namespace
self.wait_time = wait_time self.wait_time = wait_time
@ -846,7 +846,7 @@ def k8s_cloudflare(kind_cluster, kind_cmd) -> Generator[str, None, None]:
cluster_name = kind_cluster["name"] cluster_name = kind_cluster["name"]
# Build header-echo server image locally # Build header-echo server image locally
header_echo_dir = BASE_DIR.parent / "fixtures" / "header-echo" header_echo_dir = BASE_DIR / "fixtures" / "header-echo"
print(" → Building header-echo-server:test image...") print(" → Building header-echo-server:test image...")
subprocess.run( subprocess.run(
["docker", "build", "-t", "header-echo-server:test", str(header_echo_dir)], ["docker", "build", "-t", "header-echo-server:test", str(header_echo_dir)],
@ -877,7 +877,7 @@ def k8s_cloudflare(kind_cluster, kind_cmd) -> Generator[str, None, None]:
ip_list_base64 = base64.b64encode(ip_list_content.encode('utf-8')).decode('ascii') ip_list_base64 = base64.b64encode(ip_list_content.encode('utf-8')).decode('ascii')
# Read the original manifest # Read the original manifest
manifest_path = BASE_DIR / "cloudflare.yml" manifest_path = BASE_DIR / "kubernetes" / "cloudflare.yml"
with open(manifest_path, 'r') as f: with open(manifest_path, 'r') as f:
manifest_content = f.read() manifest_content = f.read()
@ -889,7 +889,7 @@ def k8s_cloudflare(kind_cluster, kind_cmd) -> Generator[str, None, None]:
) )
# Write modified manifest to temp file # Write modified manifest to temp file
temp_manifest_path = BASE_DIR / "cloudflare_test.yml" temp_manifest_path = BASE_DIR / "kubernetes" / "cloudflare_test.yml"
with open(temp_manifest_path, 'w') as f: with open(temp_manifest_path, 'w') as f:
f.write(manifest_modified) f.write(manifest_modified)