appsignal 4.0.6-java → 4.0.7-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,557 +0,0 @@
1
- describe Appsignal::CheckIn::Scheduler do
2
- include WaitForHelper
3
- include TakeAtMostHelper
4
-
5
- let(:log_stream) { std_stream }
6
- let(:logs) { log_contents(log_stream) }
7
- let(:appsignal_options) { {} }
8
- let(:scheduler) { Appsignal::CheckIn.scheduler }
9
-
10
- before do
11
- start_agent(:options => appsignal_options, :internal_logger => test_logger(log_stream))
12
- # Shorten debounce intervals to make the tests run faster.
13
- stub_const("Appsignal::CheckIn::Scheduler::INITIAL_DEBOUNCE_SECONDS", 0.1)
14
- stub_const("Appsignal::CheckIn::Scheduler::BETWEEN_TRANSMISSIONS_DEBOUNCE_SECONDS", 0.1)
15
- end
16
-
17
- after do
18
- scheduler.stop
19
- end
20
-
21
- describe "when no event is sent" do
22
- it "does not start a thread" do
23
- expect(scheduler.thread).to be_nil
24
- end
25
-
26
- it "does not schedule a debounce" do
27
- expect(scheduler.waker).to be_nil
28
- end
29
-
30
- it "can be stopped" do
31
- # Set all debounce intervals to 10 seconds, to make the assertion
32
- # fail if it waits for the debounce -- this ensures that what is being
33
- # tested is that no debounces are awaited when stopping the scheduler.
34
- stub_const("Appsignal::CheckIn::Scheduler::INITIAL_DEBOUNCE_SECONDS", 10)
35
- stub_const("Appsignal::CheckIn::Scheduler::BETWEEN_TRANSMISSIONS_DEBOUNCE_SECONDS", 10)
36
-
37
- take_at_most(0.1) do
38
- expect { scheduler.stop }.not_to raise_error
39
- end
40
- end
41
-
42
- it "can be stopped more than once" do
43
- # Set all debounce intervals to 10 seconds, to make the assertion
44
- # fail if it waits for the debounce -- this ensures that what is being
45
- # tested is that no debounces are awaited when stopping the scheduler.
46
- stub_const("Appsignal::CheckIn::Scheduler::INITIAL_DEBOUNCE_SECONDS", 10)
47
- stub_const("Appsignal::CheckIn::Scheduler::BETWEEN_TRANSMISSIONS_DEBOUNCE_SECONDS", 10)
48
-
49
- take_at_most(0.1) do
50
- expect { scheduler.stop }.not_to raise_error
51
- expect { scheduler.stop }.not_to raise_error
52
- end
53
- end
54
-
55
- it "closes the queue when stopped" do
56
- scheduler.stop
57
- expect(scheduler.queue.closed?).to be(true)
58
- end
59
- end
60
-
61
- describe "when an event is sent" do
62
- it "starts a thread" do
63
- stub_check_in_request(
64
- :events => [
65
- "identifier" => "test",
66
- "kind" => "finish",
67
- "check_in_type" => "cron"
68
- ]
69
- )
70
- Appsignal::CheckIn.cron("test")
71
- expect(scheduler.thread).to be_a(Thread)
72
- end
73
-
74
- it "schedules a debounce" do
75
- stub_check_in_request(
76
- :events => [
77
- "identifier" => "test",
78
- "kind" => "finish",
79
- "check_in_type" => "cron"
80
- ]
81
- )
82
- Appsignal::CheckIn.cron("test")
83
- expect(scheduler.waker).to be_a(Thread)
84
- end
85
-
86
- it "schedules the event to be transmitted" do
87
- stub_check_in_request(
88
- :events => [
89
- "identifier" => "test",
90
- "kind" => "finish",
91
- "check_in_type" => "cron"
92
- ]
93
- )
94
-
95
- expect(scheduler.events).to be_empty
96
-
97
- Appsignal::CheckIn.cron("test")
98
-
99
- expect(scheduler.events).not_to be_empty
100
-
101
- wait_for("the event to be transmitted") { scheduler.transmitted == 1 }
102
-
103
- expect(scheduler.events).to be_empty
104
-
105
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `test` finish event")
106
- expect(logs).to contains_log(:debug, "Transmitted cron check-in `test` finish event")
107
- end
108
-
109
- it "waits for the event to be transmitted when stopped" do
110
- # Set all debounce intervals to 10 seconds, to make the test
111
- # fail if it waits for the debounce -- this ensures that what is being
112
- # tested is that the events are transmitted immediately when the
113
- # scheduler is stopped, without waiting for any debounce.
114
- stub_const("Appsignal::CheckIn::Scheduler::INITIAL_DEBOUNCE_SECONDS", 10)
115
- stub_const("Appsignal::CheckIn::Scheduler::BETWEEN_TRANSMISSIONS_DEBOUNCE_SECONDS", 10)
116
-
117
- stub_check_in_request(
118
- :events => [
119
- "identifier" => "test",
120
- "kind" => "finish",
121
- "check_in_type" => "cron"
122
- ]
123
- )
124
-
125
- Appsignal::CheckIn.cron("test")
126
-
127
- expect(scheduler.events).not_to be_empty
128
-
129
- take_at_most(0.1) do
130
- expect { scheduler.stop }.not_to raise_error
131
- end
132
-
133
- # Check that the thread wasn't killed before the transmission was
134
- # completed.
135
- expect(scheduler.transmitted).to eq(1)
136
-
137
- expect(scheduler.events).to be_empty
138
-
139
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `test` finish event")
140
- expect(logs).to contains_log(:debug, "Transmitted cron check-in `test` finish event")
141
- end
142
-
143
- it "can be stopped more than once" do
144
- # Set all debounce intervals to 10 seconds, to make the test
145
- # fail if it waits for the debounce -- this ensures that what is being
146
- # tested is that the events are transmitted immediately when the
147
- # scheduler is stopped, without waiting for the debounce interval.
148
- stub_const("Appsignal::CheckIn::Scheduler::INITIAL_DEBOUNCE_SECONDS", 10)
149
- stub_const("Appsignal::CheckIn::Scheduler::BETWEEN_TRANSMISSIONS_DEBOUNCE_SECONDS", 10)
150
-
151
- stub_check_in_request(
152
- :events => [
153
- "identifier" => "test",
154
- "kind" => "finish",
155
- "check_in_type" => "cron"
156
- ]
157
- )
158
- Appsignal::CheckIn.cron("test")
159
- take_at_most(0.1) do
160
- expect { scheduler.stop }.not_to raise_error
161
- end
162
-
163
- # Check that the thread wasn't killed before the transmission was
164
- # completed.
165
- expect(scheduler.transmitted).to eq(1)
166
-
167
- take_at_most(0.1) do
168
- expect { scheduler.stop }.not_to raise_error
169
- end
170
- end
171
-
172
- it "closes the queue when stopped" do
173
- stub_check_in_request(
174
- :events => [
175
- "identifier" => "test",
176
- "kind" => "finish",
177
- "check_in_type" => "cron"
178
- ]
179
- )
180
- Appsignal::CheckIn.cron("test")
181
- scheduler.stop
182
- expect(scheduler.queue.closed?).to be(true)
183
- end
184
-
185
- it "kills the thread when stopped" do
186
- stub_check_in_request(
187
- :events => [
188
- "identifier" => "test",
189
- "kind" => "finish",
190
- "check_in_type" => "cron"
191
- ]
192
- )
193
- Appsignal::CheckIn.cron("test")
194
- scheduler.stop
195
- expect(scheduler.thread.alive?).to be(false)
196
- end
197
-
198
- it "unschedules the debounce when stopped" do
199
- stub_check_in_request(
200
- :events => [
201
- "identifier" => "test",
202
- "kind" => "finish",
203
- "check_in_type" => "cron"
204
- ]
205
- )
206
- Appsignal::CheckIn.cron("test")
207
- waker = scheduler.waker
208
- scheduler.stop
209
- expect(waker.alive?).to be(false)
210
- expect(scheduler.waker).to be_nil
211
- end
212
- end
213
-
214
- describe "when many events are sent" do
215
- describe "within the short debounce interval" do
216
- it "transmits all events at once" do
217
- ["first", "second", "third"].map do |identifier|
218
- stub_check_in_request(
219
- :events => [
220
- "identifier" => identifier,
221
- "kind" => "finish",
222
- "check_in_type" => "cron"
223
- ]
224
- )
225
- end
226
-
227
- Appsignal::CheckIn.cron("first")
228
- Appsignal::CheckIn.cron("second")
229
- Appsignal::CheckIn.cron("third")
230
-
231
- wait_for("the events to be transmitted") { scheduler.transmitted == 1 }
232
- end
233
-
234
- it "transmits all events at once when stopped" do
235
- # Set a short debounce interval of 10 seconds, to make the final wait
236
- # fail if it waits for the debounce -- this ensures that what is being
237
- # tested is that the events are transmitted when the scheduler is
238
- # stopped.
239
- stub_const("Appsignal::CheckIn::Scheduler::INITIAL_DEBOUNCE_SECONDS", 10)
240
-
241
- ["first", "second", "third"].map do |identifier|
242
- stub_check_in_request(
243
- :events => [
244
- "identifier" => identifier,
245
- "kind" => "finish",
246
- "check_in_type" => "cron"
247
- ]
248
- )
249
- end
250
-
251
- Appsignal::CheckIn.cron("first")
252
- Appsignal::CheckIn.cron("second")
253
- Appsignal::CheckIn.cron("third")
254
-
255
- scheduler.stop
256
-
257
- wait_for("the events to be transmitted") { scheduler.transmitted == 1 }
258
- end
259
- end
260
-
261
- describe "further apart than the short debounce interval" do
262
- it "transmits the first event and enqueues future events" do
263
- stub_check_in_request(
264
- :events => [
265
- "identifier" => "first",
266
- "kind" => "finish",
267
- "check_in_type" => "cron"
268
- ]
269
- )
270
-
271
- Appsignal::CheckIn.cron("first")
272
-
273
- wait_for("the first event to be transmitted") { scheduler.transmitted == 1 }
274
-
275
- stub_check_in_request(
276
- :events => [
277
- {
278
- "identifier" => "second",
279
- "kind" => "finish",
280
- "check_in_type" => "cron"
281
- },
282
- {
283
- "identifier" => "third",
284
- "kind" => "finish",
285
- "check_in_type" => "cron"
286
- }
287
- ]
288
- )
289
- Appsignal::CheckIn.cron("second")
290
- Appsignal::CheckIn.cron("third")
291
-
292
- expect(scheduler.events).to match(["second", "third"].map do |identifier|
293
- hash_including({
294
- :identifier => identifier,
295
- :check_in_type => "cron",
296
- :kind => "finish"
297
- })
298
- end)
299
- end
300
-
301
- it "transmits the other events after the debounce interval" do
302
- stub_check_in_request(
303
- :events => [
304
- "identifier" => "first",
305
- "kind" => "finish",
306
- "check_in_type" => "cron"
307
- ]
308
- )
309
- Appsignal::CheckIn.cron("first")
310
-
311
- wait_for("the first event to be transmitted") { scheduler.transmitted == 1 }
312
-
313
- stub_check_in_request(
314
- :events => [
315
- {
316
- "identifier" => "second",
317
- "kind" => "finish",
318
- "check_in_type" => "cron"
319
- },
320
- {
321
- "identifier" => "third",
322
- "kind" => "finish",
323
- "check_in_type" => "cron"
324
- }
325
- ]
326
- )
327
-
328
- Appsignal::CheckIn.cron("second")
329
- Appsignal::CheckIn.cron("third")
330
-
331
- expect(scheduler.events).to_not be_empty
332
-
333
- wait_for("the other events to be transmitted") { scheduler.transmitted == 2 }
334
-
335
- expect(scheduler.events).to be_empty
336
-
337
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `first` finish event")
338
- expect(logs).to contains_log(:debug, "Transmitted cron check-in `first` finish event")
339
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `second` finish event")
340
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `third` finish event")
341
- expect(logs).to contains_log(:debug, "Transmitted 2 check-in events")
342
- end
343
-
344
- it "transmits the other events when stopped" do
345
- # Restore the original long debounce interval of 10 seconds, to make
346
- # the final wait fail if it waits for the debounce -- this ensures
347
- # that what is being tested is that the events are transmitted
348
- # immediately when the scheduler is stopped.
349
- stub_const("Appsignal::CheckIn::Scheduler::BETWEEN_TRANSMISSIONS_DEBOUNCE_SECONDS", 10)
350
-
351
- stub_check_in_request(
352
- :events => [
353
- "identifier" => "first",
354
- "kind" => "finish",
355
- "check_in_type" => "cron"
356
- ]
357
- )
358
- Appsignal::CheckIn.cron("first")
359
-
360
- wait_for("the event to be transmitted") { scheduler.transmitted == 1 }
361
-
362
- stub_check_in_request(
363
- :events => [
364
- {
365
- "identifier" => "second",
366
- "kind" => "finish",
367
- "check_in_type" => "cron"
368
- },
369
- {
370
- "identifier" => "third",
371
- "kind" => "finish",
372
- "check_in_type" => "cron"
373
- }
374
- ]
375
- )
376
-
377
- Appsignal::CheckIn.cron("second")
378
- Appsignal::CheckIn.cron("third")
379
-
380
- expect(scheduler.events).to_not be_empty
381
-
382
- scheduler.stop
383
-
384
- wait_for("the other events to be transmitted") { scheduler.transmitted == 2 }
385
-
386
- expect(scheduler.events).to be_empty
387
-
388
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `first` finish event")
389
- expect(logs).to contains_log(:debug, "Transmitted cron check-in `first` finish event")
390
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `second` finish event")
391
- expect(logs).to contains_log(:debug, "Scheduling cron check-in `third` finish event")
392
- expect(logs).to contains_log(:debug, "Transmitted 2 check-in events")
393
- end
394
- end
395
- end
396
-
397
- describe "when a similar event is sent more than once" do
398
- it "only transmits one of the similar events" do
399
- # We must instantiate `Appsignal::CheckIn::Cron` directly, as the
400
- # `.cron` helper would use a different digest for each invocation.
401
- cron = Appsignal::CheckIn::Cron.new(:identifier => "test")
402
-
403
- stub_check_in_request(
404
- :events => [
405
- "identifier" => "test",
406
- "kind" => "start",
407
- "check_in_type" => "cron"
408
- ]
409
- )
410
-
411
- cron.start
412
- cron.start
413
-
414
- wait_for("the event to be transmitted") { scheduler.transmitted == 1 }
415
-
416
- expect(logs).to contains_log(
417
- :debug,
418
- "Scheduling cron check-in `test` start event (digest #{cron.digest}) to be transmitted"
419
- )
420
- expect(logs).to contains_log(
421
- :debug,
422
- "Scheduling cron check-in `test` start event (digest #{cron.digest}) to be transmitted"
423
- )
424
- expect(logs).to contains_log(
425
- :debug,
426
- "Replacing previously scheduled cron check-in `test` start event (digest #{cron.digest})"
427
- )
428
- expect(logs).to contains_log(
429
- :debug,
430
- "Transmitted cron check-in `test` start event (digest #{cron.digest})"
431
- )
432
- end
433
- end
434
-
435
- describe "when the scheduler is stopped" do
436
- it "does not schedule any events to be transmitted" do
437
- scheduler.stop
438
-
439
- Appsignal::CheckIn.cron("test")
440
-
441
- expect(scheduler.events).to be_empty
442
-
443
- expect(logs).to contains_log(
444
- :debug,
445
- /Cannot transmit cron check-in `test` finish event .+: AppSignal is stopped/
446
- )
447
- end
448
- end
449
-
450
- describe "when AppSignal is not active" do
451
- let(:appsignal_options) { { :active => false } }
452
-
453
- it "does not schedule any events to be transmitted" do
454
- scheduler.stop
455
-
456
- Appsignal::CheckIn.cron("test")
457
-
458
- expect(scheduler.events).to be_empty
459
-
460
- expect(logs).to contains_log(
461
- :debug,
462
- /Cannot transmit cron check-in `test` finish event .+: AppSignal is not active/
463
- )
464
- end
465
- end
466
-
467
- describe "when transmitting returns a non-success response code" do
468
- it "logs the error and continues" do
469
- stub_check_in_request(
470
- :events => [
471
- "identifier" => "first",
472
- "kind" => "start",
473
- "check_in_type" => "cron"
474
- ],
475
- :response => { :status => 404 }
476
- )
477
- stub_check_in_request(
478
- :events => [
479
- "identifier" => "first",
480
- "kind" => "finish",
481
- "check_in_type" => "cron"
482
- ],
483
- :response => { :status => 404 }
484
- )
485
-
486
- Appsignal::CheckIn.cron("first")
487
-
488
- wait_for("the first event to be transmitted") { scheduler.transmitted == 1 }
489
-
490
- stub_check_in_request(
491
- :events => [
492
- "identifier" => "second",
493
- "kind" => "start",
494
- "check_in_type" => "cron"
495
- ]
496
- )
497
- stub_check_in_request(
498
- :events => [
499
- "identifier" => "second",
500
- "kind" => "finish",
501
- "check_in_type" => "cron"
502
- ]
503
- )
504
-
505
- Appsignal::CheckIn.cron("second")
506
-
507
- wait_for("the second event to be transmitted") { scheduler.transmitted == 2 }
508
-
509
- expect(logs).to contains_log(
510
- :error,
511
- /Failed to transmit cron check-in `first` finish event .+: 404 status code/
512
- )
513
- expect(logs).to contains_log(
514
- :debug,
515
- "Transmitted cron check-in `second` finish event"
516
- )
517
- end
518
- end
519
-
520
- describe "when transmitting throws an error" do
521
- it "logs the error and continues" do
522
- stub_check_in_request(
523
- :events => [
524
- "identifier" => "first",
525
- "kind" => "finish",
526
- "check_in_type" => "cron"
527
- ],
528
- :response => ExampleStandardError.new("Something went wrong")
529
- )
530
-
531
- Appsignal::CheckIn.cron("first")
532
-
533
- wait_for("the first event to be transmitted") { scheduler.transmitted == 1 }
534
-
535
- stub_check_in_request(
536
- :events => [
537
- "identifier" => "second",
538
- "kind" => "finish",
539
- "check_in_type" => "cron"
540
- ]
541
- )
542
-
543
- Appsignal::CheckIn.cron("second")
544
-
545
- wait_for("the second event to be transmitted") { scheduler.transmitted == 2 }
546
-
547
- expect(logs).to contains_log(
548
- :error,
549
- /Failed to transmit cron check-in `first` finish event .+: ExampleStandardError: Something went wrong/ # rubocop:disable Layout/LineLength
550
- )
551
- expect(logs).to contains_log(
552
- :debug,
553
- "Transmitted cron check-in `second` finish event"
554
- )
555
- end
556
- end
557
- end
@@ -1,46 +0,0 @@
1
- require "appsignal/cli"
2
-
3
- describe Appsignal::CLI::Demo do
4
- include CLIHelpers
5
-
6
- let(:options) { {} }
7
- let(:out_stream) { std_stream }
8
- let(:output) { out_stream.read }
9
- before(:context) { Appsignal.stop }
10
-
11
- def run
12
- run_within_dir project_fixture_path
13
- end
14
-
15
- def run_within_dir(chdir)
16
- Dir.chdir chdir do
17
- capture_stdout(out_stream) { run_cli("demo", options) }
18
- end
19
- end
20
-
21
- context "without configuration" do
22
- it "returns an error" do
23
- expect { run_within_dir tmp_dir }.to raise_error(SystemExit)
24
-
25
- expect(output).to include("Error: Unable to start the AppSignal agent")
26
- end
27
- end
28
-
29
- context "with configuration" do
30
- before do
31
- # Ignore sleeps to speed up the test
32
- allow(Appsignal::Demo).to receive(:sleep)
33
- end
34
- let(:options) { { :environment => "development" } }
35
-
36
- it "calls Appsignal::Demo transmitter" do
37
- expect(Appsignal::Demo).to receive(:transmit).and_return(true)
38
- run
39
- end
40
-
41
- it "outputs message" do
42
- run
43
- expect(output).to include("Demonstration sample data sent!")
44
- end
45
- end
46
- end
@@ -1,16 +0,0 @@
1
- require "bundler/cli"
2
- require "bundler/cli/common"
3
- require "appsignal/cli/diagnose/paths"
4
-
5
- describe Appsignal::CLI::Diagnose::Paths do
6
- describe "#paths" do
7
- before { start_agent }
8
-
9
- it "returns gem installation path as package_install_path" do
10
- expect(described_class.new.paths[:package_install_path]).to eq(
11
- :label => "AppSignal gem path",
12
- :path => Bundler::CLI::Common.select_spec("appsignal").full_gem_path.strip
13
- )
14
- end
15
- end
16
- end
@@ -1,86 +0,0 @@
1
- require "appsignal/cli/diagnose/utils"
2
-
3
- describe Appsignal::CLI::Diagnose::Utils do
4
- describe ".username_for_uid" do
5
- subject { described_class.username_for_uid(uid) }
6
-
7
- context "when user with id exists" do
8
- let(:uid) { 0 }
9
-
10
- it "returns username" do
11
- is_expected.to be_kind_of(String)
12
- end
13
- end
14
-
15
- context "when user with id does not exist" do
16
- let(:uid) { -1 }
17
-
18
- it "returns nil" do
19
- is_expected.to be_nil
20
- end
21
- end
22
- end
23
-
24
- describe ".group_for_gid" do
25
- subject { described_class.group_for_gid(uid) }
26
-
27
- context "when group with id exists" do
28
- let(:uid) { 0 }
29
-
30
- it "returns group name" do
31
- is_expected.to be_kind_of(String)
32
- end
33
- end
34
-
35
- context "when group with id does not exist" do
36
- let(:uid) { -3 }
37
-
38
- it "returns nil" do
39
- is_expected.to be_nil
40
- end
41
- end
42
- end
43
-
44
- describe ".read_file_content" do
45
- let(:path) { File.join(spec_system_tmp_dir, "test_file.txt") }
46
- let(:bytes_to_read) { 100 }
47
- subject { described_class.read_file_content(path, bytes_to_read) }
48
- before do
49
- File.write(path, file_contents)
50
- end
51
-
52
- context "when file is bigger than read size" do
53
- let(:file_contents) do
54
- "".tap do |s|
55
- 100.times do |i|
56
- s << "line #{i}\n"
57
- end
58
- end
59
- end
60
-
61
- it "returns the last X bytes" do
62
- is_expected
63
- .to eq(file_contents[(file_contents.length - bytes_to_read)..file_contents.length])
64
- end
65
- end
66
-
67
- context "when file is smaller than read size" do
68
- let(:file_contents) { "line 1\n" }
69
-
70
- it "returns the whole file content" do
71
- is_expected.to eq(file_contents)
72
- end
73
- end
74
-
75
- context "when reading the file raises an illegal seek error" do
76
- let(:file_contents) { "line 1\n" }
77
- before do
78
- expect(File).to receive(:binread).and_raise(Errno::ESPIPE)
79
- end
80
-
81
- it "returns the error as the content" do
82
- expect { subject }.to raise_error(Errno::ESPIPE)
83
- end
84
- end
85
- end
86
- end