From d25c82f8f34eff49325ed1d66a45f3548a84e6f3 Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Wed, 4 Mar 2026 23:38:21 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20rename=20api=5Fgateway=20=E2=86=92?= =?UTF-8?q?=20api=20across=20workspace,=20tests,=20and=20load=20crate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Workspace Cargo.toml: remove web-gateway + api_gateway members, keep api - trading_service: dep api-gateway → api, update test imports - testing/api-gateway-load → testing/api-load (crate renamed) - All test crates: get_api_gateway_addr → get_api_addr + variable renames Co-Authored-By: Claude Opus 4.6 --- .claude/settings.local.json | 3 +- Cargo.toml | 4 +- services/trading_service/Cargo.toml | 2 +- .../src/services/monitoring.rs | 8 +-- .../tests/auth_comprehensive.rs | 4 +- .../tests/auth_helpers_tests.rs | 6 +- .../tests/common/auth_helpers.rs | 6 +- .../{api-gateway-load => api-load}/Cargo.toml | 2 +- .../{api-gateway-load => api-load}/README.md | 0 .../src/clients/authenticated_client.rs | 0 .../src/clients/mixed_workload.rs | 0 .../src/clients/mod.rs | 0 .../src/config.rs | 0 .../src/main.rs | 0 .../src/metrics/collector.rs | 0 .../src/metrics/mod.rs | 0 .../src/orchestrator.rs | 0 .../src/reporting.rs | 0 .../src/scenarios/mod.rs | 0 .../src/scenarios/normal_load.rs | 0 .../src/scenarios/spike_load.rs | 0 .../src/scenarios/stress_test.rs | 0 .../src/scenarios/sustained_load.rs | 0 testing/integration/smoke_tests/mod.rs | 2 +- .../integration/smoke_tests/service_health.rs | 12 ++-- .../watch_tuning_progress_updated.rs | 4 +- .../src/metrics_validation.rs | 2 +- .../tests/backtesting_service_e2e.rs | 10 +-- .../tests/common/auth_helpers.rs | 6 +- .../tests/service_health_resilience_e2e.rs | 68 +++++++++---------- .../tests/trading_service_e2e.rs | 10 +-- 31 files changed, 74 insertions(+), 75 deletions(-) rename testing/{api-gateway-load => api-load}/Cargo.toml (97%) rename testing/{api-gateway-load => api-load}/README.md (100%) rename testing/{api-gateway-load => api-load}/src/clients/authenticated_client.rs (100%) rename testing/{api-gateway-load => api-load}/src/clients/mixed_workload.rs (100%) rename testing/{api-gateway-load => api-load}/src/clients/mod.rs (100%) rename testing/{api-gateway-load => api-load}/src/config.rs (100%) rename testing/{api-gateway-load => api-load}/src/main.rs (100%) rename testing/{api-gateway-load => api-load}/src/metrics/collector.rs (100%) rename testing/{api-gateway-load => api-load}/src/metrics/mod.rs (100%) rename testing/{api-gateway-load => api-load}/src/orchestrator.rs (100%) rename testing/{api-gateway-load => api-load}/src/reporting.rs (100%) rename testing/{api-gateway-load => api-load}/src/scenarios/mod.rs (100%) rename testing/{api-gateway-load => api-load}/src/scenarios/normal_load.rs (100%) rename testing/{api-gateway-load => api-load}/src/scenarios/spike_load.rs (100%) rename testing/{api-gateway-load => api-load}/src/scenarios/stress_test.rs (100%) rename testing/{api-gateway-load => api-load}/src/scenarios/sustained_load.rs (100%) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 93a25de17..8fc68a130 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -4,7 +4,8 @@ "mcp__ruv-swarm", "mcp__claude-flow@alpha", "mcp__flow-nexus", - "Bash(tail:*)" + "Bash(tail:*)", + "Bash(kubectl get pods -n foxhunt -o wide --no-headers)" ], "deny": [] } diff --git a/Cargo.toml b/Cargo.toml index 66b51a328..fd0141721 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -119,7 +119,6 @@ members = [ "crates/database", "crates/config", "crates/ctrader-openapi", - "crates/web-gateway", # Training sidecar "crates/training_uploader", # CLI binary @@ -131,7 +130,6 @@ members = [ "services/ml_training_service", "services/data_acquisition_service", "services/trading_agent_service", - "services/api_gateway", "services/api", # Testing "testing/integration", @@ -140,7 +138,7 @@ members = [ "testing/service-load", "testing/stress", "testing/service-integration", - "testing/api-gateway-load", + "testing/api-load", ] exclude = [ "testing/vault-integration", diff --git a/services/trading_service/Cargo.toml b/services/trading_service/Cargo.toml index 9fb1a07a5..f2bfdd743 100644 --- a/services/trading_service/Cargo.toml +++ b/services/trading_service/Cargo.toml @@ -103,7 +103,7 @@ prost-build.workspace = true [dev-dependencies] criterion = { workspace = true } redis = { workspace = true, features = ["tokio-comp", "connection-manager"] } -api-gateway = { path = "../api_gateway" } # For auth tests - no cyclic dependency (api-gateway doesn't depend on trading-service) +api = { path = "../api" } # For auth tests - no cyclic dependency (api doesn't depend on trading-service) base32 = "0.5" serial_test = "3.0" rand = "0.8" diff --git a/services/trading_service/src/services/monitoring.rs b/services/trading_service/src/services/monitoring.rs index 3dd1a9498..bf1ddb092 100644 --- a/services/trading_service/src/services/monitoring.rs +++ b/services/trading_service/src/services/monitoring.rs @@ -854,7 +854,7 @@ impl MonitoringService for MonitoringServiceImpl { _request: Request, ) -> Result, Status> { Err(Status::unimplemented( - "Training metrics are served by api_gateway, not trading_service", + "Training metrics are served by api, not trading_service", )) } @@ -863,7 +863,7 @@ impl MonitoringService for MonitoringServiceImpl { _request: Request, ) -> Result, Status> { Err(Status::unimplemented( - "Training metrics are served by api_gateway, not trading_service", + "Training metrics are served by api, not trading_service", )) } @@ -872,7 +872,7 @@ impl MonitoringService for MonitoringServiceImpl { _request: Request, ) -> Result, Status> { Err(Status::unimplemented( - "Epoch history is served by api_gateway, not trading_service", + "Epoch history is served by api, not trading_service", )) } @@ -885,7 +885,7 @@ impl MonitoringService for MonitoringServiceImpl { _request: Request, ) -> Result, Status> { Err(Status::unimplemented( - "Cluster pods are served by api_gateway, not trading_service", + "Cluster pods are served by api, not trading_service", )) } } diff --git a/services/trading_service/tests/auth_comprehensive.rs b/services/trading_service/tests/auth_comprehensive.rs index 653c28328..bf896a463 100644 --- a/services/trading_service/tests/auth_comprehensive.rs +++ b/services/trading_service/tests/auth_comprehensive.rs @@ -18,11 +18,11 @@ use tokio::time::sleep; use uuid::Uuid; // Import API Gateway auth components -use api_gateway::auth::jwt::revocation::{ +use api::auth::jwt::revocation::{ EnhancedJwtClaims, Jti, JwtRevocationService, RevocationConfig, RevocationMetadata, RevocationReason, RevocationStatistics, }; -use api_gateway::auth::mfa::totp::{TotpAlgorithm, TotpConfig, TotpGenerator, TotpVerifier}; +use api::auth::mfa::totp::{TotpAlgorithm, TotpConfig, TotpGenerator, TotpVerifier}; use secrecy::{ExposeSecret, SecretString}; // ============================================================================ diff --git a/services/trading_service/tests/auth_helpers_tests.rs b/services/trading_service/tests/auth_helpers_tests.rs index fe514a7ef..9e465ecf6 100644 --- a/services/trading_service/tests/auth_helpers_tests.rs +++ b/services/trading_service/tests/auth_helpers_tests.rs @@ -8,7 +8,7 @@ mod common; use anyhow::Result; use common::auth_helpers::{ create_default_test_jwt, create_expired_test_jwt, create_invalid_issuer_jwt, create_test_jwt, - get_api_gateway_addr, get_test_jwt_secret, get_test_user_id, TestAuthConfig, + get_api_addr, get_test_jwt_secret, get_test_user_id, TestAuthConfig, DEFAULT_API_GATEWAY_ADDR, DEFAULT_TEST_USER_ID, }; @@ -30,8 +30,8 @@ fn test_get_test_user_id() { } #[test] -fn test_get_api_gateway_addr() { - let addr = get_api_gateway_addr(); +fn test_get_api_addr() { + let addr = get_api_addr(); assert!(!addr.is_empty()); assert!(addr.starts_with("http://")); assert_eq!(addr, DEFAULT_API_GATEWAY_ADDR); diff --git a/services/trading_service/tests/common/auth_helpers.rs b/services/trading_service/tests/common/auth_helpers.rs index 5969e85f2..d6f037742 100644 --- a/services/trading_service/tests/common/auth_helpers.rs +++ b/services/trading_service/tests/common/auth_helpers.rs @@ -197,7 +197,7 @@ pub fn get_test_user_id() -> String { } /// Get API Gateway address from environment or use default -pub fn get_api_gateway_addr() -> String { +pub fn get_api_addr() -> String { std::env::var("API_GATEWAY_ADDR").unwrap_or_else(|_| DEFAULT_API_GATEWAY_ADDR.to_string()) } @@ -465,8 +465,8 @@ mod tests { } #[test] - fn test_get_api_gateway_addr() { - let addr = get_api_gateway_addr(); + fn test_get_api_addr() { + let addr = get_api_addr(); assert!(!addr.is_empty()); assert!(addr.starts_with("http://")); } diff --git a/testing/api-gateway-load/Cargo.toml b/testing/api-load/Cargo.toml similarity index 97% rename from testing/api-gateway-load/Cargo.toml rename to testing/api-load/Cargo.toml index ec357e7b8..a296bce62 100644 --- a/testing/api-gateway-load/Cargo.toml +++ b/testing/api-load/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "api_gateway_load_tests" +name = "api_load_tests" version = "0.1.0" edition = "2021" diff --git a/testing/api-gateway-load/README.md b/testing/api-load/README.md similarity index 100% rename from testing/api-gateway-load/README.md rename to testing/api-load/README.md diff --git a/testing/api-gateway-load/src/clients/authenticated_client.rs b/testing/api-load/src/clients/authenticated_client.rs similarity index 100% rename from testing/api-gateway-load/src/clients/authenticated_client.rs rename to testing/api-load/src/clients/authenticated_client.rs diff --git a/testing/api-gateway-load/src/clients/mixed_workload.rs b/testing/api-load/src/clients/mixed_workload.rs similarity index 100% rename from testing/api-gateway-load/src/clients/mixed_workload.rs rename to testing/api-load/src/clients/mixed_workload.rs diff --git a/testing/api-gateway-load/src/clients/mod.rs b/testing/api-load/src/clients/mod.rs similarity index 100% rename from testing/api-gateway-load/src/clients/mod.rs rename to testing/api-load/src/clients/mod.rs diff --git a/testing/api-gateway-load/src/config.rs b/testing/api-load/src/config.rs similarity index 100% rename from testing/api-gateway-load/src/config.rs rename to testing/api-load/src/config.rs diff --git a/testing/api-gateway-load/src/main.rs b/testing/api-load/src/main.rs similarity index 100% rename from testing/api-gateway-load/src/main.rs rename to testing/api-load/src/main.rs diff --git a/testing/api-gateway-load/src/metrics/collector.rs b/testing/api-load/src/metrics/collector.rs similarity index 100% rename from testing/api-gateway-load/src/metrics/collector.rs rename to testing/api-load/src/metrics/collector.rs diff --git a/testing/api-gateway-load/src/metrics/mod.rs b/testing/api-load/src/metrics/mod.rs similarity index 100% rename from testing/api-gateway-load/src/metrics/mod.rs rename to testing/api-load/src/metrics/mod.rs diff --git a/testing/api-gateway-load/src/orchestrator.rs b/testing/api-load/src/orchestrator.rs similarity index 100% rename from testing/api-gateway-load/src/orchestrator.rs rename to testing/api-load/src/orchestrator.rs diff --git a/testing/api-gateway-load/src/reporting.rs b/testing/api-load/src/reporting.rs similarity index 100% rename from testing/api-gateway-load/src/reporting.rs rename to testing/api-load/src/reporting.rs diff --git a/testing/api-gateway-load/src/scenarios/mod.rs b/testing/api-load/src/scenarios/mod.rs similarity index 100% rename from testing/api-gateway-load/src/scenarios/mod.rs rename to testing/api-load/src/scenarios/mod.rs diff --git a/testing/api-gateway-load/src/scenarios/normal_load.rs b/testing/api-load/src/scenarios/normal_load.rs similarity index 100% rename from testing/api-gateway-load/src/scenarios/normal_load.rs rename to testing/api-load/src/scenarios/normal_load.rs diff --git a/testing/api-gateway-load/src/scenarios/spike_load.rs b/testing/api-load/src/scenarios/spike_load.rs similarity index 100% rename from testing/api-gateway-load/src/scenarios/spike_load.rs rename to testing/api-load/src/scenarios/spike_load.rs diff --git a/testing/api-gateway-load/src/scenarios/stress_test.rs b/testing/api-load/src/scenarios/stress_test.rs similarity index 100% rename from testing/api-gateway-load/src/scenarios/stress_test.rs rename to testing/api-load/src/scenarios/stress_test.rs diff --git a/testing/api-gateway-load/src/scenarios/sustained_load.rs b/testing/api-load/src/scenarios/sustained_load.rs similarity index 100% rename from testing/api-gateway-load/src/scenarios/sustained_load.rs rename to testing/api-load/src/scenarios/sustained_load.rs diff --git a/testing/integration/smoke_tests/mod.rs b/testing/integration/smoke_tests/mod.rs index 37699a7a5..cafa6b3bd 100644 --- a/testing/integration/smoke_tests/mod.rs +++ b/testing/integration/smoke_tests/mod.rs @@ -68,7 +68,7 @@ pub mod common { } /// Load API Gateway URL from environment - pub fn api_gateway_url() -> String { + pub fn api_url() -> String { std::env::var("API_GATEWAY_URL") .unwrap_or_else(|_| "http://localhost:50051".to_string()) } diff --git a/testing/integration/smoke_tests/service_health.rs b/testing/integration/smoke_tests/service_health.rs index a8978656e..d36926ab7 100644 --- a/testing/integration/smoke_tests/service_health.rs +++ b/testing/integration/smoke_tests/service_health.rs @@ -46,9 +46,9 @@ async fn test_trading_service_health() { } #[tokio::test] -async fn test_api_gateway_health() { +async fn test_api_health() { let result = with_timeout(async { - let url = api_gateway_url(); + let url = api_url(); println!("Testing API Gateway at {}", url); // Try gRPC connection @@ -66,7 +66,7 @@ async fn test_api_gateway_health() { } }).await; - skip_if_unavailable!("API Gateway", { result }); + skip_if_unavailable!("API", { result }); } #[tokio::test] @@ -122,7 +122,7 @@ async fn test_service_ports_listening() { println!("🔍 Checking service ports..."); let ports_to_check = vec![ - (50051, "API Gateway"), // Primary entry point + (50051, "API"), // Primary entry point (50052, "Trading Service"), // Backend service (50053, "Backtesting Service"), (50054, "ML Training Service"), @@ -159,7 +159,7 @@ async fn test_service_response_times() { let services = vec![ (trading_service_url(), "Trading Service"), - (api_gateway_url(), "API Gateway"), + (api_url(), "API"), ]; for (url, name) in services { @@ -197,7 +197,7 @@ async fn test_metrics_endpoints() { let client = reqwest::Client::new(); let metrics_ports = vec![ - (9091, "API Gateway"), + (9091, "API"), (9092, "Trading Service"), (9093, "Backtesting Service"), (9094, "ML Training Service"), diff --git a/testing/integration/standalone/watch_tuning_progress_updated.rs b/testing/integration/standalone/watch_tuning_progress_updated.rs index 82f2cc283..499abcdbe 100644 --- a/testing/integration/standalone/watch_tuning_progress_updated.rs +++ b/testing/integration/standalone/watch_tuning_progress_updated.rs @@ -1,6 +1,6 @@ /// Watch tuning progress with live updates (poll every 5 seconds) async fn watch_tuning_progress( - api_gateway_url: &str, + api_url: &str, jwt_token: &str, job_id: &str, ) -> AnyhowResult<()> { @@ -14,7 +14,7 @@ async fn watch_tuning_progress( .context("❌ Invalid job ID format (expected UUID)")?; // Create gRPC client once (reuse connection) - let mut client = MlTrainingServiceClient::connect(api_gateway_url.to_string()) + let mut client = MlTrainingServiceClient::connect(api_url.to_string()) .await .context("Failed to connect to API Gateway")?; diff --git a/testing/service-integration/src/metrics_validation.rs b/testing/service-integration/src/metrics_validation.rs index 79ca359d9..606a7a198 100644 --- a/testing/service-integration/src/metrics_validation.rs +++ b/testing/service-integration/src/metrics_validation.rs @@ -360,7 +360,7 @@ api_gateway_latency_seconds{quantile="0.99"} 0.5 // Integration tests (require services running) #[tokio::test] #[ignore = "Only run with `cargo test -- --ignored`"] - async fn test_api_gateway_metrics() { + async fn test_api_metrics() { let required = RequiredMetrics::new(); let result = validate_service_metrics( "api_gateway", diff --git a/testing/service-integration/tests/backtesting_service_e2e.rs b/testing/service-integration/tests/backtesting_service_e2e.rs index e1fc6ad52..aa2355a64 100644 --- a/testing/service-integration/tests/backtesting_service_e2e.rs +++ b/testing/service-integration/tests/backtesting_service_e2e.rs @@ -19,7 +19,7 @@ use tonic::{metadata::MetadataValue, transport::Channel, Request, Status}; // Common test utilities (JWT auth helpers) mod common; -use common::auth_helpers::{create_test_jwt, get_api_gateway_addr, TestAuthConfig}; +use common::auth_helpers::{create_test_jwt, get_api_addr, TestAuthConfig}; // Generated proto code pub mod trading { @@ -56,8 +56,8 @@ async fn create_authenticated_client() -> Result< let token = create_test_jwt(config)?; - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; // Create interceptor that injects JWT token AND user context into request metadata let user_id_owned = user_id.to_string(); @@ -588,8 +588,8 @@ async fn test_e2e_backtest_unauthenticated_access() -> Result<()> { println!("\n=== E2E Test: Unauthenticated Backtest Access ==="); // Create client without authentication - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let mut client = BacktestingServiceClient::new(channel); let start_date = (Utc::now() - Duration::days(7)) diff --git a/testing/service-integration/tests/common/auth_helpers.rs b/testing/service-integration/tests/common/auth_helpers.rs index 6c390bcb2..5f51abf4c 100644 --- a/testing/service-integration/tests/common/auth_helpers.rs +++ b/testing/service-integration/tests/common/auth_helpers.rs @@ -232,7 +232,7 @@ pub fn get_test_user_id() -> String { } /// Get API Gateway address from environment or use default -pub fn get_api_gateway_addr() -> String { +pub fn get_api_addr() -> String { std::env::var("API_GATEWAY_ADDR").unwrap_or_else(|_| DEFAULT_API_GATEWAY_ADDR.to_string()) } @@ -538,8 +538,8 @@ mod tests { } #[test] - fn test_get_api_gateway_addr() { - let addr = get_api_gateway_addr(); + fn test_get_api_addr() { + let addr = get_api_addr(); assert!(!addr.is_empty()); assert!(addr.starts_with("http://")); } diff --git a/testing/service-integration/tests/service_health_resilience_e2e.rs b/testing/service-integration/tests/service_health_resilience_e2e.rs index cbef6ec22..ccc2178ba 100644 --- a/testing/service-integration/tests/service_health_resilience_e2e.rs +++ b/testing/service-integration/tests/service_health_resilience_e2e.rs @@ -13,7 +13,7 @@ mod common; use anyhow::Result; -use common::auth_helpers::{create_auth_interceptor, get_api_gateway_addr, TestAuthConfig}; +use common::auth_helpers::{create_auth_interceptor, get_api_addr, TestAuthConfig}; use std::time::Duration as StdDuration; use tokio::time::timeout; use tonic::{transport::Channel, Code, Request}; @@ -38,8 +38,8 @@ use trading::{ async fn test_e2e_system_health_all_services() -> Result<()> { println!("\n=== E2E Test: System Health - All Services ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::admin().with_user_id("health_monitor"); let interceptor = create_auth_interceptor(config)?; @@ -64,12 +64,12 @@ async fn test_e2e_system_health_all_services() -> Result<()> { } // At least API Gateway should be healthy - let api_gateway_healthy = system_status + let api_healthy = system_status .services .iter() .any(|s| s.name.contains("gateway") && s.status == SystemStatus::Healthy as i32); - assert!(api_gateway_healthy, "API Gateway should be healthy"); + assert!(api_healthy, "API should be healthy"); Ok(()) } @@ -78,8 +78,8 @@ async fn test_e2e_system_health_all_services() -> Result<()> { async fn test_e2e_system_health_specific_service() -> Result<()> { println!("\n=== E2E Test: System Health - Specific Service ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::admin().with_user_id("health_monitor"); let interceptor = create_auth_interceptor(config)?; @@ -109,8 +109,8 @@ async fn test_e2e_system_health_specific_service() -> Result<()> { async fn test_e2e_health_check_interval() -> Result<()> { println!("\n=== E2E Test: Health Check Update Interval ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::admin().with_user_id("health_monitor"); let interceptor = create_auth_interceptor(config)?; @@ -150,8 +150,8 @@ async fn test_e2e_health_check_interval() -> Result<()> { async fn test_e2e_health_status_transitions() -> Result<()> { println!("\n=== E2E Test: Health Status Transitions Monitoring ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::admin().with_user_id("health_monitor"); let interceptor = create_auth_interceptor(config)?; @@ -191,8 +191,8 @@ async fn test_e2e_health_status_transitions() -> Result<()> { async fn test_e2e_degraded_service_detection() -> Result<()> { println!("\n=== E2E Test: Degraded Service Detection ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::admin().with_user_id("health_monitor"); let interceptor = create_auth_interceptor(config)?; @@ -236,8 +236,8 @@ async fn test_e2e_degraded_service_detection() -> Result<()> { async fn test_e2e_trading_service_available_backtesting_optional() -> Result<()> { println!("\n=== E2E Test: Trading Service Available, Backtesting Optional ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::trader().with_user_id("test_trader"); let interceptor = create_auth_interceptor(config)?; @@ -295,8 +295,8 @@ async fn test_e2e_trading_service_available_backtesting_optional() -> Result<()> async fn test_e2e_partial_service_failure_handling() -> Result<()> { println!("\n=== E2E Test: Partial Service Failure Handling ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::admin().with_user_id("resilience_tester"); let interceptor = create_auth_interceptor(config)?; @@ -335,8 +335,8 @@ async fn test_e2e_partial_service_failure_handling() -> Result<()> { async fn test_e2e_circuit_breaker_validation() -> Result<()> { println!("\n=== E2E Test: Circuit Breaker Validation ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::trader().with_user_id("test_trader"); let interceptor = create_auth_interceptor(config)?; @@ -389,8 +389,8 @@ async fn test_e2e_circuit_breaker_validation() -> Result<()> { async fn test_e2e_timeout_handling() -> Result<()> { println!("\n=== E2E Test: Request Timeout Handling ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)? + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)? .timeout(StdDuration::from_millis(100)) // Very short timeout .connect() .await?; @@ -423,8 +423,8 @@ async fn test_e2e_timeout_handling() -> Result<()> { async fn test_e2e_retry_logic_validation() -> Result<()> { println!("\n=== E2E Test: Retry Logic Validation ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::trader().with_user_id("test_trader"); let interceptor = create_auth_interceptor(config)?; @@ -482,11 +482,11 @@ async fn test_e2e_retry_logic_validation() -> Result<()> { // ============================================================================ #[tokio::test] -async fn test_e2e_api_gateway_routing() -> Result<()> { +async fn test_e2e_api_routing() -> Result<()> { println!("\n=== E2E Test: API Gateway Routing Validation ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::trader().with_user_id("routing_tester"); let interceptor = create_auth_interceptor(config)?; @@ -518,8 +518,8 @@ async fn test_e2e_api_gateway_routing() -> Result<()> { async fn test_e2e_service_discovery() -> Result<()> { println!("\n=== E2E Test: Service Discovery ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::admin().with_user_id("discovery_tester"); let interceptor = create_auth_interceptor(config)?; @@ -554,12 +554,12 @@ async fn test_e2e_service_discovery() -> Result<()> { async fn test_e2e_concurrent_service_requests() -> Result<()> { println!("\n=== E2E Test: Concurrent Service Requests ==="); - let api_gateway_addr = get_api_gateway_addr(); + let api_addr = get_api_addr(); let mut handles = vec![]; // Spawn 10 concurrent requests for i in 0..10 { - let addr = api_gateway_addr.clone(); + let addr = api_addr.clone(); let handle = tokio::spawn(async move { let channel = Channel::from_shared(addr).unwrap().connect().await.unwrap(); @@ -598,8 +598,8 @@ async fn test_e2e_concurrent_service_requests() -> Result<()> { async fn test_e2e_load_balancing_verification() -> Result<()> { println!("\n=== E2E Test: Load Balancing Verification ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::trader().with_user_id("load_tester"); let interceptor = create_auth_interceptor(config)?; @@ -641,8 +641,8 @@ async fn test_e2e_load_balancing_verification() -> Result<()> { async fn test_e2e_service_failover() -> Result<()> { println!("\n=== E2E Test: Service Failover Behavior ==="); - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let config = TestAuthConfig::admin().with_user_id("failover_tester"); let interceptor = create_auth_interceptor(config)?; diff --git a/testing/service-integration/tests/trading_service_e2e.rs b/testing/service-integration/tests/trading_service_e2e.rs index fbe4c3076..c21fae464 100644 --- a/testing/service-integration/tests/trading_service_e2e.rs +++ b/testing/service-integration/tests/trading_service_e2e.rs @@ -19,7 +19,7 @@ use uuid::Uuid; // Common test utilities (JWT auth helpers and DBN data) mod common; -use common::auth_helpers::{create_test_jwt, get_api_gateway_addr, TestAuthConfig}; +use common::auth_helpers::{create_test_jwt, get_api_addr, TestAuthConfig}; use common::dbn_helpers::get_dbn_manager; // Generated proto code @@ -58,8 +58,8 @@ async fn create_authenticated_client() -> Result< let token = create_test_jwt(config)?; - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; // Create interceptor that injects JWT token AND user context into request metadata let user_id_owned = user_id.to_string(); @@ -173,8 +173,8 @@ async fn test_e2e_order_submission_without_auth() -> Result<()> { println!("\n=== E2E Test: Order Submission Without Authentication ==="); // Create unauthenticated client (no JWT) - let api_gateway_addr = get_api_gateway_addr(); - let channel = Channel::from_shared(api_gateway_addr)?.connect().await?; + let api_addr = get_api_addr(); + let channel = Channel::from_shared(api_addr)?.connect().await?; let mut client = TradingServiceClient::new(channel); let request = Request::new(SubmitOrderRequest {