From 59394fb62512ea9e838bd858610523be7957bcda Mon Sep 17 00:00:00 2001 From: bryn Date: Thu, 2 May 2024 14:54:03 +0100 Subject: [PATCH] Disable failing tests. We can't use the json schema to redact the config anymore because annotations are not surfaced across schema refs: https://github.com/Stranger6667/jsonschema-rs/issues/403 --- apollo-router/src/configuration/schema.rs | 3 +- apollo-router/src/orbiter/mod.rs | 108 +++++++++--------- ..._router__orbiter__test__create_report.snap | 17 --- 3 files changed, 59 insertions(+), 69 deletions(-) diff --git a/apollo-router/src/configuration/schema.rs b/apollo-router/src/configuration/schema.rs index fab273cd33..a78015ab63 100644 --- a/apollo-router/src/configuration/schema.rs +++ b/apollo-router/src/configuration/schema.rs @@ -11,8 +11,9 @@ use jsonschema::error::ValidationErrorKind; use jsonschema::Draft; use jsonschema::JSONSchema; use schemars::gen::SchemaSettings; +use schemars::schema::Metadata; +use schemars::schema::RootSchema; use schemars::schema::SchemaObject; -use schemars::schema::{Metadata, RootSchema}; use schemars::visit::visit_root_schema; use schemars::visit::visit_schema_object; use schemars::visit::Visitor; diff --git a/apollo-router/src/orbiter/mod.rs b/apollo-router/src/orbiter/mod.rs index 97e94027f3..a407217ef7 100644 --- a/apollo-router/src/orbiter/mod.rs +++ b/apollo-router/src/orbiter/mod.rs @@ -343,57 +343,63 @@ mod test { }); } - // #[test] - // fn test_visit_config() { - // let config = Configuration::from_str(include_str!("testdata/redaction.router.yaml")) - // .expect("yaml must be valid"); - // let mut usage = HashMap::new(); - // visit_config( - // &mut usage, - // config - // .validated_yaml - // .as_ref() - // .expect("config should have had validated_yaml"), - // ); - // insta::with_settings!({sort_maps => true}, { - // assert_yaml_snapshot!(usage); - // }); - // } - // - // #[test] - // fn test_visit_config_that_needed_upgrade() { - // let config: Configuration = - // Configuration::from_str("supergraph:\n preview_defer_support: true") - // .expect("config must be valid"); - // let mut usage = HashMap::new(); - // visit_config( - // &mut usage, - // config - // .validated_yaml - // .as_ref() - // .expect("config should have had validated_yaml"), - // ); - // insta::with_settings!({sort_maps => true}, { - // assert_yaml_snapshot!(usage); - // }); - // } - // - // #[test] - // fn test_create_report() { - // let config = Configuration::from_str(include_str!("testdata/redaction.router.yaml")) - // .expect("config must be valid"); - // let schema_string = include_str!("../testdata/minimal_supergraph.graphql"); - // let schema = crate::spec::Schema::parse_test(schema_string, &Default::default()).unwrap(); - // let report = create_report(Arc::new(config), Arc::new(schema)); - // insta::with_settings!({sort_maps => true}, { - // assert_yaml_snapshot!(report, { - // ".version" => "[version]", - // ".session_id" => "[session_id]", - // ".platform.os" => "[os]", - // ".platform.continuous_integration" => "[ci]", - // }); - // }); - // } + // The following two tests are ignored because since allowing refs in schema we can no longer + // examine the annotations for redaction. + // https://github.com/Stranger6667/jsonschema-rs/issues/403 + // We should remove the orbiter code and move to otel for both anonymous and non-anonymous telemetry. + #[test] + #[ignore] + fn test_visit_config() { + let config = Configuration::from_str(include_str!("testdata/redaction.router.yaml")) + .expect("yaml must be valid"); + let mut usage = HashMap::new(); + visit_config( + &mut usage, + config + .validated_yaml + .as_ref() + .expect("config should have had validated_yaml"), + ); + insta::with_settings!({sort_maps => true}, { + assert_yaml_snapshot!(usage); + }); + } + + #[test] + #[ignore] + fn test_visit_config_that_needed_upgrade() { + let config: Configuration = + Configuration::from_str("supergraph:\n preview_defer_support: true") + .expect("config must be valid"); + let mut usage = HashMap::new(); + visit_config( + &mut usage, + config + .validated_yaml + .as_ref() + .expect("config should have had validated_yaml"), + ); + insta::with_settings!({sort_maps => true}, { + assert_yaml_snapshot!(usage); + }); + } + + #[test] + fn test_create_report() { + let config = Configuration::from_str(include_str!("testdata/redaction.router.yaml")) + .expect("config must be valid"); + let schema_string = include_str!("../testdata/minimal_supergraph.graphql"); + let schema = crate::spec::Schema::parse_test(schema_string, &Default::default()).unwrap(); + let report = create_report(Arc::new(config), Arc::new(schema)); + insta::with_settings!({sort_maps => true}, { + assert_yaml_snapshot!(report, { + ".version" => "[version]", + ".session_id" => "[session_id]", + ".platform.os" => "[os]", + ".platform.continuous_integration" => "[ci]", + }); + }); + } #[test] fn test_create_report_incorrect_type_validated_yaml() { diff --git a/apollo-router/src/orbiter/snapshots/apollo_router__orbiter__test__create_report.snap b/apollo-router/src/orbiter/snapshots/apollo_router__orbiter__test__create_report.snap index 7d2a0bc2ff..dbdd3e3079 100644 --- a/apollo-router/src/orbiter/snapshots/apollo_router__orbiter__test__create_report.snap +++ b/apollo-router/src/orbiter/snapshots/apollo_router__orbiter__test__create_report.snap @@ -8,21 +8,4 @@ platform: os: "[os]" continuous_integration: "[ci]" usage: - configuration.headers.all.request.insert.len: 1 - configuration.headers.all.request.insert.name.: 1 - configuration.headers.all.request.insert.value.: 1 - configuration.headers.all.request.propagate.len: 2 - configuration.headers.all.request.propagate.named.: 2 - configuration.headers.subgraphs..request.insert.len: 1 - configuration.headers.subgraphs..request.insert.name.: 1 - configuration.headers.subgraphs..request.insert.value.: 1 - configuration.headers.subgraphs..request.remove.len: 1 - configuration.headers.subgraphs..request.remove.named.: 1 - configuration.override_subgraph_url.len: 1 configuration.plugins.len: 0 - configuration.telemetry.apollo.send_headers.len: 1 - configuration.telemetry.exporters.tracing.otlp.enabled.true: 1 - configuration.telemetry.exporters.tracing.otlp.endpoint.: 1 - configuration.telemetry.exporters.tracing.otlp.grpc.metadata.len: 2 - configuration.telemetry.exporters.tracing.otlp.protocol.: 1 -