appsignal 4.0.6-java → 4.0.7-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/Rakefile +9 -9
  4. data/appsignal.gemspec +22 -1
  5. data/ext/agent.rb +27 -27
  6. data/lib/appsignal/check_in.rb +1 -1
  7. data/lib/appsignal/config.rb +1 -3
  8. data/lib/appsignal/integrations/resque.rb +1 -6
  9. data/lib/appsignal/utils/hash_sanitizer.rb +4 -0
  10. data/lib/appsignal/version.rb +1 -1
  11. metadata +2 -192
  12. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
  13. data/.github/ISSUE_TEMPLATE/chore.md +0 -14
  14. data/.github/workflows/ci.yml +0 -3285
  15. data/.github/workflows/create_release_from_tag.yml +0 -62
  16. data/.gitignore +0 -35
  17. data/.gitmodules +0 -3
  18. data/.rspec +0 -4
  19. data/.yardopts +0 -8
  20. data/benchmark.rake +0 -139
  21. data/gemfiles/capistrano2.gemfile +0 -6
  22. data/gemfiles/capistrano3.gemfile +0 -7
  23. data/gemfiles/dry-monitor.gemfile +0 -5
  24. data/gemfiles/grape.gemfile +0 -5
  25. data/gemfiles/hanami-2.0.gemfile +0 -7
  26. data/gemfiles/hanami-2.1.gemfile +0 -7
  27. data/gemfiles/http5.gemfile +0 -5
  28. data/gemfiles/no_dependencies.gemfile +0 -10
  29. data/gemfiles/padrino.gemfile +0 -7
  30. data/gemfiles/psych-3.gemfile +0 -5
  31. data/gemfiles/psych-4.gemfile +0 -5
  32. data/gemfiles/que-1.gemfile +0 -5
  33. data/gemfiles/que-2.gemfile +0 -5
  34. data/gemfiles/rails-6.0.gemfile +0 -10
  35. data/gemfiles/rails-6.1.gemfile +0 -11
  36. data/gemfiles/rails-7.0.gemfile +0 -11
  37. data/gemfiles/rails-7.1.gemfile +0 -11
  38. data/gemfiles/rails-7.2.gemfile +0 -11
  39. data/gemfiles/redis-4.gemfile +0 -5
  40. data/gemfiles/redis-5.gemfile +0 -6
  41. data/gemfiles/resque-2.gemfile +0 -6
  42. data/gemfiles/sequel.gemfile +0 -10
  43. data/gemfiles/sinatra.gemfile +0 -5
  44. data/gemfiles/webmachine1.gemfile +0 -7
  45. data/gemfiles/webmachine2.gemfile +0 -6
  46. data/mono.yml +0 -16
  47. data/spec/.rubocop.yml +0 -7
  48. data/spec/lib/appsignal/auth_check_spec.rb +0 -84
  49. data/spec/lib/appsignal/capistrano2_spec.rb +0 -227
  50. data/spec/lib/appsignal/capistrano3_spec.rb +0 -284
  51. data/spec/lib/appsignal/check_in/cron_spec.rb +0 -210
  52. data/spec/lib/appsignal/check_in/scheduler_spec.rb +0 -557
  53. data/spec/lib/appsignal/cli/demo_spec.rb +0 -46
  54. data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +0 -16
  55. data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +0 -86
  56. data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1553
  57. data/spec/lib/appsignal/cli/helpers_spec.rb +0 -179
  58. data/spec/lib/appsignal/cli/install_spec.rb +0 -848
  59. data/spec/lib/appsignal/cli_spec.rb +0 -56
  60. data/spec/lib/appsignal/config_spec.rb +0 -1380
  61. data/spec/lib/appsignal/demo_spec.rb +0 -83
  62. data/spec/lib/appsignal/environment_spec.rb +0 -190
  63. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +0 -60
  64. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -21
  65. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -21
  66. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -52
  67. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -21
  68. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -84
  69. data/spec/lib/appsignal/event_formatter/rom/sql_formatter_spec.rb +0 -22
  70. data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +0 -30
  71. data/spec/lib/appsignal/event_formatter/view_component/render_formatter_spec.rb +0 -41
  72. data/spec/lib/appsignal/event_formatter_spec.rb +0 -193
  73. data/spec/lib/appsignal/extension/jruby_spec.rb +0 -46
  74. data/spec/lib/appsignal/extension_install_failure_spec.rb +0 -20
  75. data/spec/lib/appsignal/extension_spec.rb +0 -178
  76. data/spec/lib/appsignal/garbage_collection_spec.rb +0 -98
  77. data/spec/lib/appsignal/hooks/action_cable_spec.rb +0 -345
  78. data/spec/lib/appsignal/hooks/action_mailer_spec.rb +0 -55
  79. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +0 -23
  80. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +0 -99
  81. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +0 -47
  82. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +0 -47
  83. data/spec/lib/appsignal/hooks/activejob_spec.rb +0 -650
  84. data/spec/lib/appsignal/hooks/at_exit_spec.rb +0 -105
  85. data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -40
  86. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -40
  87. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -38
  88. data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +0 -83
  89. data/spec/lib/appsignal/hooks/excon_spec.rb +0 -67
  90. data/spec/lib/appsignal/hooks/gvl_spec.rb +0 -145
  91. data/spec/lib/appsignal/hooks/http_spec.rb +0 -37
  92. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -46
  93. data/spec/lib/appsignal/hooks/mri_spec.rb +0 -23
  94. data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -18
  95. data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -30
  96. data/spec/lib/appsignal/hooks/puma_spec.rb +0 -80
  97. data/spec/lib/appsignal/hooks/que_spec.rb +0 -19
  98. data/spec/lib/appsignal/hooks/rake_spec.rb +0 -144
  99. data/spec/lib/appsignal/hooks/redis_client_spec.rb +0 -218
  100. data/spec/lib/appsignal/hooks/redis_spec.rb +0 -124
  101. data/spec/lib/appsignal/hooks/resque_spec.rb +0 -27
  102. data/spec/lib/appsignal/hooks/sequel_spec.rb +0 -44
  103. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -29
  104. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +0 -115
  105. data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -63
  106. data/spec/lib/appsignal/hooks/webmachine_spec.rb +0 -24
  107. data/spec/lib/appsignal/hooks_spec.rb +0 -124
  108. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -74
  109. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +0 -454
  110. data/spec/lib/appsignal/integrations/http_spec.rb +0 -111
  111. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +0 -154
  112. data/spec/lib/appsignal/integrations/net_http_spec.rb +0 -33
  113. data/spec/lib/appsignal/integrations/object_spec.rb +0 -347
  114. data/spec/lib/appsignal/integrations/puma_spec.rb +0 -150
  115. data/spec/lib/appsignal/integrations/que_spec.rb +0 -187
  116. data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -457
  117. data/spec/lib/appsignal/integrations/resque_spec.rb +0 -155
  118. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +0 -165
  119. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +0 -640
  120. data/spec/lib/appsignal/integrations/webmachine_spec.rb +0 -136
  121. data/spec/lib/appsignal/loaders/grape_spec.rb +0 -12
  122. data/spec/lib/appsignal/loaders/hanami_spec.rb +0 -92
  123. data/spec/lib/appsignal/loaders/padrino_spec.rb +0 -273
  124. data/spec/lib/appsignal/loaders/sinatra_spec.rb +0 -44
  125. data/spec/lib/appsignal/loaders_spec.rb +0 -144
  126. data/spec/lib/appsignal/logger_spec.rb +0 -205
  127. data/spec/lib/appsignal/marker_spec.rb +0 -51
  128. data/spec/lib/appsignal/probes/gvl_spec.rb +0 -164
  129. data/spec/lib/appsignal/probes/mri_spec.rb +0 -162
  130. data/spec/lib/appsignal/probes/sidekiq_spec.rb +0 -333
  131. data/spec/lib/appsignal/probes_spec.rb +0 -414
  132. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +0 -370
  133. data/spec/lib/appsignal/rack/body_wrapper_spec.rb +0 -319
  134. data/spec/lib/appsignal/rack/event_handler_spec.rb +0 -441
  135. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +0 -201
  136. data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +0 -36
  137. data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +0 -38
  138. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +0 -126
  139. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +0 -217
  140. data/spec/lib/appsignal/rack_spec.rb +0 -243
  141. data/spec/lib/appsignal/sample_data_spec.rb +0 -238
  142. data/spec/lib/appsignal/span_spec.rb +0 -141
  143. data/spec/lib/appsignal/system_spec.rb +0 -126
  144. data/spec/lib/appsignal/transaction_spec.rb +0 -2115
  145. data/spec/lib/appsignal/transmitter_spec.rb +0 -198
  146. data/spec/lib/appsignal/utils/data_spec.rb +0 -166
  147. data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +0 -182
  148. data/spec/lib/appsignal/utils/integration_logger_spec.rb +0 -21
  149. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -153
  150. data/spec/lib/appsignal/utils/json_spec.rb +0 -44
  151. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -192
  152. data/spec/lib/appsignal_spec.rb +0 -1919
  153. data/spec/lib/puma/appsignal_spec.rb +0 -334
  154. data/spec/spec_helper.rb +0 -179
  155. data/spec/support/fixtures/generated_config.yml +0 -24
  156. data/spec/support/fixtures/projects/broken/config/appsignal.yml +0 -1
  157. data/spec/support/fixtures/projects/valid/config/appsignal.yml +0 -57
  158. data/spec/support/fixtures/projects/valid/log/.gitkeep +0 -0
  159. data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +0 -16
  160. data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +0 -56
  161. data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +0 -10
  162. data/spec/support/fixtures/projects/valid_with_rails_app/log/.gitkeep +0 -0
  163. data/spec/support/fixtures/uploaded_file.txt +0 -0
  164. data/spec/support/hanami/hanami_app.rb +0 -29
  165. data/spec/support/helpers/action_mailer_helpers.rb +0 -25
  166. data/spec/support/helpers/activejob_helpers.rb +0 -27
  167. data/spec/support/helpers/api_request_helper.rb +0 -60
  168. data/spec/support/helpers/cli_helpers.rb +0 -40
  169. data/spec/support/helpers/config_helpers.rb +0 -66
  170. data/spec/support/helpers/dependency_helper.rb +0 -155
  171. data/spec/support/helpers/directory_helper.rb +0 -27
  172. data/spec/support/helpers/env_helpers.rb +0 -41
  173. data/spec/support/helpers/environment_metdata_helper.rb +0 -16
  174. data/spec/support/helpers/example_exception.rb +0 -13
  175. data/spec/support/helpers/example_standard_error.rb +0 -13
  176. data/spec/support/helpers/loader_helper.rb +0 -21
  177. data/spec/support/helpers/log_helpers.rb +0 -36
  178. data/spec/support/helpers/rails_helper.rb +0 -28
  179. data/spec/support/helpers/std_streams_helper.rb +0 -94
  180. data/spec/support/helpers/system_helpers.rb +0 -8
  181. data/spec/support/helpers/take_at_most_helper.rb +0 -21
  182. data/spec/support/helpers/time_helpers.rb +0 -11
  183. data/spec/support/helpers/transaction_helpers.rb +0 -122
  184. data/spec/support/helpers/wait_for_helper.rb +0 -39
  185. data/spec/support/matchers/contains_log.rb +0 -26
  186. data/spec/support/matchers/have_colorized_text.rb +0 -28
  187. data/spec/support/matchers/transaction.rb +0 -200
  188. data/spec/support/mocks/appsignal_mock.rb +0 -18
  189. data/spec/support/mocks/dummy_app.rb +0 -20
  190. data/spec/support/mocks/fake_gc_profiler.rb +0 -19
  191. data/spec/support/mocks/fake_gvl_tools.rb +0 -28
  192. data/spec/support/mocks/hash_like.rb +0 -10
  193. data/spec/support/mocks/mock_probe.rb +0 -13
  194. data/spec/support/mocks/puma_mock.rb +0 -43
  195. data/spec/support/shared_examples/instrument.rb +0 -48
  196. data/spec/support/stubs/appsignal/loaders/loader_stub.rb +0 -7
  197. data/spec/support/stubs/delayed_job.rb +0 -0
  198. data/spec/support/stubs/sidekiq/api.rb +0 -4
  199. data/spec/support/testing.rb +0 -203
  200. data/support/bundler_wrapper +0 -12
  201. data/support/install_deps +0 -33
@@ -1,227 +0,0 @@
1
- if DependencyHelper.capistrano2_present?
2
- require "capistrano"
3
- require "capistrano/configuration"
4
- require "appsignal/capistrano"
5
-
6
- describe "Capistrano 2 integration" do
7
- let(:out_stream) { std_stream }
8
- let(:output) { out_stream.read }
9
- let(:config) { build_config }
10
- let(:capistrano_config) do
11
- Capistrano::Configuration.new.tap do |c|
12
- c.set(:rails_env, "production")
13
- c.set(:repository, "main")
14
- c.set(:deploy_to, "/home/username/app")
15
- c.set(:current_release, "")
16
- c.set(:current_revision, "503ce0923ed177a3ce000005")
17
- c.dry_run = false
18
- end
19
- end
20
- before { Appsignal::Integrations::Capistrano.tasks(capistrano_config) }
21
-
22
- def run
23
- capture_stdout(out_stream) do
24
- capistrano_config.find_and_execute_task("appsignal:deploy")
25
- end
26
- end
27
-
28
- it "has a deploy task" do
29
- expect(capistrano_config.find_task("appsignal:deploy")).to_not be_nil
30
- end
31
-
32
- describe "appsignal:deploy task" do
33
- before do
34
- ENV["USER"] = "batman"
35
- ENV["PWD"] = project_fixture_path
36
- end
37
-
38
- context "config" do
39
- before do
40
- capistrano_config.dry_run = true
41
- end
42
-
43
- context "when appsignal_config is available" do
44
- before do
45
- capistrano_config.set(
46
- :appsignal_config,
47
- :name => "AppName",
48
- :active => true,
49
- :push_api_key => "abc"
50
- )
51
- end
52
-
53
- it "overrides the default config with the custom appsignal_config" do
54
- original_new = Appsignal::Marker.method(:new)
55
-
56
- expect(Appsignal::Marker).to receive(:new) do |data, given_config|
57
- expect(given_config[:name]).to eq("AppName")
58
- original_new.call(data, given_config)
59
- end
60
-
61
- run
62
- end
63
-
64
- context "when rack_env is used instead of rails_env" do
65
- before do
66
- capistrano_config.unset(:rails_env)
67
- capistrano_config.set(:rack_env, "rack_production")
68
- end
69
-
70
- it "uses the rack_env as the env" do
71
- original_new = Appsignal::Marker.method(:new)
72
-
73
- expect(Appsignal::Marker).to receive(:new) do |data, given_config|
74
- expect(given_config.env).to eq("rack_production")
75
- original_new.call(data, given_config)
76
- end
77
-
78
- run
79
- end
80
- end
81
-
82
- context "when stage is used instead of rack_env / rails_env" do
83
- before do
84
- capistrano_config.unset(:rails_env)
85
- capistrano_config.set(:stage, "stage_production")
86
- end
87
-
88
- it "uses the stage as the env" do
89
- original_new = Appsignal::Marker.method(:new)
90
-
91
- expect(Appsignal::Marker).to receive(:new) do |data, given_config|
92
- expect(given_config.env).to eq("stage_production")
93
- original_new.call(data, given_config)
94
- end
95
-
96
- run
97
- end
98
- end
99
-
100
- context "when appsignal_env is set" do
101
- before do
102
- capistrano_config.set(:rack_env, "rack_production")
103
- capistrano_config.set(:stage, "stage_production")
104
- capistrano_config.set(:appsignal_env, "appsignal_production")
105
- end
106
-
107
- it "uses the appsignal_env as the env" do
108
- original_new = Appsignal::Marker.method(:new)
109
-
110
- expect(Appsignal::Marker).to receive(:new) do |data, given_config|
111
- expect(given_config.env).to eq("appsignal_production")
112
- original_new.call(data, given_config)
113
- end
114
-
115
- run
116
- end
117
- end
118
-
119
- context "with invalid config" do
120
- before do
121
- capistrano_config.set(:appsignal_config, :push_api_key => nil)
122
- end
123
-
124
- it "does not continue with invalid config" do
125
- run
126
- expect(output).to include \
127
- "Not notifying of deploy, config is not active for environment: production"
128
- end
129
- end
130
- end
131
- end
132
-
133
- describe "markers" do
134
- def stub_marker_request(data = {})
135
- stub_api_request config, "markers", marker_data.merge(data)
136
- end
137
-
138
- let(:marker_data) do
139
- {
140
- :revision => "503ce0923ed177a3ce000005",
141
- :user => "batman"
142
- }
143
- end
144
-
145
- context "when active for this environment" do
146
- it "transmits marker" do
147
- stub_marker_request.to_return(:status => 200)
148
- run
149
-
150
- expect(output).to include \
151
- "Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005," \
152
- " user: batman",
153
- "AppSignal has been notified of this deploy!"
154
- end
155
-
156
- context "with overridden revision" do
157
- before do
158
- capistrano_config.set(:appsignal_revision, "abc123")
159
- stub_marker_request(:revision => "abc123").to_return(:status => 200)
160
- run
161
- end
162
-
163
- it "transmits the overridden revision" do
164
- expect(output).to include \
165
- "Notifying AppSignal of deploy with: revision: abc123, user: batman",
166
- "AppSignal has been notified of this deploy!"
167
- end
168
- end
169
-
170
- context "with overridden deploy user" do
171
- before do
172
- capistrano_config.set(:appsignal_user, "robin")
173
- stub_marker_request(:user => "robin").to_return(:status => 200)
174
- run
175
- end
176
-
177
- it "transmits the overridden deploy user" do
178
- expect(output).to include \
179
- "Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005," \
180
- " user: robin",
181
- "AppSignal has been notified of this deploy!"
182
- end
183
- end
184
-
185
- context "with failed request" do
186
- before do
187
- stub_marker_request.to_return(:status => 500)
188
- run
189
- end
190
-
191
- it "does not transmit marker" do
192
- expect(output).to include \
193
- "Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005," \
194
- " user: batman",
195
- "Something went wrong while trying to notify AppSignal:"
196
- expect(output).to_not include "AppSignal has been notified of this deploy!"
197
- end
198
- end
199
-
200
- context "when dry run" do
201
- before do
202
- capistrano_config.dry_run = true
203
- run
204
- end
205
-
206
- it "does not transmit marker" do
207
- expect(output).to include \
208
- "Dry run: AppSignal deploy marker not actually sent."
209
- end
210
- end
211
- end
212
-
213
- context "when not active for this environment" do
214
- before do
215
- capistrano_config.set(:rails_env, "nonsense")
216
- run
217
- end
218
-
219
- it "does not transmit marker" do
220
- expect(output).to include \
221
- "Not notifying of deploy, config is not active for environment: nonsense"
222
- end
223
- end
224
- end
225
- end
226
- end
227
- end
@@ -1,284 +0,0 @@
1
- if DependencyHelper.capistrano3_present?
2
- require "capistrano/all"
3
- require "capistrano/deploy"
4
- require "appsignal/capistrano"
5
-
6
- describe "Capistrano 3 integration" do
7
- let(:capistrano) { Class.new.extend(Capistrano::DSL) }
8
- let(:env) { :production }
9
- let(:options) { {} }
10
- let(:config) { build_config(:env => env, :options => options) }
11
- let(:out_stream) { std_stream }
12
- let(:output) { out_stream.read }
13
- let(:logger) { Logger.new(out_stream) }
14
- let!(:capistrano_config) do
15
- Capistrano::Configuration.reset!
16
- Capistrano::Configuration.env.tap do |c|
17
- c.set(:log_level, :error)
18
- c.set(:logger, logger)
19
- c.set(:rails_env, "production")
20
- c.set(:repository, "main")
21
- c.set(:deploy_to, "/home/username/app")
22
- c.set(:current_release, "")
23
- c.set(:current_revision, "503ce0923ed177a3ce000005")
24
- end
25
- end
26
- let(:marker_data) do
27
- {
28
- :revision => "503ce0923ed177a3ce000005",
29
- :user => "batman"
30
- }
31
- end
32
- before { Rake::Task["appsignal:deploy"].reenable }
33
-
34
- def run
35
- capture_std_streams(out_stream, out_stream) do
36
- capistrano.invoke("appsignal:deploy")
37
- end
38
- end
39
-
40
- it "should have a deploy task" do
41
- expect(Rake::Task.task_defined?("appsignal:deploy")).to be_truthy
42
- end
43
-
44
- describe "appsignal:deploy task" do
45
- before do
46
- ENV["USER"] = "batman"
47
- end
48
- around do |example|
49
- Dir.chdir project_fixture_path do
50
- example.run
51
- end
52
- end
53
-
54
- context "config" do
55
- let(:options) { { :name => "AppName" } }
56
- before do
57
- capistrano_config.set(
58
- :appsignal_config,
59
- :name => "AppName",
60
- :active => true,
61
- :push_api_key => "abc"
62
- )
63
- end
64
-
65
- context "when rack_env is the only env set" do
66
- let(:env) { "rack_production" }
67
- before do
68
- capistrano_config.delete(:rails_env)
69
- capistrano_config.set(:rack_env, env)
70
- end
71
-
72
- it "uses the rack_env as the env" do
73
- stub_marker_request(
74
- :environment => env.to_s,
75
- :name => "AppName",
76
- :push_api_key => "abc"
77
- ).to_return(:status => 200)
78
- original_new = Appsignal::Marker.method(:new)
79
-
80
- expect(Appsignal::Marker).to receive(:new) do |data, given_config|
81
- expect(given_config.env).to eq("rack_production")
82
- original_new.call(data, given_config)
83
- end
84
-
85
- run
86
- end
87
- end
88
-
89
- context "when stage is set" do
90
- let(:env) { "stage_production" }
91
- before do
92
- capistrano_config.set(:rack_env, "rack_production")
93
- capistrano_config.set(:stage, env)
94
- end
95
-
96
- it "prefers the Capistrano stage rather than rails_env and rack_env" do
97
- stub_marker_request(
98
- :environment => env.to_s,
99
- :name => "AppName",
100
- :push_api_key => "abc"
101
- ).to_return(:status => 200)
102
- original_new = Appsignal::Marker.method(:new)
103
-
104
- expect(Appsignal::Marker).to receive(:new) do |data, given_config|
105
- expect(given_config.env).to eq("stage_production")
106
- original_new.call(data, given_config)
107
- end
108
-
109
- run
110
- end
111
- end
112
-
113
- context "when `appsignal_config` is set" do
114
- before do
115
- ENV["APPSIGNAL_APP_NAME"] = "EnvName"
116
- capistrano_config.set(:appsignal_config, :name => "CapName")
117
- end
118
-
119
- it "overrides the default config with the custom appsignal_config" do
120
- stub_marker_request(
121
- :environment => env.to_s,
122
- :name => "CapName",
123
- :push_api_key => "abc"
124
- ).to_return(:status => 200)
125
- original_new = Appsignal::Marker.method(:new)
126
-
127
- expect(Appsignal::Marker).to receive(:new) do |data, given_config|
128
- expect(given_config[:name]).to eq("CapName")
129
- original_new.call(data, given_config)
130
- end
131
-
132
- run
133
- end
134
-
135
- context "with invalid config" do
136
- before do
137
- capistrano_config.set(:appsignal_config, :push_api_key => nil)
138
- end
139
-
140
- it "does not continue with invalid config" do
141
- run
142
- expect(output).to include \
143
- "Not notifying of deploy, config is not active for environment: production"
144
- end
145
- end
146
- end
147
-
148
- context "when `appsignal_env` is set" do
149
- let(:env) { "appsignal_production" }
150
- before do
151
- capistrano_config.set(:rack_env, "rack_production")
152
- capistrano_config.set(:stage, "stage_production")
153
- capistrano_config.set(:appsignal_env, env)
154
- end
155
-
156
- it "prefers the appsignal_env rather than stage, rails_env and rack_env" do
157
- stub_marker_request(
158
- :environment => env.to_s,
159
- :name => "AppName",
160
- :push_api_key => "abc"
161
- ).to_return(:status => 200)
162
- original_new = Appsignal::Marker.method(:new)
163
-
164
- expect(Appsignal::Marker).to receive(:new) do |data, given_config|
165
- expect(given_config.env).to eq("appsignal_production")
166
- original_new.call(data, given_config)
167
- end
168
-
169
- run
170
- end
171
- end
172
- end
173
-
174
- describe "markers" do
175
- context "when active for this environment" do
176
- it "transmits marker" do
177
- stub_marker_request(
178
- :environment => env.to_s,
179
- :name => "TestApp",
180
- :push_api_key => "abc"
181
- ).to_return(:status => 200)
182
- run
183
-
184
- expect(output).to include \
185
- "Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005, " \
186
- "user: batman",
187
- "AppSignal has been notified of this deploy!"
188
- end
189
-
190
- context "with overridden revision" do
191
- before do
192
- capistrano_config.set(:appsignal_revision, "abc123")
193
- stub_marker_request(
194
- {
195
- :environment => env.to_s,
196
- :name => "TestApp",
197
- :push_api_key => "abc"
198
- },
199
- :revision => "abc123"
200
- ).to_return(:status => 200)
201
- run
202
- end
203
-
204
- it "transmits the overridden revision" do
205
- expect(output).to include \
206
- "Notifying AppSignal of deploy with: revision: abc123, user: batman",
207
- "AppSignal has been notified of this deploy!"
208
- end
209
- end
210
-
211
- context "with overridden deploy user" do
212
- before do
213
- capistrano_config.set(:appsignal_user, "robin")
214
- stub_marker_request(
215
- {
216
- :environment => env.to_s,
217
- :name => "TestApp",
218
- :push_api_key => "abc"
219
- },
220
- :user => "robin"
221
- ).to_return(:status => 200)
222
- run
223
- end
224
-
225
- it "transmits the overridden deploy user" do
226
- expect(output).to include \
227
- "Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005, " \
228
- "user: robin",
229
- "AppSignal has been notified of this deploy!"
230
- end
231
- end
232
-
233
- if Gem::Version.new(Capistrano::VERSION) >= Gem::Version.new("3.5.0")
234
- context "when dry run" do
235
- before do
236
- expect(capistrano_config).to receive(:dry_run?).and_return(true)
237
- run
238
- end
239
-
240
- it "does not transmit the marker" do
241
- expect(output).to include "Dry run: AppSignal deploy marker not actually sent."
242
- end
243
- end
244
- end
245
-
246
- context "with failed request" do
247
- before do
248
- stub_marker_request(
249
- :environment => env.to_s,
250
- :name => "TestApp",
251
- :push_api_key => "abc"
252
- ).to_return(:status => 500)
253
- run
254
- end
255
-
256
- it "does not transmit marker" do
257
- expect(output).to include \
258
- "Notifying AppSignal of deploy with: revision: 503ce0923ed177a3ce000005, " \
259
- "user: batman",
260
- "Something went wrong while trying to notify AppSignal:"
261
- expect(output).to_not include "AppSignal has been notified of this deploy!"
262
- end
263
- end
264
- end
265
-
266
- context "when not active for this environment" do
267
- before do
268
- capistrano_config.set(:rails_env, "nonsense")
269
- run
270
- end
271
-
272
- it "should not send deploy marker" do
273
- expect(output).to include \
274
- "Not notifying of deploy, config is not active for environment: nonsense"
275
- end
276
- end
277
- end
278
- end
279
- end
280
-
281
- def stub_marker_request(config = {}, data = {})
282
- stub_api_request config, "markers", marker_data.merge(data)
283
- end
284
- end