cuboid 0.0.3alpha → 0.1.0
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/README.md +14 -13
- data/cuboid.gemspec +1 -1
- data/lib/cuboid/application.rb +10 -10
- data/lib/cuboid/option_groups/agent.rb +54 -0
- data/lib/cuboid/option_groups/paths.rb +13 -4
- data/lib/cuboid/options.rb +1 -1
- data/lib/cuboid/processes/{dispatchers.rb → agents.rb} +40 -26
- data/lib/cuboid/processes/executables/agent.rb +5 -0
- data/lib/cuboid/processes/helpers/agents.rb +23 -0
- data/lib/cuboid/processes/helpers/instances.rb +4 -4
- data/lib/cuboid/processes/helpers.rb +1 -1
- data/lib/cuboid/processes/instances.rb +22 -10
- data/lib/cuboid/processes/schedulers.rb +16 -3
- data/lib/cuboid/processes.rb +2 -2
- data/lib/cuboid/rest/server/instance_helpers.rb +13 -13
- data/lib/cuboid/rest/server/routes/dispatcher.rb +11 -11
- data/lib/cuboid/rest/server/routes/grid.rb +8 -8
- data/lib/cuboid/rest/server/routes/instances.rb +1 -1
- data/lib/cuboid/rest/server.rb +5 -5
- data/lib/cuboid/rpc/client/{dispatcher.rb → agent.rb} +4 -4
- data/lib/cuboid/rpc/client/instance.rb +2 -2
- data/lib/cuboid/rpc/client.rb +1 -1
- data/lib/cuboid/rpc/server/agent/node.rb +247 -0
- data/lib/cuboid/rpc/server/{dispatcher → agent}/service.rb +13 -13
- data/lib/cuboid/rpc/server/{dispatcher.rb → agent.rb} +62 -32
- data/lib/cuboid/rpc/server/application_wrapper.rb +5 -4
- data/lib/cuboid/rpc/server/instance.rb +4 -4
- data/lib/cuboid/rpc/server/scheduler.rb +13 -12
- data/lib/version +1 -1
- data/spec/cuboid/option_groups/dispatcher_spec.rb +2 -2
- data/spec/cuboid/option_groups/paths_spec.rb +6 -3
- data/spec/cuboid/rest/server_spec.rb +45 -45
- data/spec/cuboid/rpc/client/dispatcher_spec.rb +2 -2
- data/spec/cuboid/rpc/server/dispatcher/node_spec.rb +65 -65
- data/spec/cuboid/rpc/server/dispatcher/service_spec.rb +16 -16
- data/spec/cuboid/rpc/server/dispatcher_spec.rb +187 -72
- data/spec/cuboid/rpc/server/scheduler_spec.rb +8 -8
- data/spec/support/fixtures/executables/node.rb +3 -3
- data/spec/support/fixtures/mock_app/test_service.rb +8 -8
- data/spec/support/fixtures/mock_app.rb +1 -1
- data/spec/support/fixtures/services/echo.rb +6 -6
- data/spec/support/helpers/resets.rb +1 -1
- data/spec/support/lib/web_server_client.rb +2 -2
- data/spec/support/lib/web_server_dispatcher.rb +1 -1
- metadata +18 -58
- data/lib/cuboid/option_groups/dispatcher.rb +0 -38
- data/lib/cuboid/processes/executables/dispatcher.rb +0 -5
- data/lib/cuboid/processes/helpers/dispatchers.rb +0 -23
- data/lib/cuboid/rpc/server/dispatcher/node.rb +0 -247
- data/spec/support/logs/Dispatcher - 51489-29703.log +0 -6
- data/spec/support/logs/Scheduler - 51474-42556.log +0 -3
- data/spec/support/logs/Scheduler - 51477-63074.log +0 -6
- data/spec/support/logs/Scheduler - 51496-16039.log +0 -3
- data/spec/support/logs/Scheduler - 51499-40309.log +0 -6
- data/spec/support/logs/Scheduler - 51521-54983.log +0 -4
- data/spec/support/logs/Scheduler - 51533-50145.log +0 -1
- data/spec/support/logs/Scheduler - 51537-26476.log +0 -3
- data/spec/support/logs/Scheduler - 51541-33347.log +0 -6
- data/spec/support/logs/Scheduler - 51556-5765.log +0 -3
- data/spec/support/logs/Scheduler - 51559-22349.log +0 -6
- data/spec/support/logs/Scheduler - 51567-20476.log +0 -3
- data/spec/support/logs/Scheduler - 51570-37548.log +0 -6
- data/spec/support/logs/Scheduler - 52668-26175.log +0 -3
- data/spec/support/reports/3480c2e4463df854d3457b247e3ba679.crf +0 -0
- data/spec/support/reports/45958408cb49a7f3391a973e05bf673b.crf +0 -0
- data/spec/support/reports/62a7f8d6c8914bb086e7e5f8c418d974.crf +0 -0
- data/spec/support/reports/6363927e13ec27b5cbd973b86bd8e52c.crf +0 -0
- data/spec/support/reports/b68f94be3aa96d0c27477dcfe1e25143.crf +0 -0
- data/spec/support/reports/bbb7496056393de17e72855a63d3acfb.crf +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require "#{Cuboid::Options.paths.lib}/rpc/server/
|
2
|
+
require "#{Cuboid::Options.paths.lib}/rpc/server/agent"
|
3
3
|
|
4
|
-
describe Cuboid::RPC::Server::
|
4
|
+
describe Cuboid::RPC::Server::Agent::Node do
|
5
5
|
|
6
6
|
def get_node( port = available_port )
|
7
7
|
Cuboid::Options.rpc.server_port = port
|
@@ -25,7 +25,7 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
|
|
25
25
|
|
26
26
|
before( :each ) do
|
27
27
|
options.paths.executables = "#{fixtures_path}executables/"
|
28
|
-
options.
|
28
|
+
options.agent.ping_interval = 0.5
|
29
29
|
end
|
30
30
|
after( :each ) do
|
31
31
|
Cuboid::Processes::Manager.killall
|
@@ -35,9 +35,9 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
|
|
35
35
|
let(:options) { Cuboid::Options }
|
36
36
|
|
37
37
|
describe '#grid_member?' do
|
38
|
-
context 'when the
|
38
|
+
context 'when the agent is a grid member' do
|
39
39
|
it 'should return true' do
|
40
|
-
options.
|
40
|
+
options.agent.peer = subject.url
|
41
41
|
|
42
42
|
c = get_node
|
43
43
|
sleep 0.5
|
@@ -46,68 +46,68 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
context 'when the
|
49
|
+
context 'when the agent is not a grid member' do
|
50
50
|
it 'should return false' do
|
51
51
|
expect(subject.grid_member?).to be_falsey
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
context 'when a previously unreachable
|
57
|
-
it 'gets re-added to the
|
56
|
+
context 'when a previously unreachable peer comes back to life' do
|
57
|
+
it 'gets re-added to the peers list' do
|
58
58
|
port = available_port
|
59
|
-
subject.
|
59
|
+
subject.add_peer( '127.0.0.1:' + port.to_s )
|
60
60
|
|
61
61
|
sleep 3
|
62
|
-
expect(subject.
|
62
|
+
expect(subject.peers).to be_empty
|
63
63
|
|
64
64
|
c = get_node( port )
|
65
65
|
|
66
66
|
sleep 0.5
|
67
|
-
expect(subject.
|
68
|
-
expect(c.
|
67
|
+
expect(subject.peers).to eq([c.url])
|
68
|
+
expect(c.peers).to eq([subject.url])
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
context 'when a
|
72
|
+
context 'when a peer becomes unreachable' do
|
73
73
|
it 'is removed' do
|
74
74
|
c = get_node
|
75
75
|
|
76
|
-
subject.
|
76
|
+
subject.add_peer( c.url )
|
77
77
|
sleep 0.5
|
78
78
|
|
79
|
-
expect(c.
|
80
|
-
expect(subject.
|
79
|
+
expect(c.peers).to eq([subject.url])
|
80
|
+
expect(subject.peers).to eq([c.url])
|
81
81
|
|
82
82
|
subject.shutdown rescue break while sleep 0.1
|
83
83
|
sleep 0.5
|
84
84
|
|
85
|
-
expect(c.
|
85
|
+
expect(c.peers).to be_empty
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
context 'when initialised with a
|
90
|
-
it 'adds that
|
91
|
-
options.
|
89
|
+
context 'when initialised with a peer' do
|
90
|
+
it 'adds that peer and reach convergence' do
|
91
|
+
options.agent.peer = subject.url
|
92
92
|
|
93
93
|
c = get_node
|
94
94
|
sleep 0.5
|
95
|
-
expect(c.
|
96
|
-
expect(subject.
|
95
|
+
expect(c.peers).to eq([subject.url])
|
96
|
+
expect(subject.peers).to eq([c.url])
|
97
97
|
|
98
98
|
d = get_node
|
99
99
|
sleep 0.5
|
100
|
-
expect(d.
|
101
|
-
expect(c.
|
102
|
-
expect(subject.
|
100
|
+
expect(d.peers.sort).to eq([subject.url, c.url].sort)
|
101
|
+
expect(c.peers.sort).to eq([subject.url, d.url].sort)
|
102
|
+
expect(subject.peers.sort).to eq([c.url, d.url].sort)
|
103
103
|
|
104
|
-
options.
|
104
|
+
options.agent.peer = d.url
|
105
105
|
e = get_node
|
106
106
|
sleep 0.5
|
107
|
-
expect(e.
|
108
|
-
expect(d.
|
109
|
-
expect(c.
|
110
|
-
expect(subject.
|
107
|
+
expect(e.peers.sort).to eq([subject.url, c.url, d.url].sort)
|
108
|
+
expect(d.peers.sort).to eq([subject.url, c.url, e.url].sort)
|
109
|
+
expect(c.peers.sort).to eq([subject.url, d.url, e.url].sort)
|
110
|
+
expect(subject.peers.sort).to eq([c.url, d.url, e.url].sort)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -115,75 +115,75 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
|
|
115
115
|
it 'removes itself from the Grid' do
|
116
116
|
c = get_node
|
117
117
|
|
118
|
-
subject.
|
118
|
+
subject.add_peer( c.url )
|
119
119
|
sleep 0.5
|
120
|
-
expect(c.
|
120
|
+
expect(c.peers).to eq([subject.url])
|
121
121
|
|
122
122
|
c.unplug
|
123
123
|
|
124
|
-
expect(c.
|
124
|
+
expect(c.peers).to be_empty
|
125
125
|
expect(c.grid_member?).to be_falsey
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
-
describe '#
|
129
|
+
describe '#add_peer' do
|
130
130
|
before(:each) do
|
131
|
-
subject.
|
131
|
+
subject.add_peer( other.url )
|
132
132
|
sleep 0.5
|
133
133
|
end
|
134
134
|
|
135
135
|
let( :other ) { get_node }
|
136
136
|
|
137
|
-
it 'adds a
|
138
|
-
expect(subject.
|
139
|
-
expect(other.
|
137
|
+
it 'adds a peer' do
|
138
|
+
expect(subject.peers).to eq([other.url])
|
139
|
+
expect(other.peers).to eq([subject.url])
|
140
140
|
end
|
141
141
|
|
142
142
|
context 'when propagate is set to true' do
|
143
|
-
it 'announces the new
|
143
|
+
it 'announces the new peer to the existing peers' do
|
144
144
|
n = get_node
|
145
|
-
subject.
|
145
|
+
subject.add_peer( n.url, true )
|
146
146
|
sleep 0.5
|
147
147
|
|
148
|
-
expect(subject.
|
149
|
-
expect(other.
|
148
|
+
expect(subject.peers.sort).to eq([other.url, n.url].sort)
|
149
|
+
expect(other.peers.sort).to eq([subject.url, n.url].sort)
|
150
150
|
|
151
151
|
c = get_node
|
152
|
-
n.
|
152
|
+
n.add_peer( c.url, true )
|
153
153
|
sleep 0.5
|
154
154
|
|
155
|
-
expect(subject.
|
156
|
-
expect(other.
|
157
|
-
expect(c.
|
155
|
+
expect(subject.peers.sort).to eq([other.url, n.url, c.url].sort)
|
156
|
+
expect(other.peers.sort).to eq([subject.url, n.url, c.url].sort)
|
157
|
+
expect(c.peers.sort).to eq([subject.url, n.url, other.url].sort)
|
158
158
|
|
159
159
|
d = get_node
|
160
|
-
d.
|
160
|
+
d.add_peer( c.url, true )
|
161
161
|
sleep 0.5
|
162
162
|
|
163
|
-
expect(subject.
|
164
|
-
expect(other.
|
165
|
-
expect(c.
|
166
|
-
expect(d.
|
163
|
+
expect(subject.peers.sort).to eq([d.url, other.url, n.url, c.url].sort)
|
164
|
+
expect(other.peers.sort).to eq([d.url, subject.url, n.url, c.url].sort)
|
165
|
+
expect(c.peers.sort).to eq([d.url, subject.url, n.url, other.url].sort)
|
166
|
+
expect(d.peers.sort).to eq([c.url, subject.url, n.url, other.url].sort)
|
167
167
|
end
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
|
-
describe '#
|
172
|
-
it 'returns an array of
|
173
|
-
expect(subject.
|
171
|
+
describe '#peers' do
|
172
|
+
it 'returns an array of peers' do
|
173
|
+
expect(subject.peers.is_a?( Array )).to be_truthy
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
|
-
describe '#
|
178
|
-
it 'returns all
|
179
|
-
subject.
|
177
|
+
describe '#peers_with_info' do
|
178
|
+
it 'returns all peers accompanied by their node info' do
|
179
|
+
subject.add_peer( get_node.url )
|
180
180
|
sleep 0.5
|
181
181
|
|
182
|
-
expect(subject.
|
183
|
-
expect(subject.
|
182
|
+
expect(subject.peers).to be_any
|
183
|
+
expect(subject.peers_with_info.size).to eq (subject.peers.size)
|
184
184
|
|
185
185
|
keys = subject.info.keys.sort
|
186
|
-
subject.
|
186
|
+
subject.peers_with_info.each do |i|
|
187
187
|
expect(i.keys.sort).to eq(keys)
|
188
188
|
end
|
189
189
|
end
|
@@ -191,18 +191,18 @@ describe Cuboid::RPC::Server::Dispatcher::Node do
|
|
191
191
|
|
192
192
|
describe '#info' do
|
193
193
|
it 'returns node info' do
|
194
|
-
options.
|
194
|
+
options.agent.name = 'blah'
|
195
195
|
|
196
196
|
c = get_node
|
197
|
-
subject.
|
197
|
+
subject.add_peer( c.url )
|
198
198
|
sleep 0.5
|
199
199
|
|
200
200
|
info = subject.info
|
201
201
|
|
202
202
|
expect(info['url']).to eq(subject.url)
|
203
|
-
expect(info['
|
204
|
-
expect(info['
|
205
|
-
expect(info['name']).to eq(options.
|
203
|
+
expect(info['peers']).to eq(subject.peers)
|
204
|
+
expect(info['unreachable_peers']).to be_empty
|
205
|
+
expect(info['name']).to eq(options.agent.name)
|
206
206
|
end
|
207
207
|
|
208
208
|
context 'when OptionGroups::RPC#server_external_address has been set' do
|
@@ -1,36 +1,36 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require "#{Cuboid::Options.paths.lib}/rpc/server/
|
2
|
+
require "#{Cuboid::Options.paths.lib}/rpc/server/agent"
|
3
3
|
|
4
|
-
describe Cuboid::RPC::Server::
|
4
|
+
describe Cuboid::RPC::Server::Agent::Service do
|
5
5
|
before( :each ) do
|
6
6
|
Cuboid::Options.paths.services = "#{fixtures_path}services/"
|
7
7
|
Cuboid::Options.system.max_slots = 10
|
8
8
|
end
|
9
9
|
let(:instance_count) { 3 }
|
10
|
-
let(:
|
11
|
-
let(:subject) {
|
10
|
+
let(:agent) { agent_spawn application: "#{fixtures_path}/mock_app.rb" }
|
11
|
+
let(:subject) { agent.test_service }
|
12
12
|
|
13
|
-
describe '#
|
14
|
-
it 'provides access to the parent
|
15
|
-
expect(subject.
|
13
|
+
describe '#agent' do
|
14
|
+
it 'provides access to the parent Agent' do
|
15
|
+
expect(subject.test_agent).to be_truthy
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '#opts' do
|
20
|
-
it 'provides access to the
|
20
|
+
it 'provides access to the Agent\'s options' do
|
21
21
|
expect(subject.test_opts).to be_truthy
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#node' do
|
26
|
-
it 'provides access to the
|
26
|
+
it 'provides access to the Agent\'s node' do
|
27
27
|
expect(subject.test_node).to be_truthy
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
describe '#instances' do
|
32
32
|
before(:each) do
|
33
|
-
instance_count.times {
|
33
|
+
instance_count.times { agent.spawn }
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'provides access to the running instances' do
|
@@ -40,7 +40,7 @@ describe Cuboid::RPC::Server::Dispatcher::Service do
|
|
40
40
|
|
41
41
|
describe '#map_instances' do
|
42
42
|
before(:each) do
|
43
|
-
instance_count.times {
|
43
|
+
instance_count.times { agent.spawn }
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'asynchronously maps all running instances' do
|
@@ -52,7 +52,7 @@ describe Cuboid::RPC::Server::Dispatcher::Service do
|
|
52
52
|
|
53
53
|
describe '#each_instance' do
|
54
54
|
before(:each) do
|
55
|
-
instance_count.times {
|
55
|
+
instance_count.times { agent.spawn }
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'asynchronously iterates over all running instances' do
|
@@ -92,15 +92,15 @@ describe Cuboid::RPC::Server::Dispatcher::Service do
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
describe '#
|
96
|
-
it 'connects to the a
|
97
|
-
expect(subject.
|
95
|
+
describe '#connect_to_agent' do
|
96
|
+
it 'connects to the a agent by url' do
|
97
|
+
expect(subject.test_connect_to_agent( agent.url )).to be_truthy
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
101
|
describe '#connect_to_instance' do
|
102
102
|
it 'connects to an instance' do
|
103
|
-
|
103
|
+
agent.spawn
|
104
104
|
instance = subject.instances.first
|
105
105
|
|
106
106
|
expect(subject.test_connect_to_instance( instance )).to be_falsey
|