From dd90f321dee26b2272486b55b84add108cf1b09c Mon Sep 17 00:00:00 2001 From: Robert Mosolgo Date: Fri, 13 Oct 2023 11:21:12 -0400 Subject: [PATCH] ci: Update test reset code for GraphQL-Ruby 2.1.3 (#691) Fixes https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/689 --- .../instrumentation/graphql/tracers/graphql_trace_test.rb | 3 +-- .../instrumentation/graphql/tracers/graphql_tracer_test.rb | 4 +--- instrumentation/graphql/test/test_helper.rb | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_trace_test.rb b/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_trace_test.rb index 26b2cf6a2..5d4111b74 100644 --- a/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_trace_test.rb +++ b/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_trace_test.rb @@ -97,8 +97,7 @@ after do # Reset various instance variables to clear state between tests - SomeOtherGraphQLAppSchema.instance_variable_set(:@own_tracers, []) - SomeOtherGraphQLAppSchema.instance_variable_set(:@own_plugins, SomeOtherGraphQLAppSchema.plugins[0..1]) + [GraphQL::Schema, SomeOtherGraphQLAppSchema, SomeGraphQLAppSchema].each(&:_reset_tracer_for_testing) end it 'traces the provided schemas' do diff --git a/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_tracer_test.rb b/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_tracer_test.rb index 496580bee..35e5e4b0d 100644 --- a/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_tracer_test.rb +++ b/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_tracer_test.rb @@ -97,13 +97,11 @@ after do # Reset various instance variables to clear state between tests - SomeOtherGraphQLAppSchema.instance_variable_set(:@own_tracers, []) - SomeOtherGraphQLAppSchema.instance_variable_set(:@own_plugins, SomeOtherGraphQLAppSchema.plugins[0..1]) + [GraphQL::Schema, SomeOtherGraphQLAppSchema, SomeGraphQLAppSchema].each(&:_reset_tracer_for_testing) end it 'traces the provided schemas' do SomeOtherGraphQLAppSchema.execute('query SimpleQuery{ __typename }') - _(spans.size).must_equal(8) end diff --git a/instrumentation/graphql/test/test_helper.rb b/instrumentation/graphql/test/test_helper.rb index 330b3d836..75f349b28 100644 --- a/instrumentation/graphql/test/test_helper.rb +++ b/instrumentation/graphql/test/test_helper.rb @@ -25,7 +25,7 @@ module SchemaTestPatches # Reseting @graphql_definition is needed for tests running against version `1.9.x` # Other variables are used by ~> 2.0.19 def _reset_tracer_for_testing - %w[own_tracers trace_modes trace_class tracers graphql_definition].each do |ivar| + %w[own_tracers trace_modes trace_class tracers graphql_definition own_trace_modes].each do |ivar| remove_instance_variable("@#{ivar}") if instance_variable_defined?("@#{ivar}") end end