Skip to content

Commit 2c84fc0

Browse files
authored
DI: make a test method longer to avoid flakiness (#5069)
1 parent 651c3ba commit 2c84fc0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

spec/datadog/di/integration/instrumentation_spec.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ def test_method(a = 1)
2020
42
2121
end
2222

23+
def long_test_method
24+
# This method is used to assert on @duration, and +test_method+
25+
# somehow managed to report an execution time of 0.0 in CI one time
26+
# (though normally it takes about 1 microsecond).
27+
Object.methods.length > 0 and 42
28+
end
29+
2330
def mutating_method(greeting)
2431
greeting.sub!('hello', 'bye')
2532
end
@@ -520,6 +527,15 @@ def run_test
520527
]
521528
end
522529

530+
let(:probe_spec) do
531+
{
532+
id: '1234',
533+
type: 'LOG_PROBE',
534+
where: {typeName: 'InstrumentationSpecTestClass', methodName: 'long_test_method'},
535+
segments: segments,
536+
}
537+
end
538+
523539
it 'substitutes the expected value' do
524540
probe_manager.add_probe(probe)
525541

@@ -535,7 +551,7 @@ def run_test
535551
expect(value).to be > 0
536552
expect(value).to be < 1
537553
end
538-
expect(InstrumentationSpecTestClass.new.test_method).to eq(42)
554+
expect(InstrumentationSpecTestClass.new.long_test_method).to eq(42)
539555
component.probe_notifier_worker.flush
540556
end
541557
end

0 commit comments

Comments
 (0)