|
6 | 6 | require 'minitest_helper'
|
7 | 7 | require 'minitest/mock'
|
8 | 8 | require './lib/solarwinds_apm/api'
|
| 9 | +require './lib/solarwinds_apm/sampling' |
| 10 | +require 'sampling_test_helper' |
9 | 11 |
|
10 | 12 | describe 'Test solarwinds_ready API call' do
|
11 |
| - it 'default_test_solarwinds_ready' do |
12 |
| - SolarWindsAPM::Context.stub(:isReady, 1) do |
13 |
| - _(SolarWindsAPM::API.solarwinds_ready?).must_equal true |
14 |
| - end |
15 |
| - end |
16 |
| - |
17 |
| - it 'solarwinds_ready_with_5000_wait_time' do |
18 |
| - SolarWindsAPM::Context.stub(:isReady, 1) do |
19 |
| - _(SolarWindsAPM::API.solarwinds_ready?(5000)).must_equal true |
20 |
| - end |
| 13 | + let(:tracer) { OpenTelemetry.tracer_provider.tracer('test') } |
| 14 | + before do |
| 15 | + ENV['OTEL_TRACES_EXPORTER'] = 'none' |
| 16 | + OpenTelemetry::SDK.configure |
| 17 | + |
| 18 | + @memory_exporter = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new |
| 19 | + OpenTelemetry.tracer_provider.add_span_processor(OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(@memory_exporter)) |
| 20 | + |
| 21 | + @config = { |
| 22 | + collector: 'https://apm.collector.st-ssp.solarwinds.com:443', |
| 23 | + service: 'test-ruby', |
| 24 | + headers: "Bearer #{ENV.fetch('APM_RUBY_TEST_STAGING_KEY', nil)}", |
| 25 | + tracing_mode: true, |
| 26 | + trigger_trace_enabled: true |
| 27 | + } |
21 | 28 | end
|
22 | 29 |
|
23 |
| - it 'solarwinds_ready_with_5000_wait_time_and_int_response' do |
24 |
| - SolarWindsAPM::Context.stub(:isReady, 1) do |
25 |
| - _(SolarWindsAPM::API.solarwinds_ready?(5000, integer_response: true)).must_equal 1 |
26 |
| - end |
| 30 | + after do |
| 31 | + OpenTelemetry::TestHelpers.reset_opentelemetry |
| 32 | + @memory_exporter.reset |
27 | 33 | end
|
28 | 34 |
|
29 |
| - it 'solarwinds_ready_with_default_wait_time_and_int_response' do |
30 |
| - SolarWindsAPM::Context.stub(:isReady, 1) do |
31 |
| - _(SolarWindsAPM::API.solarwinds_ready?(integer_response: true)).must_equal 1 |
32 |
| - end |
| 35 | + it 'default_test_solarwinds_ready' do |
| 36 | + new_config = @config.dup |
| 37 | + sampler = SolarWindsAPM::HttpSampler.new(new_config) |
| 38 | + replace_sampler(sampler) |
| 39 | + _(SolarWindsAPM::API.solarwinds_ready?).must_equal true |
33 | 40 | end
|
34 | 41 |
|
35 |
| - it 'solarwinds_ready_with_default_wait_time_and_int_response_as_4' do |
36 |
| - SolarWindsAPM::Context.stub(:isReady, 4) do |
37 |
| - _(SolarWindsAPM::API.solarwinds_ready?(integer_response: true)).must_equal 4 |
38 |
| - end |
| 42 | + it 'solarwinds_ready_with_5000_wait_time' do |
| 43 | + new_config = @config.dup |
| 44 | + sampler = SolarWindsAPM::HttpSampler.new(new_config) |
| 45 | + replace_sampler(sampler) |
| 46 | + _(SolarWindsAPM::API.solarwinds_ready?(5000)).must_equal true |
39 | 47 | end
|
40 | 48 |
|
41 |
| - it 'solarwinds_ready_with_default_wait_time_and_int_response_as_false' do |
42 |
| - SolarWindsAPM::Context.stub(:isReady, 1) do |
43 |
| - _(SolarWindsAPM::API.solarwinds_ready?(integer_response: false)).must_equal true |
44 |
| - end |
| 49 | + it 'solarwinds_ready_with_invalid_collector' do |
| 50 | + new_config = @config.merge(collector: URI('https://collector.invalid')) |
| 51 | + sampler = SolarWindsAPM::HttpSampler.new(new_config) |
| 52 | + replace_sampler(sampler) |
| 53 | + _(SolarWindsAPM::API.solarwinds_ready?(100_000)).must_equal false |
45 | 54 | end
|
46 | 55 | end
|
0 commit comments