|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +E2E Test Entrypoint for gRPC Instrumentation |
| 4 | +
|
| 5 | +This script orchestrates the full e2e test lifecycle: |
| 6 | +1. Setup: Install dependencies, generate proto files |
| 7 | +2. Record: Start app in RECORD mode, execute requests |
| 8 | +3. Test: Run Tusk CLI tests |
| 9 | +4. Teardown: Cleanup and return exit code |
| 10 | +""" |
| 11 | + |
| 12 | +import sys |
| 13 | +from pathlib import Path |
| 14 | + |
| 15 | +# Add SDK to path for imports |
| 16 | +sys.path.insert(0, "/sdk") |
| 17 | + |
| 18 | +from drift.instrumentation.e2e_common.base_runner import E2ETestRunnerBase |
| 19 | + |
| 20 | + |
| 21 | +class GrpcE2ETestRunner(E2ETestRunnerBase): |
| 22 | + """E2E test runner for gRPC instrumentation.""" |
| 23 | + |
| 24 | + def __init__(self): |
| 25 | + import os |
| 26 | + |
| 27 | + port = int(os.getenv("PORT", "8000")) |
| 28 | + super().__init__(app_port=port) |
| 29 | + |
| 30 | + def setup(self): |
| 31 | + """Phase 1: Setup dependencies and generate proto files.""" |
| 32 | + self.log("=" * 50, self.Colors.BLUE) |
| 33 | + self.log("Phase 1: Setup", self.Colors.BLUE) |
| 34 | + self.log("=" * 50, self.Colors.BLUE) |
| 35 | + |
| 36 | + self.log("Installing Python dependencies...", self.Colors.BLUE) |
| 37 | + self.run_command(["pip", "install", "-q", "-r", "requirements.txt"]) |
| 38 | + |
| 39 | + # Generate proto files |
| 40 | + self.log("Generating proto files...", self.Colors.BLUE) |
| 41 | + self.run_command( |
| 42 | + [ |
| 43 | + "python", |
| 44 | + "-m", |
| 45 | + "grpc_tools.protoc", |
| 46 | + "-I", |
| 47 | + "src/proto", |
| 48 | + "--python_out=src", |
| 49 | + "--grpc_python_out=src", |
| 50 | + "src/proto/greeter.proto", |
| 51 | + ] |
| 52 | + ) |
| 53 | + |
| 54 | + self.log("Setup complete", self.Colors.GREEN) |
| 55 | + |
| 56 | + # Use Colors from base class |
| 57 | + @property |
| 58 | + def Colors(self): |
| 59 | + from drift.instrumentation.e2e_common.base_runner import Colors |
| 60 | + |
| 61 | + return Colors |
| 62 | + |
| 63 | + |
| 64 | +if __name__ == "__main__": |
| 65 | + runner = GrpcE2ETestRunner() |
| 66 | + exit_code = runner.run() |
| 67 | + sys.exit(exit_code) |
0 commit comments