mirror of
https://github.com/velocitatem/PHANTOM.git
synced 2026-05-31 08:33:36 +00:00
Implement comprehensive E2E tests to validate the surge pricing pipeline: - Test SimpleSurgePricer with configurable thresholds (high=3, surge=1.5x) - Verify discount pricing when demand is below low_threshold - Test multi-product differential pricing based on demand signals - Validate price propagation from pipeline through Redis to API Test infrastructure: - Playwright configuration with custom fixtures - Python pipeline worker for direct test execution (bypasses Airflow) - API client for event ingestion and price verification - Event generator for creating realistic interaction sequences - docker-compose.e2e.yml with minimal services for testing
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { testConfig } from './playwright.config';
|
|
|
|
/**
|
|
* Global setup for E2E tests
|
|
* Verifies all services are healthy before running tests
|
|
*/
|
|
async function globalSetup() {
|
|
console.log('\n🚀 PHANTOM E2E Test Suite - Global Setup\n');
|
|
|
|
// Check backend health
|
|
await checkService('Backend API', `${testConfig.backendUrl}/health`);
|
|
|
|
// Check pricing provider health
|
|
await checkService('Pricing Provider', `${testConfig.providerUrl}/health`);
|
|
|
|
console.log('\n✅ All services healthy. Starting tests...\n');
|
|
}
|
|
|
|
async function checkService(name: string, url: string): Promise<void> {
|
|
const maxRetries = 10;
|
|
const retryDelay = 2000;
|
|
|
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
try {
|
|
const response = await fetch(url);
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
console.log(`✅ ${name}: healthy`);
|
|
if (data.redis !== undefined) {
|
|
console.log(` └─ Redis: ${data.redis ? 'connected' : 'disconnected'}`);
|
|
}
|
|
if (data.kafka !== undefined) {
|
|
console.log(` └─ Kafka: ${data.kafka}`);
|
|
}
|
|
return;
|
|
}
|
|
} catch (error) {
|
|
if (attempt === maxRetries) {
|
|
throw new Error(`❌ ${name} is not available at ${url} after ${maxRetries} attempts`);
|
|
}
|
|
console.log(`⏳ Waiting for ${name} (attempt ${attempt}/${maxRetries})...`);
|
|
await new Promise(resolve => setTimeout(resolve, retryDelay));
|
|
}
|
|
}
|
|
}
|
|
|
|
export default globalSetup;
|