diff --git a/.changesets/maint_bryn_disable_tests_apollo_key_missing.md b/.changesets/maint_bryn_disable_tests_apollo_key_missing.md new file mode 100644 index 0000000000..65999285f8 --- /dev/null +++ b/.changesets/maint_bryn_disable_tests_apollo_key_missing.md @@ -0,0 +1,6 @@ +### Disable GraphOS tests when apollo key not present ([PR #5362](https://github.com/apollographql/router/pull/5362)) + +A number of tests require APOLLO_KEY and APOLLO_GRAPH_REF to be present to execute successfully. +These are now skipped if these env variables are not present. + +By [@BrynCooke](https://github.com/BrynCooke) in https://github.com/apollographql/router/pull/5362 diff --git a/apollo-router/tests/common.rs b/apollo-router/tests/common.rs index 143be91bc9..22e40d5385 100644 --- a/apollo-router/tests/common.rs +++ b/apollo-router/tests/common.rs @@ -1150,3 +1150,14 @@ fn merge_overrides( serde_yaml::to_string(&config).unwrap() } + +#[allow(dead_code)] +pub fn graph_os_enabled() -> bool { + matches!( + ( + std::env::var("TEST_APOLLO_KEY"), + std::env::var("TEST_APOLLO_GRAPH_REF"), + ), + (Ok(_), Ok(_)) + ) +} diff --git a/apollo-router/tests/integration/coprocessor.rs b/apollo-router/tests/integration/coprocessor.rs index d8d2ffadb0..02924763f5 100644 --- a/apollo-router/tests/integration/coprocessor.rs +++ b/apollo-router/tests/integration/coprocessor.rs @@ -1,10 +1,14 @@ use insta::assert_yaml_snapshot; use tower::BoxError; +use crate::integration::common::graph_os_enabled; use crate::integration::IntegrationTest; #[tokio::test(flavor = "multi_thread")] async fn test_error_not_propagated_to_client() -> Result<(), BoxError> { + if !graph_os_enabled() { + return Ok(()); + } let mut router = IntegrationTest::builder() .config(include_str!("fixtures/broken_coprocessor.router.yaml")) .build() @@ -18,6 +22,5 @@ async fn test_error_not_propagated_to_client() -> Result<(), BoxError> { assert_yaml_snapshot!(response.text().await?); router.assert_log_contains("INTERNAL_SERVER_ERROR").await; router.graceful_shutdown().await; - Ok(()) } diff --git a/apollo-router/tests/integration/redis.rs b/apollo-router/tests/integration/redis.rs index 1d1d5bfd73..50ccb9ac92 100644 --- a/apollo-router/tests/integration/redis.rs +++ b/apollo-router/tests/integration/redis.rs @@ -19,6 +19,7 @@ use serde_json::Value; use tower::BoxError; use tower::ServiceExt; +use crate::integration::common::graph_os_enabled; use crate::integration::IntegrationTest; #[tokio::test(flavor = "multi_thread")] @@ -958,6 +959,9 @@ async fn query_planner_redis_update_reuse_query_fragments() { } async fn test_redis_query_plan_config_update(updated_config: &str, new_cache_key: &str) { + if !graph_os_enabled() { + return; + } // This test shows that the redis key changes when the query planner config changes. // The test starts a router with a specific config, executes a query, and checks the redis cache key. // Then it updates the config, executes the query again, and checks the redis cache key. diff --git a/apollo-router/tests/integration/telemetry/metrics.rs b/apollo-router/tests/integration/telemetry/metrics.rs index 6e745671f3..74465528bf 100644 --- a/apollo-router/tests/integration/telemetry/metrics.rs +++ b/apollo-router/tests/integration/telemetry/metrics.rs @@ -2,6 +2,7 @@ use std::time::Duration; use serde_json::json; +use crate::integration::common::graph_os_enabled; use crate::integration::IntegrationTest; const PROMETHEUS_CONFIG: &str = include_str!("fixtures/prometheus.router.yaml"); @@ -189,6 +190,9 @@ async fn test_bad_queries() { #[tokio::test(flavor = "multi_thread")] async fn test_graphql_metrics() { + if !graph_os_enabled() { + return; + } let mut router = IntegrationTest::builder() .config(include_str!("fixtures/graphql.router.yaml")) .build() @@ -198,21 +202,21 @@ async fn test_graphql_metrics() { router.assert_started().await; router.execute_default_query().await; router - .assert_metrics_contains(r#"graphql_field_list_length_sum{graphql_field_name="topProducts",graphql_field_type="Product",graphql_type_name="Query",otel_scope_name="apollo/router"} 3"#, None) - .await; + .assert_metrics_contains(r#"graphql_field_list_length_sum{graphql_field_name="topProducts",graphql_field_type="Product",graphql_type_name="Query",otel_scope_name="apollo/router"} 3"#, None) + .await; router - .assert_metrics_contains(r#"graphql_field_list_length_bucket{graphql_field_name="topProducts",graphql_field_type="Product",graphql_type_name="Query",otel_scope_name="apollo/router",le="5"} 1"#, None) - .await; + .assert_metrics_contains(r#"graphql_field_list_length_bucket{graphql_field_name="topProducts",graphql_field_type="Product",graphql_type_name="Query",otel_scope_name="apollo/router",le="5"} 1"#, None) + .await; router - .assert_metrics_contains(r#"graphql_field_execution_total{graphql_field_name="name",graphql_field_type="String",graphql_type_name="Product",otel_scope_name="apollo/router"} 3"#, None) - .await; + .assert_metrics_contains(r#"graphql_field_execution_total{graphql_field_name="name",graphql_field_type="String",graphql_type_name="Product",otel_scope_name="apollo/router"} 3"#, None) + .await; router - .assert_metrics_contains(r#"graphql_field_execution_total{graphql_field_name="topProducts",graphql_field_type="Product",graphql_type_name="Query",otel_scope_name="apollo/router"} 1"#, None) - .await; + .assert_metrics_contains(r#"graphql_field_execution_total{graphql_field_name="topProducts",graphql_field_type="Product",graphql_type_name="Query",otel_scope_name="apollo/router"} 1"#, None) + .await; router - .assert_metrics_contains(r#"custom_counter_total{graphql_field_name="name",graphql_field_type="String",graphql_type_name="Product",otel_scope_name="apollo/router"} 3"#, None) - .await; + .assert_metrics_contains(r#"custom_counter_total{graphql_field_name="name",graphql_field_type="String",graphql_type_name="Product",otel_scope_name="apollo/router"} 3"#, None) + .await; router - .assert_metrics_contains(r#"custom_histogram_sum{graphql_field_name="topProducts",graphql_field_type="Product",graphql_type_name="Query",otel_scope_name="apollo/router"} 3"#, None) - .await; + .assert_metrics_contains(r#"custom_histogram_sum{graphql_field_name="topProducts",graphql_field_type="Product",graphql_type_name="Query",otel_scope_name="apollo/router"} 3"#, None) + .await; }