big_brother 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/big_brother/app.rb +2 -2
- data/lib/big_brother/cluster.rb +4 -0
- data/lib/big_brother/version.rb +1 -1
- data/spec/big_brother/app_spec.rb +21 -8
- data/spec/big_brother/cluster_spec.rb +11 -0
- data/spec/big_brother/node_spec.rb +1 -1
- data/spec/support/factories/node_factory.rb +2 -1
- metadata +30 -30
data/lib/big_brother/app.rb
CHANGED
@@ -9,7 +9,7 @@ module BigBrother
|
|
9
9
|
Big Brother: #{BigBrother::VERSION}
|
10
10
|
|
11
11
|
Running:
|
12
|
-
#{BigBrother.clusters.running.map { |cluster| "+ #{cluster}\n" }.join}
|
12
|
+
#{BigBrother.clusters.running.map { |cluster| "+ #{cluster} - CombinedWeight: #{cluster.combined_weight}\n" }.join}
|
13
13
|
Stopped:
|
14
14
|
#{BigBrother.clusters.stopped.map { |cluster| "- #{cluster}\n" }.join}
|
15
15
|
CONTENT
|
@@ -22,7 +22,7 @@ Stopped:
|
|
22
22
|
|
23
23
|
get "/cluster/:name" do |name|
|
24
24
|
@cluster.synchronize! unless @cluster.monitored?
|
25
|
-
[200, "Running: #{@cluster.monitored?}"]
|
25
|
+
[200, "Running: #{@cluster.monitored?}\nCombinedWeight: #{@cluster.combined_weight}\n"]
|
26
26
|
end
|
27
27
|
|
28
28
|
put "/cluster/:name" do |name|
|
data/lib/big_brother/cluster.rb
CHANGED
data/lib/big_brother/version.rb
CHANGED
@@ -10,7 +10,10 @@ module BigBrother
|
|
10
10
|
it "returns the list of configured clusters and their status" do
|
11
11
|
BigBrother.clusters['one'] = Factory.cluster(:name => 'one', :fwmark => 1)
|
12
12
|
BigBrother.clusters['two'] = Factory.cluster(:name => 'two', :fwmark => 2)
|
13
|
-
BigBrother.clusters['three'] = Factory.cluster(
|
13
|
+
BigBrother.clusters['three'] = Factory.cluster(
|
14
|
+
:name => 'three', :fwmark => 3,
|
15
|
+
:nodes => [Factory.node(:weight => 99)]
|
16
|
+
)
|
14
17
|
BigBrother.clusters['three'].start_monitoring!
|
15
18
|
BigBrother.clusters['four'] = Factory.cluster(:name => 'four', :fwmark => 4)
|
16
19
|
|
@@ -19,7 +22,7 @@ module BigBrother
|
|
19
22
|
last_response.body.should include("Big Brother: #{BigBrother::VERSION}")
|
20
23
|
last_response.body.should include("- one (1)")
|
21
24
|
last_response.body.should include("- two (2)")
|
22
|
-
last_response.body.should include("+ three (3)")
|
25
|
+
last_response.body.should include("+ three (3) - CombinedWeight: 99")
|
23
26
|
last_response.body.should include("- four (4)")
|
24
27
|
end
|
25
28
|
end
|
@@ -31,17 +34,27 @@ module BigBrother
|
|
31
34
|
get "/cluster/test"
|
32
35
|
|
33
36
|
last_response.status.should == 200
|
34
|
-
last_response.body.should
|
37
|
+
last_response.body.should =~ /^Running: false$/
|
35
38
|
end
|
36
39
|
|
37
|
-
it "returns 'Running: true' when the cluster is running" do
|
38
|
-
BigBrother.clusters['test'] = Factory.cluster(
|
40
|
+
it "returns 'Running: true' and the combined weight when the cluster is running" do
|
41
|
+
BigBrother.clusters['test'] = Factory.cluster(
|
42
|
+
:name => 'test',
|
43
|
+
:nodes => [
|
44
|
+
Factory.node(:weight => 10),
|
45
|
+
Factory.node(:weight => 20),
|
46
|
+
Factory.node(:weight => 30)
|
47
|
+
]
|
48
|
+
)
|
39
49
|
|
40
50
|
put "/cluster/test"
|
41
51
|
get "/cluster/test"
|
42
52
|
|
43
53
|
last_response.status.should == 200
|
44
|
-
last_response.body.should ==
|
54
|
+
last_response.body.should == <<-RESPONSE_BODY
|
55
|
+
Running: true
|
56
|
+
CombinedWeight: 60
|
57
|
+
RESPONSE_BODY
|
45
58
|
end
|
46
59
|
|
47
60
|
it "attempts to synchronize the node if it is not running" do
|
@@ -51,14 +64,14 @@ module BigBrother
|
|
51
64
|
-a -f 1 -r 10.0.1.224:80 -i -w 1
|
52
65
|
-A -f 2 -s wrr
|
53
66
|
-a -f 2 -r 10.0.1.225:80 -i -w 1
|
54
|
-
|
67
|
+
OUTPUT
|
55
68
|
BigBrother.configure(TEST_CONFIG)
|
56
69
|
BigBrother.clusters['test'] = Factory.cluster(:name => 'test', :fwmark => 1)
|
57
70
|
|
58
71
|
get "/cluster/test"
|
59
72
|
|
60
73
|
last_response.status.should == 200
|
61
|
-
last_response.body.should
|
74
|
+
last_response.body.should =~ /^Running: true$/
|
62
75
|
end
|
63
76
|
|
64
77
|
it "returns a 404 http status when the cluster is not found" do
|
@@ -313,4 +313,15 @@ describe BigBrother::Cluster do
|
|
313
313
|
retval.should == config_cluster
|
314
314
|
end
|
315
315
|
end
|
316
|
+
|
317
|
+
describe "combined_weight" do
|
318
|
+
it "sums the weights of all the nodes in the cluster" do
|
319
|
+
cluster =Factory.cluster(:name => 'test', :nodes => [
|
320
|
+
Factory.node(:weight => 11),
|
321
|
+
Factory.node(:weight => 22),
|
322
|
+
Factory.node(:weight => 33)
|
323
|
+
])
|
324
|
+
cluster.combined_weight.should == 66
|
325
|
+
end
|
326
|
+
end
|
316
327
|
end
|
@@ -38,7 +38,7 @@ describe BigBrother::Node do
|
|
38
38
|
|
39
39
|
it "sets the weight to 100 for each node if an up file exists" do
|
40
40
|
BigBrother::HealthFetcher.stub(:current_health).and_return(56)
|
41
|
-
node = Factory.node(:address => '127.0.0.1')
|
41
|
+
node = Factory.node(:address => '127.0.0.1', :weight => 10)
|
42
42
|
cluster = Factory.cluster(:fwmark => 100, :nodes => [node])
|
43
43
|
cluster.start_monitoring!
|
44
44
|
@stub_executor.commands.clear
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: big_brother
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thin
|
16
|
-
requirement: &
|
16
|
+
requirement: &70107762666300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.3.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70107762666300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: async-rack
|
27
|
-
requirement: &
|
27
|
+
requirement: &70107762665540 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.5.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70107762665540
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sinatra
|
38
|
-
requirement: &
|
38
|
+
requirement: &70107762664840 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '1.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70107762664840
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rack-fiber_pool
|
49
|
-
requirement: &
|
49
|
+
requirement: &70107762663740 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0.9'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70107762663740
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: eventmachine
|
60
|
-
requirement: &
|
60
|
+
requirement: &70107762662860 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>'
|
@@ -68,10 +68,10 @@ dependencies:
|
|
68
68
|
version: 1.0.0.beta.100
|
69
69
|
type: :runtime
|
70
70
|
prerelease: false
|
71
|
-
version_requirements: *
|
71
|
+
version_requirements: *70107762662860
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: em-http-request
|
74
|
-
requirement: &
|
74
|
+
requirement: &70107762661360 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
77
|
- - ~>
|
@@ -79,10 +79,10 @@ dependencies:
|
|
79
79
|
version: '1.0'
|
80
80
|
type: :runtime
|
81
81
|
prerelease: false
|
82
|
-
version_requirements: *
|
82
|
+
version_requirements: *70107762661360
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: em-synchrony
|
85
|
-
requirement: &
|
85
|
+
requirement: &70107762744840 !ruby/object:Gem::Requirement
|
86
86
|
none: false
|
87
87
|
requirements:
|
88
88
|
- - ~>
|
@@ -90,10 +90,10 @@ dependencies:
|
|
90
90
|
version: '1.0'
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
|
-
version_requirements: *
|
93
|
+
version_requirements: *70107762744840
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: em-resolv-replace
|
96
|
-
requirement: &
|
96
|
+
requirement: &70107762743160 !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
99
|
- - ~>
|
@@ -101,10 +101,10 @@ dependencies:
|
|
101
101
|
version: '1.1'
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
|
-
version_requirements: *
|
104
|
+
version_requirements: *70107762743160
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: em-syslog
|
107
|
-
requirement: &
|
107
|
+
requirement: &70107762742560 !ruby/object:Gem::Requirement
|
108
108
|
none: false
|
109
109
|
requirements:
|
110
110
|
- - ~>
|
@@ -112,10 +112,10 @@ dependencies:
|
|
112
112
|
version: 0.0.2
|
113
113
|
type: :runtime
|
114
114
|
prerelease: false
|
115
|
-
version_requirements: *
|
115
|
+
version_requirements: *70107762742560
|
116
116
|
- !ruby/object:Gem::Dependency
|
117
117
|
name: rspec
|
118
|
-
requirement: &
|
118
|
+
requirement: &70107762741740 !ruby/object:Gem::Requirement
|
119
119
|
none: false
|
120
120
|
requirements:
|
121
121
|
- - ~>
|
@@ -123,10 +123,10 @@ dependencies:
|
|
123
123
|
version: 2.9.0
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
|
-
version_requirements: *
|
126
|
+
version_requirements: *70107762741740
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
128
|
name: rack-test
|
129
|
-
requirement: &
|
129
|
+
requirement: &70107762741240 !ruby/object:Gem::Requirement
|
130
130
|
none: false
|
131
131
|
requirements:
|
132
132
|
- - ~>
|
@@ -134,10 +134,10 @@ dependencies:
|
|
134
134
|
version: 0.6.1
|
135
135
|
type: :development
|
136
136
|
prerelease: false
|
137
|
-
version_requirements: *
|
137
|
+
version_requirements: *70107762741240
|
138
138
|
- !ruby/object:Gem::Dependency
|
139
139
|
name: rake
|
140
|
-
requirement: &
|
140
|
+
requirement: &70107762740820 !ruby/object:Gem::Requirement
|
141
141
|
none: false
|
142
142
|
requirements:
|
143
143
|
- - ! '>='
|
@@ -145,10 +145,10 @@ dependencies:
|
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
|
-
version_requirements: *
|
148
|
+
version_requirements: *70107762740820
|
149
149
|
- !ruby/object:Gem::Dependency
|
150
150
|
name: rake_commit
|
151
|
-
requirement: &
|
151
|
+
requirement: &70107762740240 !ruby/object:Gem::Requirement
|
152
152
|
none: false
|
153
153
|
requirements:
|
154
154
|
- - ~>
|
@@ -156,10 +156,10 @@ dependencies:
|
|
156
156
|
version: '0.13'
|
157
157
|
type: :development
|
158
158
|
prerelease: false
|
159
|
-
version_requirements: *
|
159
|
+
version_requirements: *70107762740240
|
160
160
|
- !ruby/object:Gem::Dependency
|
161
161
|
name: vagrant
|
162
|
-
requirement: &
|
162
|
+
requirement: &70107762739820 !ruby/object:Gem::Requirement
|
163
163
|
none: false
|
164
164
|
requirements:
|
165
165
|
- - ! '>='
|
@@ -167,7 +167,7 @@ dependencies:
|
|
167
167
|
version: '0'
|
168
168
|
type: :development
|
169
169
|
prerelease: false
|
170
|
-
version_requirements: *
|
170
|
+
version_requirements: *70107762739820
|
171
171
|
description: IPVS backend supervisor
|
172
172
|
email:
|
173
173
|
- code@getbraintree.com
|