heroku-qc-autoscale 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,6 +11,11 @@ module Autoscale
11
11
  client.post_ps_scale(app, "worker", qty)
12
12
  end
13
13
 
14
+ # shutdown all workers
15
+ def shutdown
16
+ self.workers = 0
17
+ end
18
+
14
19
  def job_count
15
20
  QC::Queries.count.to_i
16
21
  end
@@ -32,7 +37,7 @@ module Autoscale
32
37
  end
33
38
 
34
39
  def calculate_required_workers
35
- scale.rindex{|x| x <= job_count} + 1
40
+ (scale.rindex{|x| x <= job_count}.to_i + 1)
36
41
  end
37
42
 
38
43
  def params
@@ -1,7 +1,7 @@
1
1
  module Heroku
2
2
  module QC
3
3
  module Autoscale
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
6
6
  end
7
7
  end
@@ -26,6 +26,15 @@ describe Autoscale::Heroku do
26
26
  subject.job_count.must_equal(0)
27
27
  end
28
28
 
29
+ it "calculate required workers should be min of 1 with no jobs" do
30
+ # mock for no jobs
31
+ h = Autoscale::Heroku.dup
32
+ h.define_singleton_method(:job_count) { 0 }
33
+
34
+ h.job_count.must_equal(0)
35
+ h.calculate_required_workers.must_equal(1)
36
+ end
37
+
29
38
  it "#workers" do
30
39
  subject.workers = 1
31
40
  subject.workers.must_equal(1)
@@ -34,6 +43,14 @@ describe Autoscale::Heroku do
34
43
  subject.workers.must_equal(2)
35
44
  end
36
45
 
46
+ it "should shutdown workers" do
47
+ subject.workers = 2
48
+ subject.workers.must_equal(2)
49
+
50
+ subject.shutdown
51
+ subject.workers.must_equal(0)
52
+ end
53
+
37
54
  describe "scaling up" do
38
55
  it "with 5 jobs" do
39
56
  5.times{ QC.enqueue("Time.now") }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-qc-autoscale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  segments:
162
162
  - 0
163
- hash: 2325346798596805280
163
+ hash: 2193298556490401975
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  none: false
166
166
  requirements:
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  version: '0'
170
170
  segments:
171
171
  - 0
172
- hash: 2325346798596805280
172
+ hash: 2193298556490401975
173
173
  requirements: []
174
174
  rubyforge_project: heroku-qc-autoscale
175
175
  rubygems_version: 1.8.21