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:
parent
4160babc94
commit
904a102b0a
3 changed files with 36 additions and 8 deletions
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
|
|
@ -61,7 +61,7 @@ jobs:
|
||||||
- name: Run Docker Compose E2E tests
|
- name: Run Docker Compose E2E tests
|
||||||
run: |
|
run: |
|
||||||
export PATH="$HOME/.local/bin:$PATH"
|
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:
|
Tests-E2E-Kubernetes:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
@ -84,7 +84,7 @@ jobs:
|
||||||
- name: Run Kubernetes E2E tests
|
- name: Run Kubernetes E2E tests
|
||||||
run: |
|
run: |
|
||||||
export PATH="$HOME/.local/bin:$PATH"
|
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:
|
Build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ def generate_ssl_certificates():
|
||||||
pytest.skip(f"SSL certificate generation script not found: {script_path}")
|
pytest.skip(f"SSL certificate generation script not found: {script_path}")
|
||||||
|
|
||||||
# Run from tests_e2e directory (Docker approach - WORKING)
|
# Run from tests_e2e directory (Docker approach - WORKING)
|
||||||
|
print("\n[Setup] Generating SSL certificates and JWT keys...")
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["bash", str(script_path)],
|
["bash", str(script_path)],
|
||||||
cwd=BASE_DIR, # NOT BASE_DIR.parent (K8s bug)
|
cwd=BASE_DIR, # NOT BASE_DIR.parent (K8s bug)
|
||||||
|
|
@ -35,8 +36,12 @@ def generate_ssl_certificates():
|
||||||
)
|
)
|
||||||
|
|
||||||
if result.returncode != 0:
|
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}")
|
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
|
# Return paths for K8s tests to use
|
||||||
yield {
|
yield {
|
||||||
"host1_local": BASE_DIR / "static" / "host1.local.pem",
|
"host1_local": BASE_DIR / "static" / "host1.local.pem",
|
||||||
|
|
|
||||||
|
|
@ -49,24 +49,47 @@ class DockerComposeFixture:
|
||||||
|
|
||||||
def up(self):
|
def up(self):
|
||||||
"""Start docker-compose services"""
|
"""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"]
|
cmd = ["docker", "compose", "-f", self.compose_file, "up", "-d"]
|
||||||
if self.build:
|
if self.build:
|
||||||
cmd.append("--build")
|
cmd.append("--build")
|
||||||
subprocess.run(
|
|
||||||
|
result = subprocess.run(
|
||||||
cmd,
|
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)
|
time.sleep(self.startup_wait)
|
||||||
|
print(f"[Docker] ✓ Services ready")
|
||||||
|
|
||||||
def down(self):
|
def down(self):
|
||||||
"""Stop and remove docker-compose services"""
|
"""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"],
|
["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
|
@pytest.fixture
|
||||||
def docker_compose_basic_ssl() -> Generator[None, None, None]:
|
def docker_compose_basic_ssl() -> Generator[None, None, None]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue