appoptics_apm 4.0.3 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile_test +6 -7
  3. data/README.md +3 -3
  4. data/Rakefile +3 -2
  5. data/appoptics_apm.gemspec +2 -2
  6. data/docker-compose.yml +0 -22
  7. data/ext/oboe_metal/extconf.rb +4 -0
  8. data/lib/appoptics_apm/config.rb +11 -6
  9. data/lib/appoptics_apm/version.rb +1 -1
  10. metadata +3 -202
  11. data/gemfiles/delayed_job.gemfile +0 -36
  12. data/gemfiles/frameworks.gemfile +0 -44
  13. data/gemfiles/instrumentation_mocked.gemfile +0 -29
  14. data/gemfiles/libraries.gemfile +0 -85
  15. data/gemfiles/noop.gemfile +0 -17
  16. data/gemfiles/rails23.gemfile +0 -39
  17. data/gemfiles/rails30.gemfile +0 -42
  18. data/gemfiles/rails31.gemfile +0 -44
  19. data/gemfiles/rails32.gemfile +0 -54
  20. data/gemfiles/rails40.gemfile +0 -27
  21. data/gemfiles/rails41.gemfile +0 -27
  22. data/gemfiles/rails42.gemfile +0 -35
  23. data/gemfiles/rails50.gemfile +0 -44
  24. data/gemfiles/rails51.gemfile +0 -44
  25. data/test/benchmark/README.md +0 -65
  26. data/test/benchmark/logging_bench.rb +0 -54
  27. data/test/benchmark/with_libraries_gemfile/bunny_bench.rb +0 -69
  28. data/test/benchmark/with_rails5x_gemfile/action_controller5x_bench.rb +0 -43
  29. data/test/frameworks/apps/grape_nested.rb +0 -33
  30. data/test/frameworks/apps/grape_simple.rb +0 -80
  31. data/test/frameworks/apps/padrino_simple.rb +0 -80
  32. data/test/frameworks/apps/sinatra_simple.rb +0 -55
  33. data/test/frameworks/grape_test.rb +0 -286
  34. data/test/frameworks/padrino_test.rb +0 -222
  35. data/test/frameworks/rails3x_test.rb +0 -554
  36. data/test/frameworks/rails4x_test.rb +0 -570
  37. data/test/frameworks/rails5x_api_test.rb +0 -210
  38. data/test/frameworks/rails5x_test.rb +0 -376
  39. data/test/frameworks/rails_shared_tests.rb +0 -172
  40. data/test/frameworks/sinatra_test.rb +0 -140
  41. data/test/instrumentation/bunny_client_test.rb +0 -276
  42. data/test/instrumentation/bunny_consumer_test.rb +0 -204
  43. data/test/instrumentation/curb_test.rb +0 -398
  44. data/test/instrumentation/dalli_test.rb +0 -177
  45. data/test/instrumentation/em_http_request_test.rb +0 -89
  46. data/test/instrumentation/excon_test.rb +0 -231
  47. data/test/instrumentation/faraday_test.rb +0 -228
  48. data/test/instrumentation/http_test.rb +0 -143
  49. data/test/instrumentation/httpclient_test.rb +0 -304
  50. data/test/instrumentation/memcache_test.rb +0 -260
  51. data/test/instrumentation/memcached_test.rb +0 -229
  52. data/test/instrumentation/mongo_v1_test.rb +0 -479
  53. data/test/instrumentation/mongo_v2_index_test.rb +0 -124
  54. data/test/instrumentation/mongo_v2_test.rb +0 -584
  55. data/test/instrumentation/mongo_v2_view_test.rb +0 -435
  56. data/test/instrumentation/moped_test.rb +0 -517
  57. data/test/instrumentation/rack_test.rb +0 -165
  58. data/test/instrumentation/redis_hashes_test.rb +0 -268
  59. data/test/instrumentation/redis_keys_test.rb +0 -321
  60. data/test/instrumentation/redis_lists_test.rb +0 -310
  61. data/test/instrumentation/redis_misc_test.rb +0 -163
  62. data/test/instrumentation/redis_sets_test.rb +0 -296
  63. data/test/instrumentation/redis_sortedsets_test.rb +0 -328
  64. data/test/instrumentation/redis_strings_test.rb +0 -349
  65. data/test/instrumentation/resque_test.rb +0 -185
  66. data/test/instrumentation/rest-client_test.rb +0 -288
  67. data/test/instrumentation/sequel_mysql2_test.rb +0 -353
  68. data/test/instrumentation/sequel_mysql_test.rb +0 -334
  69. data/test/instrumentation/sequel_pg_test.rb +0 -336
  70. data/test/instrumentation/sidekiq-client_test.rb +0 -159
  71. data/test/instrumentation/sidekiq-worker_test.rb +0 -180
  72. data/test/instrumentation/twitter-cassandra_test.rb +0 -424
  73. data/test/instrumentation/typhoeus_test.rb +0 -284
  74. data/test/jobs/delayed_job/db_worker_job.rb +0 -29
  75. data/test/jobs/delayed_job/error_worker_job.rb +0 -10
  76. data/test/jobs/delayed_job/remote_call_worker_job.rb +0 -20
  77. data/test/jobs/resque/db_worker_job.rb +0 -29
  78. data/test/jobs/resque/error_worker_job.rb +0 -10
  79. data/test/jobs/resque/remote_call_worker_job.rb +0 -20
  80. data/test/jobs/sidekiq/db_worker_job.rb +0 -29
  81. data/test/jobs/sidekiq/error_worker_job.rb +0 -10
  82. data/test/jobs/sidekiq/remote_call_worker_job.rb +0 -20
  83. data/test/minitest_helper.rb +0 -277
  84. data/test/mocked/curb_mocked_test.rb +0 -324
  85. data/test/mocked/excon_mocked_test.rb +0 -174
  86. data/test/mocked/faraday_mocked_test.rb +0 -97
  87. data/test/mocked/http_mocked_test.rb +0 -135
  88. data/test/mocked/httpclient_mocked_test.rb +0 -258
  89. data/test/mocked/rest_client_mocked_test.rb +0 -109
  90. data/test/mocked/typhoeus_mocked_test.rb +0 -207
  91. data/test/models/widget.rb +0 -36
  92. data/test/noop/noop_test.rb +0 -145
  93. data/test/profiling/legacy_method_profiling_test.rb +0 -201
  94. data/test/profiling/method_profiling_test.rb +0 -631
  95. data/test/queues/delayed_job-client_test.rb +0 -95
  96. data/test/queues/delayed_job-worker_test.rb +0 -91
  97. data/test/reporter/reporter_test.rb +0 -14
  98. data/test/servers/delayed_job.rb +0 -107
  99. data/test/servers/rackapp_8101.rb +0 -29
  100. data/test/servers/rails3x_8140.rb +0 -96
  101. data/test/servers/rails4x_8140.rb +0 -96
  102. data/test/servers/rails5x_8140.rb +0 -95
  103. data/test/servers/rails5x_api_8150.rb +0 -78
  104. data/test/servers/sidekiq.rb +0 -29
  105. data/test/servers/sidekiq.yml +0 -7
  106. data/test/servers/sidekiq_initializer.rb +0 -25
  107. data/test/settings +0 -0
  108. data/test/support/auto_tracing_test.rb +0 -50
  109. data/test/support/backcompat_test.rb +0 -276
  110. data/test/support/config_test.rb +0 -149
  111. data/test/support/dnt_test.rb +0 -98
  112. data/test/support/init_report_test.rb +0 -25
  113. data/test/support/liboboe_settings_test.rb +0 -110
  114. data/test/support/logging_test.rb +0 -130
  115. data/test/support/sql_sanitize_test.rb +0 -55
  116. data/test/support/tracing_mode_test.rb +0 -33
  117. data/test/support/tvalias_test.rb +0 -15
  118. data/test/support/xtrace_test.rb +0 -41
@@ -1,172 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
- require "minitest_helper"
5
- require 'mocha/mini_test'
6
-
7
-
8
- describe "RailsSharedTests" do
9
- before do
10
- clear_all_traces
11
- AppOpticsAPM.config_lock.synchronize {
12
- @tm = AppOpticsAPM::Config[:tracing_mode]
13
- @sample_rate = AppOpticsAPM::Config[:sample_rate]
14
- }
15
- end
16
-
17
- after do
18
- AppOpticsAPM.config_lock.synchronize {
19
- AppOpticsAPM::Config[:tracing_mode] = @tm
20
- AppOpticsAPM::Config[:sample_rate] = @sample_rate
21
- }
22
- end
23
-
24
- it "should NOT trace when tracing is set to :never" do
25
- AppOpticsAPM.config_lock.synchronize do
26
- AppOpticsAPM::Config[:tracing_mode] = :never
27
- uri = URI.parse('http://127.0.0.1:8140/hello/world')
28
- r = Net::HTTP.get_response(uri)
29
-
30
- traces = get_all_traces
31
- traces.count.must_equal 0
32
- end
33
- end
34
-
35
- it "should NOT trace when sample_rate is 0" do
36
- AppOpticsAPM.config_lock.synchronize do
37
- AppOpticsAPM::Config[:sample_rate] = 0
38
- uri = URI.parse('http://127.0.0.1:8140/hello/world')
39
- r = Net::HTTP.get_response(uri)
40
-
41
- traces = get_all_traces
42
- traces.count.must_equal 0
43
- end
44
- end
45
-
46
- it "should NOT trace when there is no context" do
47
- response_headers = HelloController.action("world").call(
48
- "REQUEST_METHOD" => "GET",
49
- "rack.input" => -> {}
50
- )[1]
51
-
52
- response_headers.key?('X-Trace').must_equal false
53
-
54
- traces = get_all_traces
55
- traces.count.must_equal 0
56
- end
57
-
58
- it "should send inbound metrics" do
59
- test_action, test_url, test_status, test_method, test_error = nil, nil, nil, nil, nil
60
-
61
- AppOpticsAPM::Span.expects(:createHttpSpan).with do |action, url, _duration, status, method, error|
62
- test_action = action
63
- test_url = url
64
- test_status = status
65
- test_method = method
66
- test_error = error
67
- end.once
68
-
69
- uri = URI.parse('http://127.0.0.1:8140/hello/world')
70
- Net::HTTP.get_response(uri)
71
-
72
- assert_equal "HelloController.world", test_action
73
- assert_equal "http://127.0.0.1:8140/hello/world", test_url
74
- assert_equal 200, test_status
75
- assert_equal "GET", test_method
76
- assert_equal 0, test_error
77
-
78
- assert_controller_action(test_action)
79
- end
80
-
81
- it "should send inbound metrics when not tracing" do
82
- test_action, test_url, test_status, test_method, test_error = nil, nil, nil, nil, nil
83
- AppOpticsAPM.config_lock.synchronize do
84
- AppOpticsAPM::Config[:tracing_mode] = :never
85
- AppOpticsAPM::Span.expects(:createHttpSpan).with do |action, url, _duration, status, method, error|
86
- test_action = action
87
- test_url = url
88
- test_status = status
89
- test_method = method
90
- test_error = error
91
- end.once
92
-
93
- uri = URI.parse('http://127.0.0.1:8140/hello/world')
94
- Net::HTTP.get_response(uri)
95
- end
96
-
97
- assert_equal "HelloController.world", test_action
98
- assert_equal "http://127.0.0.1:8140/hello/world", test_url
99
- assert_equal 200, test_status
100
- assert_equal "GET", test_method
101
- assert_equal 0, test_error
102
- end
103
-
104
- it "should send metrics for 500 errors" do
105
- test_action, test_url, test_status, test_method, test_error = nil, nil, nil, nil, nil
106
-
107
- AppOpticsAPM::Span.expects(:createHttpSpan).with do |action, url, _duration, status, method, error|
108
- test_action = action
109
- test_url = url
110
- test_status = status
111
- test_method = method
112
- test_error = error
113
- end.once
114
-
115
- uri = URI.parse('http://127.0.0.1:8140/hello/servererror')
116
- Net::HTTP.get_response(uri)
117
-
118
- assert_equal "HelloController.servererror", test_action
119
- assert_equal "http://127.0.0.1:8140/hello/servererror", test_url
120
- assert_equal 500, test_status
121
- assert_equal "GET", test_method
122
- assert_equal 1, test_error
123
-
124
- assert_controller_action(test_action)
125
- end
126
-
127
- it "should find the controller action for a route with a parameter" do
128
- test_action, test_url, test_status, test_method, test_error = nil, nil, nil, nil, nil
129
-
130
- AppOpticsAPM::Span.expects(:createHttpSpan).with do |action, url, _duration, status, method, error|
131
- test_action = action
132
- test_url = url
133
- test_status = status
134
- test_method = method
135
- test_error = error
136
- end.once
137
-
138
- uri = URI.parse('http://127.0.0.1:8140/hello/15/show')
139
- Net::HTTP.get_response(uri)
140
-
141
- assert_equal "HelloController.show", test_action
142
- assert_equal "http://127.0.0.1:8140/hello/15/show", test_url
143
- assert_equal 200, test_status
144
- assert_equal "GET", test_method
145
- assert_equal 0, test_error
146
-
147
- assert_controller_action(test_action)
148
- end
149
-
150
- it "should find controller action in the metal stack" do
151
- test_action, test_url, test_status, test_method, test_error = nil, nil, nil, nil, nil
152
-
153
- AppOpticsAPM::Span.expects(:createHttpSpan).with do |action, url, _duration, status, method, error|
154
- test_action = action
155
- test_url = url
156
- test_status = status
157
- test_method = method
158
- test_error = error
159
- end.once
160
-
161
- uri = URI.parse('http://127.0.0.1:8140/hello/metal')
162
- r = Net::HTTP.get_response(uri)
163
-
164
- assert_equal 200, test_status
165
- assert_equal "FerroController.world", test_action
166
- assert_equal "http://127.0.0.1:8140/hello/metal", test_url
167
- assert_equal "GET", test_method
168
- assert_equal 0, test_error
169
-
170
- assert_controller_action(test_action)
171
- end
172
- end
@@ -1,140 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
-
5
- require "minitest_helper"
6
- require "mocha/mini_test"
7
- require File.expand_path(File.dirname(__FILE__) + '/apps/sinatra_simple')
8
-
9
- describe Sinatra do
10
- before do
11
- clear_all_traces
12
- end
13
-
14
- it "should trace a request to a simple sinatra stack" do
15
- @app = SinatraSimple
16
-
17
- r = get "/render"
18
-
19
- traces = get_all_traces
20
-
21
- traces.count.must_equal 9
22
- valid_edges?(traces).must_equal true
23
- validate_outer_layers(traces, 'rack')
24
-
25
- traces[2]['Layer'].must_equal "sinatra"
26
- traces[4]['Label'].must_equal "profile_entry"
27
- traces[7]['Controller'].must_equal "SinatraSimple"
28
- traces[8]['Label'].must_equal "exit"
29
-
30
- # Validate the existence of the response header
31
- r.headers.key?('X-Trace').must_equal true
32
- r.headers['X-Trace'].must_equal traces[8]['X-Trace']
33
- end
34
-
35
- it "should not have RUM code in the response" do
36
- @app = SinatraSimple
37
-
38
- r = get "/render"
39
-
40
- (r.body =~ /tly.js/).must_be_nil
41
- end
42
-
43
- it "should report the route with :id" do
44
- @app = SinatraSimple
45
- test_action, test_url, test_status, test_method, test_error = nil, nil, nil, nil, nil
46
- AppOpticsAPM::Span.expects(:createHttpSpan).with do |action, url, _duration, status, method, error|
47
- test_action = action
48
- test_url = url
49
- test_status = status
50
- test_method = method
51
- test_error = error
52
- end.once
53
-
54
- r = get "/render/123304952309747203947"
55
-
56
- r.body.must_match /123304952309747203947/
57
-
58
- assert_equal "SinatraSimple.GET /render/:id", test_action
59
- assert_equal "http://example.org/render/123304952309747203947", test_url
60
- assert_equal 200, test_status
61
- assert_equal "GET", test_method
62
- assert_equal 0, test_error
63
-
64
- assert_controller_action(test_action)
65
- end
66
-
67
- it "should report the route with :id and more" do
68
- @app = SinatraSimple
69
- test_action, test_url, test_status, test_method, test_error = nil, nil, nil, nil, nil
70
- AppOpticsAPM::Span.expects(:createHttpSpan).with do |action, url, _duration, status, method, error|
71
- test_action = action
72
- test_url = url
73
- test_status = status
74
- test_method = method
75
- test_error = error
76
- end.once
77
-
78
- r = get "/render/123304952309747203947/what"
79
-
80
- r.body.must_match /WOOT.*123304952309747203947/
81
-
82
- assert_equal "SinatraSimple.GET /render/:id/what", test_action
83
- assert_equal "http://example.org/render/123304952309747203947/what", test_url
84
- assert_equal 200, test_status
85
- assert_equal "GET", test_method
86
- assert_equal 0, test_error
87
-
88
- assert_controller_action(test_action)
89
- end
90
-
91
- it "should report the route with splats" do
92
- @app = SinatraSimple
93
- test_action, test_url, test_status, test_method, test_error = nil, nil, nil, nil, nil
94
- AppOpticsAPM::Span.expects(:createHttpSpan).with do |action, url, _duration, status, method, error|
95
- test_action = action
96
- test_url = url
97
- test_status = status
98
- test_method = method
99
- test_error = error
100
- end.once
101
-
102
- r = get "/say/hello/to/world"
103
-
104
- r.body.must_match /hello world/
105
-
106
- assert_equal "SinatraSimple.GET /say/*/to/*", test_action
107
- assert_equal "http://example.org/say/hello/to/world", test_url
108
- assert_equal 200, test_status
109
- assert_equal "GET", test_method
110
- assert_equal 0, test_error
111
-
112
- assert_controller_action(test_action)
113
- end
114
-
115
- if RUBY_VERSION > '2.2'
116
- it "should report the route with regex" do
117
- @app = SinatraSimple
118
- test_action, test_url, test_status, test_method, test_error = nil, nil, nil, nil, nil
119
- AppOpticsAPM::Span.expects(:createHttpSpan).with do |action, url, _duration, status, method, error|
120
- test_action = action
121
- test_url = url
122
- test_status = status
123
- test_method = method
124
- test_error = error
125
- end.once
126
-
127
- r = get "/hello/friend"
128
-
129
- r.body.must_match /Hello, friend/
130
-
131
- test_action.must_match "SinatraSimple.GET \\/hello\\/([\\w]+)", test_action
132
- assert_equal "http://example.org/hello/friend", test_url
133
- assert_equal 200, test_status
134
- assert_equal "GET", test_method
135
- assert_equal 0, test_error
136
-
137
- assert_controller_action(test_action)
138
- end
139
- end
140
- end
@@ -1,276 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
- require 'minitest_helper'
5
-
6
- unless defined?(JRUBY_VERSION)
7
- class BunnyClientTest < Minitest::Test
8
- def setup
9
- # Support specific environment variables to support remote rabbitmq servers
10
- ENV['APPOPTICS_RABBITMQ_SERVER'] = "127.0.0.1" unless ENV['APPOPTICS_RABBITMQ_SERVER']
11
- ENV['APPOPTICS_RABBITMQ_PORT'] = "5672" unless ENV['APPOPTICS_RABBITMQ_PORT']
12
- ENV['APPOPTICS_RABBITMQ_USERNAME'] = "guest" unless ENV['APPOPTICS_RABBITMQ_USERNAME']
13
- ENV['APPOPTICS_RABBITMQ_PASSWORD'] = "guest" unless ENV['APPOPTICS_RABBITMQ_PASSWORD']
14
- ENV['APPOPTICS_RABBITMQ_VHOST'] = "/" unless ENV['APPOPTICS_RABBITMQ_VHOST']
15
-
16
- @connection_params = {}
17
- @connection_params[:host] = ENV['APPOPTICS_RABBITMQ_SERVER']
18
- @connection_params[:port] = ENV['APPOPTICS_RABBITMQ_PORT']
19
- @connection_params[:vhost] = ENV['APPOPTICS_RABBITMQ_VHOST']
20
- @connection_params[:user] = ENV['APPOPTICS_RABBITMQ_USERNAME']
21
- @connection_params[:pass] = ENV['APPOPTICS_RABBITMQ_PASSWORD']
22
-
23
- clear_all_traces
24
- end
25
-
26
- def test_publish_default_exchange
27
- @conn = Bunny.new(@connection_params)
28
- @conn.start
29
- @ch = @conn.create_channel
30
- @queue = @ch.queue("tv.ruby.test")
31
- @exchange = @ch.default_exchange
32
-
33
- AppOpticsAPM::API.start_trace('bunny_tests') do
34
- @exchange.publish("The Tortoise and the Hare", :routing_key => @queue.name)
35
- end
36
-
37
- traces = get_all_traces
38
- traces.count.must_equal 4
39
-
40
- validate_outer_layers(traces, "bunny_tests")
41
- assert valid_edges?(traces), "Invalid edge in traces"
42
-
43
- traces[1]['Layer'].must_equal "rabbitmq-client"
44
- traces[1]['Label'].must_equal "entry"
45
- traces[2]['Layer'].must_equal "rabbitmq-client"
46
- traces[2]['Label'].must_equal "exit"
47
- traces[2]['Spec'].must_equal "pushq"
48
- traces[2]['Flavor'].must_equal "rabbitmq"
49
- traces[2]['ExchangeName'].must_equal "default"
50
- traces[2]['RoutingKey'].must_equal "tv.ruby.test"
51
- traces[2]['Op'].must_equal "publish"
52
- traces[2]['RemoteHost'].must_equal ENV['APPOPTICS_RABBITMQ_SERVER']
53
- traces[2]['RemotePort'].must_equal ENV['APPOPTICS_RABBITMQ_PORT'].to_i
54
- traces[2]['VirtualHost'].must_equal ENV['APPOPTICS_RABBITMQ_VHOST']
55
-
56
- @conn.close
57
- end
58
-
59
- def test_publish_fanout_exchange
60
- @conn = Bunny.new(@connection_params)
61
- @conn.start
62
- @ch = @conn.create_channel
63
- @exchange = @ch.fanout("tv.ruby.fanout.tests")
64
-
65
- AppOpticsAPM::API.start_trace('bunny_tests') do
66
- @exchange.publish("The Tortoise and the Hare in the fanout exchange.", :routing_key => 'tv.ruby.test').publish("And another...")
67
- end
68
-
69
- traces = get_all_traces
70
- traces.count.must_equal 6
71
-
72
- validate_outer_layers(traces, "bunny_tests")
73
- assert valid_edges?(traces), "Invalid edge in traces"
74
-
75
- traces[1]['Layer'].must_equal "rabbitmq-client"
76
- traces[1]['Label'].must_equal "entry"
77
- traces[2]['Layer'].must_equal "rabbitmq-client"
78
- traces[2]['Label'].must_equal "exit"
79
- traces[2]['Spec'].must_equal "pushq"
80
- traces[2]['Flavor'].must_equal "rabbitmq"
81
- traces[2]['ExchangeName'].must_equal "tv.ruby.fanout.tests"
82
- traces[2]['RoutingKey'].must_equal "tv.ruby.test"
83
- traces[2]['Op'].must_equal "publish"
84
- traces[2]['RemoteHost'].must_equal ENV['APPOPTICS_RABBITMQ_SERVER']
85
- traces[2]['RemotePort'].must_equal ENV['APPOPTICS_RABBITMQ_PORT'].to_i
86
- traces[2]['VirtualHost'].must_equal ENV['APPOPTICS_RABBITMQ_VHOST']
87
-
88
- traces[3]['Layer'].must_equal "rabbitmq-client"
89
- traces[3]['Label'].must_equal "entry"
90
- traces[4]['Layer'].must_equal "rabbitmq-client"
91
- traces[4]['Label'].must_equal "exit"
92
- traces[4]['Spec'].must_equal "pushq"
93
- traces[4]['Flavor'].must_equal "rabbitmq"
94
- traces[4]['ExchangeName'].must_equal "tv.ruby.fanout.tests"
95
- traces[4].key?('RoutingKey').must_equal false
96
- traces[4]['Op'].must_equal "publish"
97
- traces[4]['RemoteHost'].must_equal ENV['APPOPTICS_RABBITMQ_SERVER']
98
- traces[4]['RemotePort'].must_equal ENV['APPOPTICS_RABBITMQ_PORT'].to_i
99
- traces[4]['VirtualHost'].must_equal ENV['APPOPTICS_RABBITMQ_VHOST']
100
-
101
- @conn.close
102
- end
103
-
104
- def test_publish_topic_exchange
105
- @conn = Bunny.new(@connection_params)
106
- @conn.start
107
- @ch = @conn.create_channel
108
- @exchange = @ch.topic("tv.ruby.topic.tests", :auto_delete => true)
109
-
110
- AppOpticsAPM::API.start_trace('bunny_tests') do
111
- @exchange.publish("The Tortoise and the Hare in the topic exchange.", :routing_key => 'tv.ruby.test.1').publish("And another...", :routing_key => 'tv.ruby.test.2' )
112
- end
113
-
114
- traces = get_all_traces
115
- traces.count.must_equal 6
116
-
117
- validate_outer_layers(traces, "bunny_tests")
118
- assert valid_edges?(traces), "Invalid edge in traces"
119
-
120
- traces[1]['Layer'].must_equal "rabbitmq-client"
121
- traces[1]['Label'].must_equal "entry"
122
- traces[2]['Layer'].must_equal "rabbitmq-client"
123
- traces[2]['Label'].must_equal "exit"
124
- traces[2]['Spec'].must_equal "pushq"
125
- traces[2]['Flavor'].must_equal "rabbitmq"
126
- traces[2]['ExchangeName'].must_equal "tv.ruby.topic.tests"
127
- traces[2]['RoutingKey'].must_equal "tv.ruby.test.1"
128
- traces[2]['Op'].must_equal "publish"
129
- traces[2]['RemoteHost'].must_equal ENV['APPOPTICS_RABBITMQ_SERVER']
130
- traces[2]['RemotePort'].must_equal ENV['APPOPTICS_RABBITMQ_PORT'].to_i
131
- traces[2]['VirtualHost'].must_equal ENV['APPOPTICS_RABBITMQ_VHOST']
132
-
133
- traces[3]['Layer'].must_equal "rabbitmq-client"
134
- traces[3]['Label'].must_equal "entry"
135
- traces[4]['Layer'].must_equal "rabbitmq-client"
136
- traces[4]['Label'].must_equal "exit"
137
- traces[4]['Spec'].must_equal "pushq"
138
- traces[4]['Flavor'].must_equal "rabbitmq"
139
- traces[4]['ExchangeName'].must_equal "tv.ruby.topic.tests"
140
- traces[4]['RoutingKey'].must_equal "tv.ruby.test.2"
141
- traces[4]['Op'].must_equal "publish"
142
- traces[4]['RemoteHost'].must_equal ENV['APPOPTICS_RABBITMQ_SERVER']
143
- traces[4]['RemotePort'].must_equal ENV['APPOPTICS_RABBITMQ_PORT'].to_i
144
- traces[4]['VirtualHost'].must_equal ENV['APPOPTICS_RABBITMQ_VHOST']
145
-
146
- @conn.close
147
- end
148
-
149
- def test_publish_error_handling
150
- @conn = Bunny.new(@connection_params)
151
- @conn.start
152
- @ch = @conn.create_channel
153
-
154
- begin
155
- AppOpticsAPM::API.start_trace('bunny_tests') do
156
- @exchange = @ch.topic("tv.ruby.error.1", :auto_delete => true)
157
- @exchange = @ch.fanout("tv.ruby.error.1", :auto_delete => true)
158
- @exchange.publish("The Tortoise and the Hare in the topic exchange.", :routing_key => 'tv.ruby.test.1').publish("And another...", :routing_key => 'tv.ruby.test.2' )
159
- end
160
- rescue
161
- # Capture intentional redeclaration error
162
- end
163
-
164
- traces = get_all_traces
165
- assert_equal 3, traces.count
166
-
167
- validate_outer_layers(traces, "bunny_tests")
168
- assert valid_edges?(traces), "Invalid edge in traces"
169
-
170
- traces[1]['Label'].must_equal "error"
171
- traces[1]['ErrorClass'].must_equal "Bunny::PreconditionFailed"
172
- traces[1]['ErrorMsg'].must_match(/PRECONDITION_FAILED/)
173
- traces[1].key?('Backtrace').must_equal true
174
-
175
- @conn.close
176
- end
177
-
178
- def test_delete_exchange
179
- @conn = Bunny.new(@connection_params)
180
- @conn.start
181
- @ch = @conn.create_channel
182
- @exchange = @ch.fanout("tv.delete_exchange.test")
183
- @queue = @ch.queue("", :exclusive => true).bind(@exchange)
184
-
185
- @ch.confirm_select
186
- @exchange.publish("", :routing_key => 'tv.ruby.test')
187
-
188
- AppOpticsAPM::API.start_trace('bunny_tests') do
189
- @exchange.delete
190
- end
191
-
192
- traces = get_all_traces
193
- traces.count.must_equal 4
194
-
195
- validate_outer_layers(traces, "bunny_tests")
196
-
197
- traces[2]['Spec'].must_equal "pushq"
198
- traces[2]['Flavor'].must_equal "rabbitmq"
199
- traces[2]['ExchangeName'].must_equal "tv.delete_exchange.test"
200
- traces[2]['ExchangeType'].must_equal "fanout"
201
- traces[2]['Op'].must_equal "delete"
202
- traces[2]['RemoteHost'].must_equal ENV['APPOPTICS_RABBITMQ_SERVER']
203
- traces[2]['RemotePort'].must_equal ENV['APPOPTICS_RABBITMQ_PORT'].to_i
204
- traces[2]['VirtualHost'].must_equal ENV['APPOPTICS_RABBITMQ_VHOST']
205
- end
206
-
207
- def test_wait_for_confirms
208
- @conn = Bunny.new(@connection_params)
209
- @conn.start
210
- @ch = @conn.create_channel
211
- @exchange = @ch.fanout("tv.ruby.wait_for_confirm.tests")
212
- @queue = @ch.queue("", :exclusive => true).bind(@exchange)
213
-
214
- @ch.confirm_select
215
-
216
- AppOpticsAPM::API.start_trace('bunny_tests') do
217
- 1000.times do
218
- @exchange.publish("", :routing_key => 'tv.ruby.test')
219
- end
220
-
221
- @ch.wait_for_confirms
222
- end
223
-
224
- traces = get_all_traces
225
- assert_equal 2004,traces.count
226
-
227
- validate_outer_layers(traces, "bunny_tests")
228
-
229
- traces[2000]['Spec'].must_equal "pushq"
230
- traces[2000]['Flavor'].must_equal "rabbitmq"
231
- traces[2000]['ExchangeName'].must_equal "tv.ruby.wait_for_confirm.tests"
232
- traces[2000]['RoutingKey'].must_equal "tv.ruby.test"
233
- traces[2000]['Op'].must_equal "publish"
234
- traces[2000]['RemoteHost'].must_equal ENV['APPOPTICS_RABBITMQ_SERVER']
235
- traces[2000]['RemotePort'].must_equal ENV['APPOPTICS_RABBITMQ_PORT'].to_i
236
- traces[2000]['VirtualHost'].must_equal ENV['APPOPTICS_RABBITMQ_VHOST']
237
-
238
- traces[2001]['Layer'].must_equal "rabbitmq-client"
239
- traces[2001]['Label'].must_equal "entry"
240
- traces[2002]['Layer'].must_equal "rabbitmq-client"
241
- traces[2002]['Label'].must_equal "exit"
242
- traces[2002]['Spec'].must_equal "pushq"
243
- traces[2002]['Flavor'].must_equal "rabbitmq"
244
- traces[2002]['Op'].must_equal "wait_for_confirms"
245
- traces[2002]['RemoteHost'].must_equal ENV['APPOPTICS_RABBITMQ_SERVER']
246
- traces[2002]['RemotePort'].must_equal ENV['APPOPTICS_RABBITMQ_PORT'].to_i
247
- traces[2002]['VirtualHost'].must_equal ENV['APPOPTICS_RABBITMQ_VHOST']
248
-
249
- @conn.close
250
- end
251
-
252
- def test_channel_queue
253
- @conn = Bunny.new(@connection_params)
254
- @conn.start
255
- @ch = @conn.create_channel
256
- @exchange = @ch.fanout("tv.queue.test")
257
-
258
- AppOpticsAPM::API.start_trace('bunny_tests') do
259
- @queue = @ch.queue("blah", :exclusive => true).bind(@exchange)
260
- end
261
-
262
- traces = get_all_traces
263
- traces.count.must_equal 4
264
-
265
- validate_outer_layers(traces, "bunny_tests")
266
-
267
- traces[2]['Spec'].must_equal "pushq"
268
- traces[2]['Flavor'].must_equal "rabbitmq"
269
- traces[2]['Op'].must_equal "queue"
270
- traces[2]['Queue'].must_equal "blah"
271
- traces[2]['RemoteHost'].must_equal ENV['APPOPTICS_RABBITMQ_SERVER']
272
- traces[2]['RemotePort'].must_equal ENV['APPOPTICS_RABBITMQ_PORT'].to_i
273
- traces[2]['VirtualHost'].must_equal ENV['APPOPTICS_RABBITMQ_VHOST']
274
- end
275
- end
276
- end