1
0
Fork 0

Migrate configuration paths to /etc/easyhaproxy and improve health check support in E2E tests

- Refactored HAProxy configuration files, templates, and paths to use `/etc/easyhaproxy` instead of `/etc/haproxy`.
- Updated Dockerfile to generate DH params and placeholder certificates in the new configuration directory.
- Added health check support with timeout to `DockerComposeFixture` in E2E test utilities.
- Adjusted tests, templates, and plugins to use the new `Consts`-based configuration paths.
- Introduced pytest fixtures for environment isolation and temporary directory management.
This commit is contained in:
Joao Gilberto Magalhaes 2026-02-15 14:32:16 -05:00
parent 3e963228f3
commit 045dd3817e
73 changed files with 600 additions and 287 deletions

43
tests/conftest.py Normal file
View file

@ -0,0 +1,43 @@
"""
Pytest configuration and fixtures for EasyHAProxy tests.
This module provides session-wide and function-level fixtures for testing.
"""
import os
import shutil
import tempfile
import pytest
# Create a session-wide temporary directory for all tests
# Use a different prefix to avoid conflicts with cleanup plugin (which looks for "easyhaproxy_*")
_test_session_dir = tempfile.mkdtemp(prefix="pytest_easyhaproxy_")
os.environ["EASYHAPROXY_BASE_PATH"] = _test_session_dir
@pytest.fixture(scope="function", autouse=True)
def reset_consts():
"""
Reset Consts before and after each test.
This ensures:
1. Each test picks up the EASYHAPROXY_BASE_PATH environment variable
2. Tests don't get permission errors trying to write to /etc/easyhaproxy/
3. Consts path cache is cleared between tests for isolation
"""
from functions import Consts
Consts.reset()
yield
Consts.reset()
def pytest_sessionfinish(session, exitstatus):
"""
Cleanup session temporary directory after all tests complete.
"""
try:
shutil.rmtree(_test_session_dir)
except Exception:
# Ignore cleanup errors
pass