einhorn 0.7.4 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,4 +18,118 @@ class CommandTest < EinhornTestCase
18
18
  Command.quieter
19
19
  end
20
20
  end
21
+
22
+ describe "resignal_timeout" do
23
+ it "does not kill any children" do
24
+ Einhorn::State.stubs(signal_timeout: 5 * 60)
25
+ Einhorn::State.stubs(children: {
26
+ 12345 => {last_signaled_at: nil},
27
+ 12346 => {signaled: Set.new(["USR1"]), last_signaled_at: Time.now - (2 * 60)},
28
+ })
29
+
30
+ Process.expects(:kill).never
31
+ Einhorn::Command.kill_expired_signaled_workers
32
+
33
+ refute(Einhorn::State.children[12346][:signaled].include?("KILL"), "Process was KILLed when it shouldn't have been")
34
+ end
35
+
36
+ it "KILLs stuck child processes" do
37
+ Time.stub :now, Time.at(0) do
38
+ Process.stub(:kill, true) do
39
+ Einhorn::State.stubs(signal_timeout: 60)
40
+ Einhorn::State.stubs(children: {
41
+ 12346 => {signaled: Set.new(["USR2"]), last_signaled_at: Time.now - (2 * 60)},
42
+ })
43
+
44
+ Einhorn::Command.kill_expired_signaled_workers
45
+
46
+ child = Einhorn::State.children[12346]
47
+ assert(child[:signaled].include?("KILL"), "Process was not KILLed as expected")
48
+ assert(child[:last_signaled_at] == Time.now, "The last_processed_at was not updated as expected")
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ describe "trigger_spinup?" do
55
+ it "is true by default" do
56
+ assert(Einhorn::Command.trigger_spinup?(1))
57
+ end
58
+
59
+ it "is false if unacked >= max_unacked" do
60
+ Einhorn::State.stubs(children: {12346 => {type: :worker, acked: false, signaled: Set.new}})
61
+ assert(Einhorn::Command.trigger_spinup?(1))
62
+ end
63
+
64
+ it "is false if capacity is exceeded" do
65
+ Einhorn::State.stubs(config: {max_upgrade_additional: 1, number: 1})
66
+ Einhorn::State.stubs(
67
+ children: {
68
+ 1 => {type: :worker, acked: true, signaled: Set.new},
69
+ 2 => {type: :worker, acked: true, signaled: Set.new},
70
+ 3 => {type: :worker, acked: true, signaled: Set.new},
71
+ }
72
+ )
73
+ refute(Einhorn::Command.trigger_spinup?(1))
74
+ end
75
+
76
+ it "is true if under capacity" do
77
+ Einhorn::State.stubs(config: {max_upgrade_additional: 2, number: 1})
78
+ Einhorn::State.stubs(children: {1 => {type: :worker, acked: true, signaled: Set.new}})
79
+ assert(Einhorn::Command.trigger_spinup?(1))
80
+ end
81
+ end
82
+
83
+ describe "replenish_gradually" do
84
+ it "does nothing if an outstanding spinup timer exists" do
85
+ Einhorn::TransientState.stubs(has_outstanding_spinup_timer: true)
86
+ Einhorn::Command.expects(:spinup).never
87
+ Einhorn::Command.replenish_gradually
88
+ end
89
+ it "does nothing if the worker pool is full" do
90
+ Einhorn::TransientState.stubs(has_outstanding_spinup_timer: false)
91
+ Einhorn::WorkerPool.stubs(missing_worker_count: 0)
92
+ Einhorn::Command.expects(:spinup).never
93
+ Einhorn::Command.replenish_gradually
94
+ end
95
+
96
+ it "does nothing if we have not reached the spinup interval" do
97
+ Einhorn::TransientState.stubs(has_outstanding_spinup_timer: false)
98
+ Einhorn::WorkerPool.stubs(missing_worker_count: 1)
99
+ Einhorn::State.stubs(last_spinup: Time.now)
100
+ Einhorn::Command.expects(:spinup).never
101
+ Einhorn::Command.replenish_gradually
102
+ end
103
+
104
+ it "calls trigger_spinup? if we have reached the spinup interval" do
105
+ Einhorn::TransientState.stubs(has_outstanding_spinup_timer: false)
106
+ Einhorn::State.stubs(config: {seconds: 1, max_unacked: 2, number: 1})
107
+ Einhorn::WorkerPool.stubs(missing_worker_count: 1)
108
+ Einhorn::State.stubs(last_spinup: Time.now - 2) # 2 seconds ago
109
+ Einhorn::Command.expects(:trigger_spinup?).with(2).returns(false)
110
+ Einhorn::Command.replenish_gradually
111
+ end
112
+
113
+ it "can handle sub-second spinup intervals" do
114
+ Einhorn::TransientState.stubs(has_outstanding_spinup_timer: false)
115
+ Einhorn::State.stubs(config: {seconds: 0.1, max_unacked: 2, number: 1})
116
+ Einhorn::WorkerPool.stubs(missing_worker_count: 1)
117
+ Einhorn::State.stubs(last_spinup: Time.now - 0.5) # Half a second ago
118
+ Einhorn::Command.stubs(trigger_spinup?: true)
119
+ Einhorn::Command.expects(:spinup)
120
+ Einhorn::Command.replenish_gradually
121
+ end
122
+
123
+ it "registers a timer to run again at spinup interval" do
124
+ Einhorn::TransientState.stubs(has_outstanding_spinup_timer: false)
125
+ Einhorn::State.stubs(config: {seconds: 0.1, max_unacked: 2, number: 1})
126
+ Einhorn::WorkerPool.stubs(missing_worker_count: 1)
127
+ Einhorn::State.stubs(last_spinup: Time.now - 1)
128
+ Einhorn::Command.stubs(trigger_spinup?: true)
129
+ Einhorn::Command.stubs(:spinup)
130
+ Einhorn::TransientState.expects(:has_outstanding_spinup_timer=).with(true)
131
+ Einhorn::Event::Timer.expects(:open).with(0.1)
132
+ Einhorn::Command.replenish_gradually
133
+ end
134
+ end
21
135
  end
metadata CHANGED
@@ -1,126 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: einhorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
5
- prerelease:
4
+ version: 0.8.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Greg Brockman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2016-07-13 00:00:00.000000000 Z
11
+ date: 2020-10-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rack
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.6'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.6'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: pry
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: minitest
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - <
59
+ - - "<"
68
60
  - !ruby/object:Gem::Version
69
61
  version: '5.0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - <
66
+ - - "<"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '5.0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: mocha
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0.13'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0.13'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: chalk-rake
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: subprocess
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  description: Einhorn makes it easy to run multiple instances of an application server,
@@ -135,8 +120,8 @@ executables:
135
120
  extensions: []
136
121
  extra_rdoc_files: []
137
122
  files:
138
- - .gitignore
139
- - .travis.yml
123
+ - ".gitignore"
124
+ - ".travis.yml"
140
125
  - CONTRIBUTORS
141
126
  - Gemfile
142
127
  - History.txt
@@ -163,6 +148,8 @@ files:
163
148
  - lib/einhorn/event/loop_breaker.rb
164
149
  - lib/einhorn/event/persistent.rb
165
150
  - lib/einhorn/event/timer.rb
151
+ - lib/einhorn/prctl.rb
152
+ - lib/einhorn/prctl_linux.rb
166
153
  - lib/einhorn/third.rb
167
154
  - lib/einhorn/version.rb
168
155
  - lib/einhorn/worker.rb
@@ -172,11 +159,16 @@ files:
172
159
  - test/integration/_lib/fixtures/env_printer/env_printer.rb
173
160
  - test/integration/_lib/fixtures/exit_during_upgrade/exiting_server.rb
174
161
  - test/integration/_lib/fixtures/exit_during_upgrade/upgrade_reexec.rb
162
+ - test/integration/_lib/fixtures/pdeathsig_printer/pdeathsig_printer.rb
163
+ - test/integration/_lib/fixtures/signal_timeout/sleepy_server.rb
175
164
  - test/integration/_lib/fixtures/upgrade_project/upgrading_server.rb
176
165
  - test/integration/_lib/helpers.rb
177
166
  - test/integration/_lib/helpers/einhorn_helpers.rb
167
+ - test/integration/pdeathsig.rb
178
168
  - test/integration/startup.rb
179
169
  - test/integration/upgrading.rb
170
+ - test/unit/_lib/bad_worker.rb
171
+ - test/unit/_lib/sleep_worker.rb
180
172
  - test/unit/einhorn.rb
181
173
  - test/unit/einhorn/client.rb
182
174
  - test/unit/einhorn/command.rb
@@ -186,45 +178,42 @@ files:
186
178
  homepage: https://github.com/stripe/einhorn
187
179
  licenses:
188
180
  - MIT
181
+ metadata: {}
189
182
  post_install_message:
190
183
  rdoc_options: []
191
184
  require_paths:
192
185
  - lib
193
186
  required_ruby_version: !ruby/object:Gem::Requirement
194
- none: false
195
187
  requirements:
196
- - - ! '>='
188
+ - - ">="
197
189
  - !ruby/object:Gem::Version
198
190
  version: '0'
199
- segments:
200
- - 0
201
- hash: 4291999791412545660
202
191
  required_rubygems_version: !ruby/object:Gem::Requirement
203
- none: false
204
192
  requirements:
205
- - - ! '>='
193
+ - - ">="
206
194
  - !ruby/object:Gem::Version
207
195
  version: '0'
208
- segments:
209
- - 0
210
- hash: 4291999791412545660
211
196
  requirements: []
212
- rubyforge_project:
213
- rubygems_version: 1.8.23
197
+ rubygems_version: 3.1.2
214
198
  signing_key:
215
- specification_version: 3
216
- summary: ! 'Einhorn: the language-independent shared socket manager'
199
+ specification_version: 4
200
+ summary: 'Einhorn: the language-independent shared socket manager'
217
201
  test_files:
218
202
  - test/_lib.rb
219
203
  - test/integration/_lib.rb
220
204
  - test/integration/_lib/fixtures/env_printer/env_printer.rb
221
205
  - test/integration/_lib/fixtures/exit_during_upgrade/exiting_server.rb
222
206
  - test/integration/_lib/fixtures/exit_during_upgrade/upgrade_reexec.rb
207
+ - test/integration/_lib/fixtures/pdeathsig_printer/pdeathsig_printer.rb
208
+ - test/integration/_lib/fixtures/signal_timeout/sleepy_server.rb
223
209
  - test/integration/_lib/fixtures/upgrade_project/upgrading_server.rb
224
210
  - test/integration/_lib/helpers.rb
225
211
  - test/integration/_lib/helpers/einhorn_helpers.rb
212
+ - test/integration/pdeathsig.rb
226
213
  - test/integration/startup.rb
227
214
  - test/integration/upgrading.rb
215
+ - test/unit/_lib/bad_worker.rb
216
+ - test/unit/_lib/sleep_worker.rb
228
217
  - test/unit/einhorn.rb
229
218
  - test/unit/einhorn/client.rb
230
219
  - test/unit/einhorn/command.rb