tcell_agent 2.5.0 → 2.5.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4460b2fd01c8b788c8139cbeb2cee7f8a2505e4cc365c279a518778766d9cdb0
4
- data.tar.gz: 18dfdd5e944e91155d6b58fa22262b027292038192fac0b6afd4693314f74fd8
3
+ metadata.gz: 521fa2c98be5ea73aa4a9f4a8c00b9c1e51e2dd801de3c886324e28c95205142
4
+ data.tar.gz: a257258e3e3a4f71ee52d2242a3e37ec56c103da6aaae7ed471b87ef3b5ae054
5
5
  SHA512:
6
- metadata.gz: a2404786f0663783fd45194043c4a12efda21db0e933c14aca5f2d4532e900aac3b3f700ca8282b1995b38c718b6e0eade2a2b1ffbc9df467bf8ab5b4f144b18
7
- data.tar.gz: 5021cff2601b66fd94a41b710ab0ab0211be35b2bd442afc0ca992ce4236d6c65e3ef69e14cd2ca9455fb4282d8affa1ba3e7aa3f05c75e4285ff6b5ab77e871
6
+ metadata.gz: '0349621e1d4393d435561bb72dcb8928746caffb6f57828f4ea429d93546ef550be81ce7d15fad344775b9c4af18b17cff6339c800c51bcc573c025bcb2e4f49'
7
+ data.tar.gz: 4c7b9c61a59d6b7023fd2e54b8262a8ea1efed04600a36ccd5d92be85eb2240a1832178197dfa40ccef35ecddc886ee34d25ec674ba926c909461c7164b5b11d
@@ -21,12 +21,12 @@ if defined?(Puma.cli_config)
21
21
  (Gem::Version.new(Puma::Const::PUMA_VERSION) < Gem::Version.new('5.1.0'))
22
22
  def run(background = true)
23
23
  TCellAgent.thread_agent.start('Puma')
24
- original_run(background, options)
24
+ tcell_original_run(background)
25
25
  end
26
26
  else
27
27
  def run(background = true, thread_name: 'server')
28
28
  TCellAgent.thread_agent.start('Puma')
29
- original_run(background, :thread_name => thread_name)
29
+ tcell_original_run(background, :thread_name => thread_name)
30
30
  end
31
31
  end
32
32
  end
@@ -48,7 +48,7 @@ if defined?(Puma.cli_config)
48
48
  else
49
49
  def run(background = true, thread_name: 'server')
50
50
  TCellAgent.thread_agent.start('Puma')
51
- original_run(background, :thread_name => thread_name)
51
+ tcell_original_run(background, :thread_name => thread_name)
52
52
  end
53
53
  end
54
54
  end
@@ -15,7 +15,7 @@ Rack::Handler::Puma.class_eval do
15
15
  (Gem::Version.new(Puma::Const::PUMA_VERSION) >= Gem::Version.new('5.1.0'))
16
16
  def run(background = true, thread_name: 'server')
17
17
  TCellAgent.thread_agent.start('Puma')
18
- original_run(background, :thread_name => thread_name)
18
+ tcell_original_run(background, :thread_name => thread_name)
19
19
  end
20
20
  else
21
21
  def run(background = true)
@@ -1,18 +1,18 @@
1
1
  Rack::Handler::WEBrick.class_eval do
2
2
  class << self
3
- alias_method :original_run, :run
3
+ alias_method :tcell_original_run, :run
4
4
 
5
5
  if defined?(Gem::Version) &&
6
6
  defined?(Rack.release) &&
7
7
  Gem::Version.new(Rack.release) < Gem::Version.new('2.2.0')
8
8
  def run(app, options = {})
9
9
  TCellAgent.thread_agent.start('WEBrick')
10
- original_run(app, options)
10
+ tcell_original_run(app, options)
11
11
  end
12
12
  else
13
13
  def run(app, **options)
14
14
  TCellAgent.thread_agent.start('WEBrick')
15
- original_run(app, **options)
15
+ tcell_original_run(app, **options)
16
16
  end
17
17
  end
18
18
  end
@@ -1,5 +1,5 @@
1
1
  # See the file "LICENSE" for the full license governing this code.
2
2
 
3
3
  module TCellAgent
4
- VERSION = '2.5.0'.freeze
4
+ VERSION = '2.5.1'.freeze
5
5
  end
@@ -18,13 +18,34 @@ def test_passenger
18
18
  expect(PhusionPassenger::LoaderSharedHelpers.instance_methods.include?(:tcell_before_handling_requests))
19
19
  end
20
20
 
21
- def test_puma
21
+ def test_puma1
22
22
  expect(Puma.cli_config.options[:preload_app]).to be_falsey
23
23
  expect(Puma::Server.instance_methods.include?(:tcell_original_run)).to be_truthy
24
+
25
+ TCellAgent.thread_agent.should_receive(:start).and_return nil
26
+ expect { Puma::Server.new.run }.not_to raise_error
27
+ end
28
+
29
+ def test_puma2
30
+ expect(Puma.cli_config.options[:preload_app]).to be_truthy
31
+ Puma.cli_config.options[:workers].should eq 0
32
+ expect(Puma::Runner.instance_methods.include?(:tcell_original_start_server)).to be_truthy
33
+
34
+ TCellAgent.thread_agent.should_receive(:start).and_return nil
35
+ expect { Puma::Runner.new.start_server }.not_to raise_error
36
+ end
37
+
38
+ def test_puma3
39
+ expect(Puma.cli_config.options[:preload_app]).to be_truthy
40
+ Puma.cli_config.options[:workers].should eq 1
41
+ expect(Puma::Server.instance_methods.include?(:tcell_original_run)).to be_truthy
42
+
43
+ TCellAgent.thread_agent.should_receive(:start).and_return nil
44
+ expect { Puma::Server.new.run }.not_to raise_error
24
45
  end
25
46
 
26
47
  def test_server(filenames, funcs)
27
- fork do
48
+ pid = fork do
28
49
  filenames.each do |file|
29
50
  load file
30
51
  end
@@ -35,6 +56,10 @@ def test_server(filenames, funcs)
35
56
  method(func).call
36
57
  end
37
58
  end
59
+
60
+ Process.wait(pid)
61
+
62
+ raise 'RSpec test failed. See output above for additional information.' unless $?.exitstatus == 0
38
63
  end
39
64
 
40
65
  describe 'instrument_servers' do
@@ -56,9 +81,19 @@ describe 'instrument_servers' do
56
81
  end
57
82
 
58
83
  context 'with Puma server' do
59
- it 'should instrument Puma' do
60
- mocks = ['spec/support/server_mocks/puma_mock.rb']
61
- tests = [:test_puma]
84
+ it 'should instrument Puma, when :preload is false and workers is 0' do
85
+ mocks = ['spec/support/server_mocks/puma_mock_1.rb']
86
+ tests = [:test_puma1]
87
+ test_server(mocks, tests)
88
+ end
89
+ it 'should instrument Puma, when :preload is true and workers is 0' do
90
+ mocks = ['spec/support/server_mocks/puma_mock_2.rb']
91
+ tests = [:test_puma2]
92
+ test_server(mocks, tests)
93
+ end
94
+ it 'should instrument Puma, when :preload is true and workers is 1' do
95
+ mocks = ['spec/support/server_mocks/puma_mock_3.rb']
96
+ tests = [:test_puma3]
62
97
  test_server(mocks, tests)
63
98
  end
64
99
  end
@@ -83,11 +118,11 @@ describe 'instrument_servers' do
83
118
  it 'should instrument all servers available' do
84
119
  mocks = ['spec/support/server_mocks/rails_mock.rb',
85
120
  'spec/support/server_mocks/thin_mock.rb',
86
- 'spec/support/server_mocks/puma_mock.rb',
121
+ 'spec/support/server_mocks/puma_mock_1.rb',
87
122
  'spec/support/server_mocks/unicorn_mock.rb',
88
123
  'spec/support/server_mocks/passenger_mock.rb']
89
124
 
90
- tests = %i[test_rails test_thin test_puma test_unicorn test_passenger]
125
+ tests = %i[test_rails test_thin test_puma1 test_unicorn test_passenger]
91
126
 
92
127
  test_server(mocks, tests)
93
128
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Puma
4
4
  class Server
5
- def run; end
5
+ def run(background = true, thread_name: 'server'); end
6
6
  end
7
7
 
8
8
  class Config
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Puma
4
+ class Server
5
+ def run(background = true, thread_name: 'server'); end
6
+ end
7
+
8
+ class Runner
9
+ def start_server; end
10
+ end
11
+
12
+ class Config
13
+ def self.options
14
+ { :preload_app => true,
15
+ :workers => 0 }
16
+ end
17
+ end
18
+
19
+ def self.cli_config
20
+ Config
21
+ end
22
+
23
+ module Const
24
+ PUMA_VERSION = '5.1.0'
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Puma
4
+ class Server
5
+ def run(background = true, thread_name: 'server'); end
6
+ end
7
+
8
+ class Config
9
+ def self.options
10
+ { :preload_app => true,
11
+ :workers => 1 }
12
+ end
13
+ end
14
+
15
+ def self.cli_config
16
+ Config
17
+ end
18
+
19
+ module Const
20
+ PUMA_VERSION = '5.1.0'
21
+ end
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tcell_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rapid7, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-03 00:00:00.000000000 Z
11
+ date: 2021-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -242,7 +242,9 @@ files:
242
242
  - spec/support/resources/lfi_sample_file.txt
243
243
  - spec/support/resources/normal_config.json
244
244
  - spec/support/server_mocks/passenger_mock.rb
245
- - spec/support/server_mocks/puma_mock.rb
245
+ - spec/support/server_mocks/puma_mock_1.rb
246
+ - spec/support/server_mocks/puma_mock_2.rb
247
+ - spec/support/server_mocks/puma_mock_3.rb
246
248
  - spec/support/server_mocks/rails_mock.rb
247
249
  - spec/support/server_mocks/thin_mock.rb
248
250
  - spec/support/server_mocks/unicorn_mock.rb
@@ -324,7 +326,9 @@ test_files:
324
326
  - spec/support/resources/lfi_sample_file.txt
325
327
  - spec/support/resources/normal_config.json
326
328
  - spec/support/server_mocks/passenger_mock.rb
327
- - spec/support/server_mocks/puma_mock.rb
329
+ - spec/support/server_mocks/puma_mock_1.rb
330
+ - spec/support/server_mocks/puma_mock_2.rb
331
+ - spec/support/server_mocks/puma_mock_3.rb
328
332
  - spec/support/server_mocks/rails_mock.rb
329
333
  - spec/support/server_mocks/thin_mock.rb
330
334
  - spec/support/server_mocks/unicorn_mock.rb