1
0
Fork 0

Enhance logging and error handling in E2E tests and CI workflows

- Added detailed log messages in `conftest.py` for SSL certificate and JWT generation steps.
- Improved Docker Compose E2E test output with service-specific logs during startup and cleanup.
- Adjusted pytest run options in CI workflows to use `--tb=short` for concise error traceback.
This commit is contained in:
Joao Gilberto Magalhaes 2026-02-12 18:26:59 -05:00
parent 4160babc94
commit 904a102b0a
3 changed files with 36 additions and 8 deletions

View file

@ -61,7 +61,7 @@ jobs:
- name: Run Docker Compose E2E tests
run: |
export PATH="$HOME/.local/bin:$PATH"
uv run pytest tests_e2e/test_docker_compose.py -sv
uv run pytest tests_e2e/test_docker_compose.py -sv --tb=short
Tests-E2E-Kubernetes:
runs-on: ubuntu-latest
@ -84,7 +84,7 @@ jobs:
- name: Run Kubernetes E2E tests
run: |
export PATH="$HOME/.local/bin:$PATH"
uv run pytest tests_e2e/test_kubernetes.py -sv
uv run pytest tests_e2e/test_kubernetes.py -sv --tb=short
Build:
runs-on: ubuntu-latest

View file

@ -27,6 +27,7 @@ def generate_ssl_certificates():
pytest.skip(f"SSL certificate generation script not found: {script_path}")
# Run from tests_e2e directory (Docker approach - WORKING)
print("\n[Setup] Generating SSL certificates and JWT keys...")
result = subprocess.run(
["bash", str(script_path)],
cwd=BASE_DIR, # NOT BASE_DIR.parent (K8s bug)
@ -35,8 +36,12 @@ def generate_ssl_certificates():
)
if result.returncode != 0:
print(f"[Setup] ERROR: Certificate generation failed!")
print(f"[Setup] stderr: {result.stderr}")
pytest.fail(f"Failed to generate SSL certificates:\n{result.stderr}")
print("[Setup] ✓ SSL certificates and JWT keys generated successfully")
# Return paths for K8s tests to use
yield {
"host1_local": BASE_DIR / "static" / "host1.local.pem",

View file

@ -49,24 +49,47 @@ class DockerComposeFixture:
def up(self):
"""Start docker-compose services"""
compose_name = Path(self.compose_file).name
print(f"\n[Docker] Starting services from {compose_name}...")
cmd = ["docker", "compose", "-f", self.compose_file, "up", "-d"]
if self.build:
cmd.append("--build")
subprocess.run(
result = subprocess.run(
cmd,
check=True,
capture_output=True
capture_output=True,
text=True
)
if result.returncode != 0:
print(f"[Docker] ERROR: Failed to start services!")
print(f"[Docker] stdout: {result.stdout}")
print(f"[Docker] stderr: {result.stderr}")
raise subprocess.CalledProcessError(result.returncode, cmd, result.stdout, result.stderr)
print(f"[Docker] ✓ Services started, waiting {self.startup_wait}s for initialization...")
time.sleep(self.startup_wait)
print(f"[Docker] ✓ Services ready")
def down(self):
"""Stop and remove docker-compose services"""
subprocess.run(
compose_name = Path(self.compose_file).name
print(f"[Docker] Stopping services from {compose_name}...")
result = subprocess.run(
["docker", "compose", "-f", self.compose_file, "down", "--remove-orphans"],
check=True,
capture_output=True
capture_output=True,
text=True
)
if result.returncode != 0:
print(f"[Docker] WARNING: Failed to stop services cleanly")
print(f"[Docker] stderr: {result.stderr}")
# Don't raise error on cleanup, just warn
else:
print(f"[Docker] ✓ Services stopped and cleaned up")
@pytest.fixture
def docker_compose_basic_ssl() -> Generator[None, None, None]: