big_brother 0.6.8 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -0
- data/Changelog.md +5 -0
- data/big_brother.gemspec +1 -1
- data/lib/big_brother.rb +4 -0
- data/lib/big_brother/active_active_cluster.rb +157 -0
- data/lib/big_brother/active_passive_cluster.rb +61 -0
- data/lib/big_brother/cluster.rb +28 -13
- data/lib/big_brother/cluster_collection.rb +3 -0
- data/lib/big_brother/cluster_factory.rb +16 -0
- data/lib/big_brother/configuration.rb +21 -3
- data/lib/big_brother/health_fetcher.rb +12 -0
- data/lib/big_brother/node.rb +35 -10
- data/lib/big_brother/version.rb +1 -1
- data/lib/resources/config_schema.yml +92 -0
- data/spec/big_brother/active_active_cluster_spec.rb +437 -0
- data/spec/big_brother/active_passive_cluster_spec.rb +172 -0
- data/spec/big_brother/app_spec.rb +13 -11
- data/spec/big_brother/cluster_collection_spec.rb +26 -0
- data/spec/big_brother/cluster_factory_spec.rb +23 -0
- data/spec/big_brother/cluster_spec.rb +60 -18
- data/spec/big_brother/configuration_spec.rb +72 -27
- data/spec/big_brother/health_fetcher_spec.rb +47 -2
- data/spec/big_brother/node_spec.rb +42 -68
- data/spec/big_brother/ticker_spec.rb +6 -2
- data/spec/big_brother_spec.rb +85 -55
- data/spec/support/example_config.yml +65 -39
- data/spec/support/factories/cluster_factory.rb +9 -1
- data/spec/support/null_logger.rb +9 -0
- metadata +30 -25
@@ -2,7 +2,44 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe BigBrother::Configuration do
|
4
4
|
describe 'self.from_file' do
|
5
|
-
|
5
|
+
context 'loading invalid config' do
|
6
|
+
before do
|
7
|
+
@config_file = Tempfile.new('config.yml')
|
8
|
+
File.open(@config_file, 'w') do |f|
|
9
|
+
f.puts(<<-EOF)
|
10
|
+
---
|
11
|
+
clusters:
|
12
|
+
- cluster_name: 1
|
13
|
+
check_interval: ""
|
14
|
+
scheduler: wrr
|
15
|
+
fwmark: 1
|
16
|
+
nodes:
|
17
|
+
- address: 127.0.0
|
18
|
+
port: 9001
|
19
|
+
path: /test/valid
|
20
|
+
EOF
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'fails' do
|
25
|
+
BigBrother.configure(@config_file.path)
|
26
|
+
|
27
|
+
BigBrother.clusters.size.should be_zero
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'logs errors' do
|
31
|
+
errors = ["- [/clusters/0/cluster_name] '1': not a string.", "- [/clusters/0/check_interval] '': not a integer.", "- [/clusters/0/nodes/0/address] '127.0.0': not matched to pattern /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/."]
|
32
|
+
|
33
|
+
BigBrother.logger = NullLogger.new([])
|
34
|
+
BigBrother::Configuration.from_file(@config_file.path)
|
35
|
+
|
36
|
+
BigBrother.logger.messages.should == errors
|
37
|
+
|
38
|
+
BigBrother.logger = NullLogger.new
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'maintains a collection of clusters' do
|
6
43
|
clusters = BigBrother::Configuration.from_file(TEST_CONFIG)
|
7
44
|
|
8
45
|
clusters['test1'].check_interval.should == 1
|
@@ -17,11 +54,16 @@ describe BigBrother::Configuration do
|
|
17
54
|
clusters['test2'].check_interval.should == 2
|
18
55
|
clusters['test2'].scheduler.should == 'wrr'
|
19
56
|
clusters['test2'].fwmark.should == 2
|
20
|
-
clusters['test2'].ramp_up_time.should == 60
|
21
57
|
|
22
58
|
clusters['test3'].check_interval.should == 1
|
23
59
|
clusters['test3'].scheduler.should == 'wrr'
|
24
60
|
clusters['test3'].fwmark.should == 3
|
61
|
+
|
62
|
+
clusters['test4'].backend_mode.should == 'active_active'
|
63
|
+
clusters['test4'].offset.should == 10000
|
64
|
+
clusters['test4'].max_down_ticks.should == 100
|
65
|
+
clusters['test4'].ramp_up_time.should == 60
|
66
|
+
clusters['test4'].non_egress_locations.should == ['test']
|
25
67
|
end
|
26
68
|
|
27
69
|
it 'populates a clusters nodes' do
|
@@ -29,13 +71,15 @@ describe BigBrother::Configuration do
|
|
29
71
|
|
30
72
|
clusters['test1'].nodes.length.should == 2
|
31
73
|
|
32
|
-
clusters['test1'].nodes[0].address == '127.0.0.1'
|
33
|
-
clusters['test1'].nodes[0].port ==
|
34
|
-
clusters['test1'].nodes[0].path == '/test/valid'
|
74
|
+
clusters['test1'].nodes[0].address.should == '127.0.0.1'
|
75
|
+
clusters['test1'].nodes[0].port.should == 9001
|
76
|
+
clusters['test1'].nodes[0].path.should == '/test/valid'
|
35
77
|
|
36
|
-
clusters['test1'].nodes[1].address == '127.0.0.1'
|
37
|
-
clusters['test1'].nodes[1].port ==
|
38
|
-
clusters['test1'].nodes[1].path == '/test/valid'
|
78
|
+
clusters['test1'].nodes[1].address.should == '127.0.0.1'
|
79
|
+
clusters['test1'].nodes[1].port.should == 9002
|
80
|
+
clusters['test1'].nodes[1].path.should == '/test/valid'
|
81
|
+
|
82
|
+
clusters['test4'].interpol_node.should be_interpol
|
39
83
|
end
|
40
84
|
|
41
85
|
it 'allows a default cluster configuration under the global config key' do
|
@@ -45,28 +89,29 @@ describe BigBrother::Configuration do
|
|
45
89
|
---
|
46
90
|
_big_brother:
|
47
91
|
check_interval: 2
|
48
|
-
scheduler: wrr
|
49
92
|
nagios:
|
50
93
|
server: 127.0.0.2
|
51
94
|
host: ha-services
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
95
|
+
clusters:
|
96
|
+
- cluster_name: test_without_overrides
|
97
|
+
scheduler: wrr
|
98
|
+
fwmark: 2
|
99
|
+
nagios:
|
100
|
+
check: test_check
|
101
|
+
nodes:
|
102
|
+
- address: 127.0.0.1
|
103
|
+
port: 9001
|
104
|
+
path: /test/invalid
|
105
|
+
- cluster_name: test_with_overrides
|
106
|
+
fwmark: 3
|
107
|
+
scheduler: wlc
|
108
|
+
nagios:
|
109
|
+
host: override-host
|
110
|
+
check: test_overrides_check
|
111
|
+
nodes:
|
112
|
+
- address: 127.0.0.1
|
113
|
+
port: 9001
|
114
|
+
path: /test/invalid
|
70
115
|
EOF
|
71
116
|
end
|
72
117
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BigBrother::HealthFetcher do
|
4
|
-
|
5
|
-
run_in_reactor
|
4
|
+
run_in_reactor
|
6
5
|
|
6
|
+
describe "#current_health" do
|
7
7
|
it "returns its health" do
|
8
8
|
StubServer.new(<<-HTTP)
|
9
9
|
HTTP/1.0 200 OK
|
@@ -48,4 +48,49 @@ HTTP
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
describe "#interpol_status" do
|
52
|
+
it "returns nodes as a list" do
|
53
|
+
StubServer.new(<<-HTTP)
|
54
|
+
HTTP/1.0 200 OK
|
55
|
+
Connection: close
|
56
|
+
|
57
|
+
[{"aggregated_health":0,"count":1,"lb_ip_address":"load1.stq","lb_url":"http://load1.stq:80/lvs.json","health":0}]
|
58
|
+
HTTP
|
59
|
+
BigBrother::HealthFetcher.interpol_status(Factory.node(:address => "127.0.0.1", :port => 8081, :interpol => true, :path => '/fwmark'), 'test').should == [
|
60
|
+
{"aggregated_health" => 0,"count" => 1,"lb_ip_address" => "load1.stq","lb_url" => "http://load1.stq:80/lvs.json","health" => 0}
|
61
|
+
]
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns an empty list when HTTP status code is not 200" do
|
65
|
+
StubServer.new(<<-HTTP)
|
66
|
+
HTTP/1.0 503 OK
|
67
|
+
Connection: close
|
68
|
+
|
69
|
+
HTTP
|
70
|
+
BigBrother::HealthFetcher.interpol_status(Factory.node(:address => "127.0.0.1", :port => 8081, :interpol => true, :path => '/fwmark'), 'test').should == []
|
71
|
+
end
|
72
|
+
|
73
|
+
it "returns an empty list for an unknown service" do
|
74
|
+
StubServer.new(<<-HTTP)
|
75
|
+
HTTP/1.0 503 Service Unavailable
|
76
|
+
Connection: close
|
77
|
+
HTTP
|
78
|
+
BigBrother::HealthFetcher.interpol_status(Factory.node(:address => "127.0.0.1", :port => 8081, :interpol => true, :path => '/fwmark'), 'test').should == []
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns 0 for an unknown DNS entry" do
|
82
|
+
BigBrother::HealthFetcher.interpol_status(Factory.node(:address => "junk.local", :port => 8081, :interpol => true, :path => '/fwmark'), 'test').should == []
|
83
|
+
end
|
84
|
+
|
85
|
+
it "returns empty list for an unparseable response body" do
|
86
|
+
StubServer.new(<<-HTTP)
|
87
|
+
HTTP/1.0 200 OK
|
88
|
+
Connection: close
|
89
|
+
|
90
|
+
This part is for people.
|
91
|
+
HTTP
|
92
|
+
BigBrother::HealthFetcher.interpol_status(Factory.node(:address => "127.0.0.1", :port => 8081, :interpol => true, :path => '/fwmark'), 'test').should == []
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
51
96
|
end
|
@@ -3,108 +3,49 @@ require 'spec_helper'
|
|
3
3
|
describe BigBrother::Node do
|
4
4
|
|
5
5
|
describe "#monitor" do
|
6
|
-
it "updates the weight for the node" do
|
7
|
-
BigBrother::HealthFetcher.stub(:current_health).and_return(56)
|
8
|
-
node = Factory.node(:address => '127.0.0.1')
|
9
|
-
cluster = Factory.cluster(:fwmark => 100, :nodes => [node])
|
10
|
-
cluster.start_monitoring!
|
11
|
-
@stub_executor.commands.clear
|
12
|
-
|
13
|
-
node.monitor(cluster)
|
14
|
-
|
15
|
-
@stub_executor.commands.should include("ipvsadm --edit-server --fwmark-service 100 --real-server 127.0.0.1 --ipip --weight 56")
|
16
|
-
end
|
17
|
-
|
18
6
|
it "a node's health should increase linearly over the specified ramp up time" do
|
19
7
|
BigBrother::HealthFetcher.stub(:current_health).and_return(100)
|
20
8
|
Time.stub(:now).and_return(1345043600)
|
21
9
|
|
22
10
|
node = Factory.node(:address => '127.0.0.1')
|
23
11
|
cluster = Factory.cluster(:ramp_up_time => 60, :fwmark => 100, :nodes => [node])
|
24
|
-
cluster.start_monitoring!
|
25
12
|
|
26
13
|
Time.stub(:now).and_return(1345043630)
|
27
|
-
node.monitor(cluster)
|
28
|
-
@stub_executor.commands.last.should == "ipvsadm --edit-server --fwmark-service 100 --real-server 127.0.0.1 --ipip --weight 50"
|
14
|
+
node.monitor(cluster).should == 50
|
29
15
|
|
30
16
|
Time.stub(:now).and_return(1345043645)
|
31
|
-
node.monitor(cluster)
|
32
|
-
@stub_executor.commands.last.should == "ipvsadm --edit-server --fwmark-service 100 --real-server 127.0.0.1 --ipip --weight 75"
|
17
|
+
node.monitor(cluster).should == 75
|
33
18
|
|
34
19
|
Time.stub(:now).and_return(1345043720)
|
35
|
-
node.monitor(cluster)
|
36
|
-
@stub_executor.commands.last.should == "ipvsadm --edit-server --fwmark-service 100 --real-server 127.0.0.1 --ipip --weight 100"
|
20
|
+
node.monitor(cluster).should == 100
|
37
21
|
end
|
38
22
|
|
39
23
|
it "sets the weight to 100 for each node if an up file exists" do
|
40
24
|
BigBrother::HealthFetcher.stub(:current_health).and_return(56)
|
41
25
|
node = Factory.node(:address => '127.0.0.1', :weight => 10)
|
42
26
|
cluster = Factory.cluster(:fwmark => 100, :nodes => [node])
|
43
|
-
cluster.start_monitoring!
|
44
|
-
@stub_executor.commands.clear
|
45
27
|
|
46
28
|
BigBrother::StatusFile.new('up', 'test').create('Up for testing')
|
47
29
|
|
48
|
-
node.monitor(cluster)
|
49
|
-
|
50
|
-
@stub_executor.commands.should include("ipvsadm --edit-server --fwmark-service 100 --real-server 127.0.0.1 --ipip --weight 100")
|
30
|
+
node.monitor(cluster).should == 100
|
51
31
|
end
|
52
32
|
|
53
33
|
it "sets the weight to 0 for each node if a down file exists" do
|
54
34
|
BigBrother::HealthFetcher.stub(:current_health).and_return(56)
|
55
35
|
node = Factory.node(:address => '127.0.0.1')
|
56
36
|
cluster = Factory.cluster(:fwmark => 100, :nodes => [node])
|
57
|
-
cluster.start_monitoring!
|
58
|
-
@stub_executor.commands.clear
|
59
37
|
|
60
38
|
BigBrother::StatusFile.new('down', 'test').create('Down for testing')
|
61
39
|
|
62
|
-
node.monitor(cluster)
|
63
|
-
|
64
|
-
@stub_executor.commands.should include("ipvsadm --edit-server --fwmark-service 100 --real-server 127.0.0.1 --ipip --weight 0")
|
65
|
-
end
|
66
|
-
|
67
|
-
it "does not run multiple ipvsadm commands if the health does not change" do
|
68
|
-
BigBrother::HealthFetcher.stub(:current_health).and_return(56)
|
69
|
-
node = Factory.node(:address => '127.0.0.1')
|
70
|
-
cluster = Factory.cluster(:fwmark => 100, :nodes => [node])
|
71
|
-
cluster.start_monitoring!
|
72
|
-
@stub_executor.commands.clear
|
73
|
-
|
74
|
-
node.monitor(cluster)
|
75
|
-
node.monitor(cluster)
|
76
|
-
|
77
|
-
@stub_executor.commands.should == ["ipvsadm --edit-server --fwmark-service 100 --real-server 127.0.0.1 --ipip --weight 56"]
|
78
|
-
end
|
79
|
-
|
80
|
-
it "will run multiple ipvsadm commands if the health does change" do
|
81
|
-
BigBrother::HealthFetcher.stub(:current_health).and_return(56)
|
82
|
-
node = Factory.node(:address => '127.0.0.1')
|
83
|
-
cluster = Factory.cluster(:fwmark => 100, :nodes => [node])
|
84
|
-
cluster.start_monitoring!
|
85
|
-
@stub_executor.commands.clear
|
86
|
-
|
87
|
-
node.monitor(cluster)
|
88
|
-
node.monitor(cluster)
|
89
|
-
BigBrother::HealthFetcher.stub(:current_health).and_return(41)
|
90
|
-
node.monitor(cluster)
|
91
|
-
|
92
|
-
@stub_executor.commands.should == [
|
93
|
-
"ipvsadm --edit-server --fwmark-service 100 --real-server 127.0.0.1 --ipip --weight 56",
|
94
|
-
"ipvsadm --edit-server --fwmark-service 100 --real-server 127.0.0.1 --ipip --weight 41"
|
95
|
-
]
|
40
|
+
node.monitor(cluster).should == 0
|
96
41
|
end
|
97
42
|
|
98
|
-
it "
|
99
|
-
BigBrother::HealthFetcher.stub(:current_health).and_return(
|
100
|
-
node = Factory.node(:address => '127.0.0.1')
|
43
|
+
it "caps the weight of a node to the max_weight configured" do
|
44
|
+
BigBrother::HealthFetcher.stub(:current_health).and_return(100)
|
45
|
+
node = Factory.node(:address => '127.0.0.1', :max_weight => 10)
|
101
46
|
cluster = Factory.cluster(:fwmark => 100, :nodes => [node])
|
102
|
-
cluster.stop_monitoring!
|
103
|
-
|
104
|
-
@stub_executor.commands.clear
|
105
|
-
node.monitor(cluster)
|
106
47
|
|
107
|
-
|
48
|
+
node.monitor(cluster).should == 10
|
108
49
|
end
|
109
50
|
end
|
110
51
|
|
@@ -122,6 +63,39 @@ describe BigBrother::Node do
|
|
122
63
|
end
|
123
64
|
end
|
124
65
|
|
66
|
+
describe "<=>" do
|
67
|
+
it "returns 1 when compared to a node with a nil weight" do
|
68
|
+
node1 = Factory.node(:address => "127.0.0.1", :port => "8000", :priority => 1, :weight => 0)
|
69
|
+
node2 = Factory.node(:address => "127.0.0.2", :port => "8000", :priority => 2, :weight => nil)
|
70
|
+
(node1 <=> node2).should == 1
|
71
|
+
end
|
72
|
+
|
73
|
+
it "returns 1 for comparison of an unhealthy node to an healthy one" do
|
74
|
+
node1 = Factory.node(:address => "127.0.0.1", :port => "8000", :priority => 1, :weight => 0)
|
75
|
+
node2 = Factory.node(:address => "127.0.0.2", :port => "8000", :priority => 2, :weight => 90)
|
76
|
+
(node1 <=> node2).should == 1
|
77
|
+
end
|
78
|
+
|
79
|
+
it "returns -1 for a node with lower priority" do
|
80
|
+
node1 = Factory.node(:address => "127.0.0.1", :port => "8000", :priority => 1)
|
81
|
+
node2 = Factory.node(:address => "127.0.0.2", :port => "8000", :priority => 2)
|
82
|
+
(node1 <=> node2).should == -1
|
83
|
+
end
|
84
|
+
|
85
|
+
it "returns 1 for a node with higher priority" do
|
86
|
+
node1 = Factory.node(:address => "127.0.0.1", :port => "8000", :priority => 1)
|
87
|
+
node2 = Factory.node(:address => "127.0.0.2", :port => "8000", :priority => 2)
|
88
|
+
(node2 <=> node1).should == 1
|
89
|
+
end
|
90
|
+
|
91
|
+
it "uses ip address for comparison if the priorities are the same" do
|
92
|
+
node1 = Factory.node(:address => "127.0.0.1", :port => "8000", :priority => 1)
|
93
|
+
node2 = Factory.node(:address => "127.0.0.2", :port => "8000", :priority => 1)
|
94
|
+
(node2 <=> node1).should == 1
|
95
|
+
(node1 <=> node2).should == -1
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
125
99
|
describe "age" do
|
126
100
|
it "is the time in seconds since the node started" do
|
127
101
|
Time.stub(:now).and_return(1345043612)
|
@@ -23,9 +23,10 @@ describe BigBrother::Ticker do
|
|
23
23
|
Factory.node(:address => public_ip_address, :port => 8082)
|
24
24
|
]
|
25
25
|
)
|
26
|
-
BigBrother.clusters['test'].
|
26
|
+
BigBrother.clusters['test'].instance_variable_set(:@monitored, true)
|
27
27
|
@stub_executor.commands.clear
|
28
28
|
|
29
|
+
BigBrother::Ticker.instance_variable_set(:@outstanding_ticks, 0)
|
29
30
|
BigBrother::Ticker.tick
|
30
31
|
|
31
32
|
@stub_executor.commands.should include("ipvsadm --edit-server --fwmark-service 100 --real-server 127.0.0.1 --ipip --weight 74")
|
@@ -37,9 +38,10 @@ describe BigBrother::Ticker do
|
|
37
38
|
:fwmark => 100,
|
38
39
|
:nodes => [Factory.node(:address => '127.0.0.1', :port => 8081)]
|
39
40
|
)
|
40
|
-
BigBrother.clusters['test'].
|
41
|
+
BigBrother.clusters['test'].instance_variable_set(:@monitored, true)
|
41
42
|
@stub_executor.commands.clear
|
42
43
|
|
44
|
+
BigBrother::Ticker.instance_variable_set(:@outstanding_ticks, 0)
|
43
45
|
BigBrother::Ticker.tick
|
44
46
|
BigBrother::Ticker.tick
|
45
47
|
|
@@ -48,12 +50,14 @@ describe BigBrother::Ticker do
|
|
48
50
|
end
|
49
51
|
|
50
52
|
it "monitors clusters requiring monitoring" do
|
53
|
+
BigBrother::HealthFetcher.stub(:current_health)
|
51
54
|
BigBrother.clusters['one'] = Factory.cluster
|
52
55
|
BigBrother.clusters['two'] = Factory.cluster
|
53
56
|
BigBrother.clusters['two'].start_monitoring!
|
54
57
|
|
55
58
|
BigBrother.clusters['two'].should_receive(:monitor_nodes)
|
56
59
|
|
60
|
+
BigBrother::Ticker.instance_variable_set(:@outstanding_ticks, 0)
|
57
61
|
BigBrother::Ticker.tick
|
58
62
|
end
|
59
63
|
end
|
data/spec/big_brother_spec.rb
CHANGED
@@ -1,10 +1,29 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BigBrother do
|
4
|
+
describe '.monitor_nodes' do
|
5
|
+
it "updates the weight for all the nodes in a cluster" do
|
6
|
+
BigBrother::HealthFetcher.stub(:current_health).and_return(76)
|
7
|
+
node1 = Factory.node(:address => '127.0.0.1', :weight => 90)
|
8
|
+
node2 = Factory.node(:address => '127.0.0.2', :weight => 30)
|
9
|
+
cluster = Factory.cluster(:fwmark => 100, :nodes => [node1, node2])
|
10
|
+
cluster.start_monitoring!
|
11
|
+
@stub_executor.commands.clear
|
12
|
+
|
13
|
+
BigBrother::HealthFetcher.stub(:current_health).and_return(56)
|
14
|
+
cluster.monitor_nodes
|
15
|
+
|
16
|
+
cluster.nodes.map(&:weight).uniq.should == [56]
|
17
|
+
@stub_executor.commands.should include("ipvsadm --edit-server --fwmark-service 100 --real-server 127.0.0.1 --ipip --weight 56")
|
18
|
+
@stub_executor.commands.should include("ipvsadm --edit-server --fwmark-service 100 --real-server 127.0.0.2 --ipip --weight 56")
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
4
23
|
describe '.configure' do
|
5
24
|
it "reads the configuration file" do
|
6
25
|
BigBrother.configure(TEST_CONFIG)
|
7
|
-
BigBrother.clusters.size.should ==
|
26
|
+
BigBrother.clusters.size.should == 4
|
8
27
|
end
|
9
28
|
end
|
10
29
|
|
@@ -27,14 +46,15 @@ HTTP
|
|
27
46
|
File.open(config_file, 'w') do |f|
|
28
47
|
f.puts(<<-EOF)
|
29
48
|
---
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
49
|
+
clusters:
|
50
|
+
- cluster_name: test1
|
51
|
+
check_interval: 1
|
52
|
+
scheduler: wrr
|
53
|
+
fwmark: 1
|
54
|
+
nodes:
|
55
|
+
- address: 127.0.0.1
|
56
|
+
port: 9001
|
57
|
+
path: /test/valid
|
38
58
|
EOF
|
39
59
|
end
|
40
60
|
BigBrother.configure(config_file)
|
@@ -44,17 +64,24 @@ EOF
|
|
44
64
|
File.open(config_file, 'w') do |f|
|
45
65
|
f.puts(<<-EOF)
|
46
66
|
---
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
67
|
+
clusters:
|
68
|
+
- cluster_name: test1
|
69
|
+
check_interval: 1
|
70
|
+
scheduler: wrr
|
71
|
+
backend_mode: 'active_active'
|
72
|
+
fwmark: 1
|
73
|
+
nodes:
|
74
|
+
- address: 127.0.0.1
|
75
|
+
port: 9001
|
76
|
+
path: /test/another/path
|
77
|
+
- address: 127.0.0.9
|
78
|
+
port: 9000
|
79
|
+
path: /fwmark
|
80
|
+
interpol: true
|
55
81
|
EOF
|
56
82
|
end
|
57
83
|
BigBrother.reconfigure
|
84
|
+
BigBrother.clusters['test1'].class.should == BigBrother::ActiveActiveCluster
|
58
85
|
BigBrother.clusters['test1'].nodes.first.path.should == "/test/another/path"
|
59
86
|
end
|
60
87
|
|
@@ -64,14 +91,15 @@ EOF
|
|
64
91
|
File.open(config_file, 'w') do |f|
|
65
92
|
f.puts(<<-EOF)
|
66
93
|
---
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
94
|
+
clusters:
|
95
|
+
- cluster_name: test1
|
96
|
+
check_interval: 1
|
97
|
+
scheduler: wrr
|
98
|
+
fwmark: 1
|
99
|
+
nodes:
|
100
|
+
- address: 127.0.0.1
|
101
|
+
port: 9001
|
102
|
+
path: /test/valid
|
75
103
|
EOF
|
76
104
|
end
|
77
105
|
BigBrother.configure(config_file)
|
@@ -84,17 +112,18 @@ EOF
|
|
84
112
|
File.open(config_file, 'w') do |f|
|
85
113
|
f.puts(<<-EOF)
|
86
114
|
---
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
115
|
+
clusters:
|
116
|
+
- cluster_name: test1
|
117
|
+
check_interval: 1
|
118
|
+
scheduler: wrr
|
119
|
+
fwmark: 1
|
120
|
+
nodes:
|
121
|
+
- address: 127.0.0.1
|
122
|
+
port: 9001
|
123
|
+
path: /test/valid
|
124
|
+
- address: 127.0.0.2
|
125
|
+
port: 9001
|
126
|
+
path: /test/valid
|
98
127
|
EOF
|
99
128
|
end
|
100
129
|
BigBrother.reconfigure
|
@@ -109,20 +138,20 @@ EOF
|
|
109
138
|
File.open(config_file, 'w') do |f|
|
110
139
|
f.puts(<<-EOF)
|
111
140
|
---
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
141
|
+
clusters:
|
142
|
+
- cluster_name: test1
|
143
|
+
check_interval: 1
|
144
|
+
scheduler: wrr
|
145
|
+
fwmark: 1
|
146
|
+
ramp_up_time: 0
|
147
|
+
nodes:
|
148
|
+
- address: 127.0.0.1
|
149
|
+
port: 9001
|
150
|
+
path: /test/valid
|
121
151
|
EOF
|
122
152
|
end
|
123
153
|
BigBrother.configure(config_file)
|
124
154
|
BigBrother.clusters['test1'].start_monitoring!
|
125
|
-
@stub_executor.commands.clear
|
126
155
|
|
127
156
|
BigBrother.start_ticker!
|
128
157
|
|
@@ -131,20 +160,21 @@ EOF
|
|
131
160
|
File.open(config_file, 'w') do |f|
|
132
161
|
f.puts(<<-EOF)
|
133
162
|
---
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
163
|
+
clusters:
|
164
|
+
- cluster_name: test1
|
165
|
+
check_interval: 1
|
166
|
+
scheduler: wrr
|
167
|
+
fwmark: 1
|
168
|
+
nodes:
|
169
|
+
- address: 127.0.0.1
|
170
|
+
port: 9001
|
171
|
+
path: /test/another/path
|
142
172
|
EOF
|
143
173
|
end
|
144
174
|
BigBrother.reconfigure
|
145
175
|
BigBrother.clusters['test1'].nodes.first.path.should == "/test/another/path"
|
146
176
|
|
147
|
-
@stub_executor.commands.
|
177
|
+
@stub_executor.commands.last.should include("--weight 50")
|
148
178
|
end
|
149
179
|
end
|
150
180
|
end
|