Skip to content

Commit b6f525c

Browse files
committed
new test case method
1 parent 5ff6ab0 commit b6f525c

21 files changed

+168
-234
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,11 @@ To run the full suite:
165165
test/run_tests.sh
166166
```
167167

168-
To run a single test file:
168+
To run a single test file or single test case:
169169

170170
```bash
171171
# most tests require just the unit.gemfile dependencies
172-
BUNDLE_GEMFILE=gemfiles/unit.gemfile bundle update
173-
174-
BUNDLE_GEMFILE=gemfiles/unit.gemfile bundle exec ruby -I test test/opentelemetry/solarwinds_propagator_test.rb
175-
```
176-
177-
To run a specific test with 'trace_state_header' inside test case name:
178-
179-
```bash
180-
BUNDLE_GEMFILE=gemfiles/unit.gemfile bundle update
181-
182-
BUNDLE_GEMFILE=gemfiles/unit.gemfile bundle exec ruby -I test test/opentelemetry/solarwinds_propagator_test.rb -n /trace_state_header/
172+
bundle update
173+
bundle exec ruby -I test test/opentelemetry/solarwinds_propagator_test.rb
174+
bundle exec ruby -I test test/opentelemetry/solarwinds_propagator_test.rb -n /trace_state_header/
183175
```

Gemfile

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,45 @@
22

33
source 'https://rubygems.org'
44

5-
# this Gemfile is very minimal
6-
# use rake commands or gemfiles in the gemfiles directory for testing
7-
8-
gem 'rake', '>= 0.9.0'
5+
gem 'rake'
96

107
group :development, :test do
8+
if RUBY_VERSION < '3.0.0'
9+
gem 'ffi', '<= 1.16.3' # set this version due to ffi 1.17.0 need rubygems version > 3 (https://rubygems.org/gems/ffi/versions/1.17.0-arm-linux-musl)
10+
gem 'google-protobuf', '< 3.25.4'
11+
elsif RUBY_VERSION < '3.1.0'
12+
gem 'ffi', '<= 1.17'
13+
else
14+
gem 'ffi'
15+
end
16+
gem 'benchmark-ips', '>= 2.7.2'
17+
gem 'bson'
1118
gem 'byebug', '>= 8.0.0'
12-
gem 'irb', '>= 1.0.0' # if RUBY_VERSION >= '2.6.0'
19+
gem 'e2mmap'
20+
gem 'get_process_mem'
21+
gem 'irb', '>= 1.0.0'
22+
gem 'logging'
23+
gem 'lumberjack'
1324
gem 'memory_profiler'
14-
gem 'rubocop'
25+
gem 'minitest', '< 5.25.0'
26+
gem 'minitest-debugger', require: false
27+
gem 'minitest-focus', '>= 1.1.2'
28+
gem 'minitest-hooks', '>= 1.5.0'
29+
gem 'minitest-reporters', '< 1.0.18'
30+
gem 'mocha'
31+
gem 'rack-cache'
32+
gem 'rack-test'
33+
gem 'rubocop', require: false
1534
gem 'rubocop-performance', require: false
1635
gem 'rubocop-rake', require: false
36+
gem 'code-scanning-rubocop', '~> 0.6.1'
37+
gem 'simplecov', require: false, group: :test
38+
gem 'simplecov-console', require: false, group: :test
39+
gem 'webmock' if RUBY_VERSION >= '2.0.0'
40+
gem 'base64' if RUBY_VERSION >= '3.4.0'
41+
42+
gem 'opentelemetry-propagator-b3'
43+
gem 'opentelemetry-test-helpers'
44+
1745
gemspec
1846
end

gemfiles/test_gems.gemfile

Lines changed: 0 additions & 51 deletions
This file was deleted.

gemfiles/unit.gemfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/api/custom_instrumentation_test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
it 'test_custom_instrumentation_simple_case' do
3131
class MyClass
3232
include SolarWindsAPM::API::Tracer
33+
3334
def new_method(param1, param2)
3435
param1 + param2
3536
end
@@ -54,6 +55,7 @@ def new_method(param1, param2)
5455
it 'test_custom_instrumentation_simple_case_with_custom_name_and_options' do
5556
class MyClass
5657
include SolarWindsAPM::API::Tracer
58+
5759
def new_method(param1, param2)
5860
param1 + param2
5961
end
@@ -83,6 +85,7 @@ def self.new_method(param1, param2)
8385

8486
class << self
8587
include SolarWindsAPM::API::Tracer
88+
8689
add_tracer :new_method, 'custom_name', { attributes: { 'foo' => 'bar' }, kind: :unknown }
8790
end
8891
end

test/initest_helper.rb

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,11 @@
88
require 'minitest/spec'
99
require 'minitest/reporters'
1010
require './lib/solarwinds_apm/logger'
11+
require 'simplecov'
12+
SimpleCov.start
1113

1214
ENV['SW_APM_SERVICE_KEY'] = 'this-is-a-dummy-api-token-for-testing-111111111111111111111111111111111:test-service'
1315

14-
# write to a file as well as STDOUT (comes in handy with docker runs)
15-
# This approach preserves the coloring of pass fail, which the cli
16-
# `./run_tests.sh 2>&1 | tee -a test/docker_test.log` does not
17-
if ENV['TEST_RUNS_TO_FILE']
18-
FileUtils.mkdir_p('log') # create if it doesn't exist
19-
$out_file = if ENV['TEST_RUNS_FILE_NAME']
20-
File.new(ENV['TEST_RUNS_FILE_NAME'], 'a')
21-
else
22-
File.new("log/test_direct_runs_#{Time.now.strftime('%Y%m%d_%H_%M')}.log", 'a')
23-
end
24-
$out_file.sync = true
25-
$stdout.sync = true
26-
27-
def $stdout.write(string)
28-
$out_file.write(string)
29-
super
30-
end
31-
end
32-
3316
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
3417

3518
$LOAD_PATH.unshift("#{Dir.pwd}/lib/")

test/minitest_helper.rb

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,21 @@
1818
require 'lumberjack'
1919
require 'logging'
2020
require 'bson'
21-
require 'grpc'
2221
require 'pp'
2322

2423
require './lib/solarwinds_apm/version'
2524
require './lib/solarwinds_apm/logger'
25+
require './lib/solarwinds_apm/constants'
26+
require 'opentelemetry-exporter-otlp-metrics'
2627

27-
# simplecov coverage information
2828
require 'simplecov'
29-
require 'simplecov-console'
30-
SimpleCov.formatter = SimpleCov::Formatter::Console
31-
SimpleCov::Formatter::Console.max_rows = 15
32-
SimpleCov::Formatter::Console.max_lines = 5
33-
SimpleCov::Formatter::Console.missing_len = 20
3429
SimpleCov.start
3530

3631
# needed by most tests
3732
ENV['SW_APM_SERVICE_KEY'] = 'this-is-a-dummy-api-token-for-testing-111111111111111111111111111111111:test-service'
38-
39-
# write to a file as well as STDOUT (comes in handy with docker runs)
40-
# This approach preserves the coloring of pass fail, which the cli
41-
# `./run_tests.sh 2>&1 | tee -a test/docker_test.log` does not
42-
if ENV['TEST_RUNS_TO_FILE']
43-
FileUtils.mkdir_p('log') # create if it doesn't exist
44-
$out_file = if ENV['TEST_RUNS_FILE_NAME']
45-
File.new(ENV['TEST_RUNS_FILE_NAME'], 'a')
46-
else
47-
File.new("log/test_direct_runs_#{Time.now.strftime('%Y%m%d_%H_%M')}.log", 'a')
48-
end
49-
$out_file.sync = true
50-
$stdout.sync = true
51-
52-
def $stdout.write(string)
53-
$out_file.write(string)
54-
super
55-
end
56-
end
57-
58-
# Print out a headline in with the settings used in the test run
59-
puts "\n\033[1m=== TEST RUN: #{RUBY_VERSION} #{File.basename(ENV.fetch('BUNDLE_GEMFILE', nil))} #{ENV.fetch('DBTYPE', nil)} #{ENV.fetch('TEST_PREPARED_STATEMENT', nil)} #{Time.now.strftime('%Y-%m-%d %H:%M')} ===\033[0m\n" unless ENV['DBO_PATCH_TEST']
60-
6133
ENV['RACK_ENV'] = 'test'
6234
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
6335

64-
# Bundler.require(:default, :test) # this load the solarwinds_apm library
6536
SolarWindsAPM.logger.level = 1
6637

6738
# Dummy Propagator for testing

test/opentelemetry/otlp_processor_sampled_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
require 'minitest_helper'
77
require './lib/solarwinds_apm/opentelemetry'
8-
require './lib/solarwinds_apm/constants'
98
require './lib/solarwinds_apm/support/txn_name_manager'
109
require './lib/solarwinds_apm/support/utils'
1110
require './lib/solarwinds_apm/sampling/sampling_patch'

test/opentelemetry/otlp_processor_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
require 'minitest_helper'
77
require './lib/solarwinds_apm/config'
88
require './lib/solarwinds_apm/opentelemetry'
9-
require './lib/solarwinds_apm/constants'
109
require './lib/solarwinds_apm/support/txn_name_manager'
1110
require './lib/solarwinds_apm/otel_native_config'
1211
require './lib/solarwinds_apm/api'

test/opentelemetry/otlp_processor_unsampled_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
require 'minitest_helper'
77
require './lib/solarwinds_apm/opentelemetry'
8-
require './lib/solarwinds_apm/constants'
98
require './lib/solarwinds_apm/support/txn_name_manager'
109
require './lib/solarwinds_apm/support/utils'
1110
require './lib/solarwinds_apm/sampling/sampling_patch'

0 commit comments

Comments
 (0)