drbqs 0.0.13 → 0.0.14
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.
- data/Gemfile +10 -7
- data/README.md +52 -11
- data/Rakefile +32 -10
- data/VERSION +1 -1
- data/bin/drbqs-manage +3 -93
- data/bin/drbqs-node +3 -89
- data/bin/drbqs-server +3 -117
- data/bin/drbqs-ssh +6 -0
- data/drbqs.gemspec +118 -97
- data/example/README.md +2 -2
- data/lib/drbqs/config/config.rb +88 -0
- data/lib/drbqs/config/process_list.rb +194 -0
- data/lib/drbqs/config/ssh_host.rb +41 -0
- data/lib/drbqs/{execute_node.rb → manage/execute_node.rb} +6 -4
- data/lib/drbqs/manage/manage.rb +100 -0
- data/lib/drbqs/manage/send_signal.rb +45 -0
- data/lib/drbqs/manage/ssh_execute.rb +23 -0
- data/lib/drbqs/manage/ssh_shell.rb +143 -0
- data/lib/drbqs/node/connection.rb +69 -0
- data/lib/drbqs/{client.rb → node/node.rb} +48 -18
- data/lib/drbqs/node/task_client.rb +94 -0
- data/lib/drbqs/server/acl_file.rb +15 -0
- data/lib/drbqs/server/check_alive.rb +23 -0
- data/lib/drbqs/server/history.rb +49 -0
- data/lib/drbqs/server/message.rb +142 -0
- data/lib/drbqs/server/node_list.rb +59 -0
- data/lib/drbqs/server/queue.rb +128 -0
- data/lib/drbqs/{server.rb → server/server.rb} +66 -74
- data/lib/drbqs/server/server_hook.rb +72 -0
- data/lib/drbqs/server/transfer_setting.rb +30 -0
- data/lib/drbqs/task/command_task.rb +43 -0
- data/lib/drbqs/{task.rb → task/task.rb} +18 -39
- data/lib/drbqs/{task_generator.rb → task/task_generator.rb} +2 -0
- data/lib/drbqs/utility/argument.rb +27 -0
- data/lib/drbqs/utility/command_line/command_base.rb +27 -0
- data/lib/drbqs/utility/command_line/command_manage.rb +121 -0
- data/lib/drbqs/utility/command_line/command_node.rb +103 -0
- data/lib/drbqs/utility/command_line/command_server.rb +165 -0
- data/lib/drbqs/utility/command_line/command_ssh.rb +126 -0
- data/lib/drbqs/utility/command_line.rb +15 -0
- data/lib/drbqs/utility/misc.rb +72 -0
- data/lib/drbqs/{server_define.rb → utility/server_define.rb} +23 -8
- data/lib/drbqs/utility/temporary.rb +49 -0
- data/lib/drbqs/{ssh/transfer.rb → utility/transfer/file_transfer.rb} +18 -58
- data/lib/drbqs/utility/transfer/transfer_client.rb +90 -0
- data/lib/drbqs.rb +10 -22
- data/spec/config/config_spec.rb +84 -0
- data/spec/config/process_list_spec.rb +149 -0
- data/spec/config/ssh_host_spec.rb +81 -0
- data/spec/integration_test/01_basic_usage_spec.rb +54 -0
- data/spec/integration_test/02_use_generator_spec.rb +53 -0
- data/spec/integration_test/03_use_temporary_file_spec.rb +26 -0
- data/spec/integration_test/04_use_unix_domain_spec.rb +34 -0
- data/spec/integration_test/05_server_exit_signal_spec.rb +23 -0
- data/spec/integration_test/06_node_exit_after_task_spec.rb +42 -0
- data/spec/integration_test/07_command_server_with_node_spec.rb +44 -0
- data/spec/integration_test/definition/server01.rb +20 -0
- data/spec/integration_test/definition/server02.rb +16 -0
- data/spec/integration_test/definition/task_obj_definition.rb +49 -0
- data/spec/manage/manage_spec.rb +33 -0
- data/spec/manage/send_signal_spec.rb +39 -0
- data/spec/{ssh_shell_spec.rb → manage/ssh_shell_spec.rb} +8 -8
- data/spec/node/connection_spec.rb +66 -0
- data/spec/node/task_client_spec.rb +212 -0
- data/spec/server/acl_file_spec.rb +9 -0
- data/spec/{server_check_alive_spec.rb → server/check_alive_spec.rb} +15 -11
- data/spec/{data → server/data}/acl.txt +0 -0
- data/spec/{history_spec.rb → server/history_spec.rb} +9 -5
- data/spec/server/message_spec.rb +195 -0
- data/spec/server/node_list_spec.rb +111 -0
- data/spec/server/queue_spec.rb +239 -0
- data/spec/{server_hook_spec.rb → server/server_hook_spec.rb} +23 -17
- data/spec/server/server_spec.rb +89 -0
- data/spec/server/transfer_setting_spec.rb +37 -0
- data/spec/spec_helper.rb +65 -0
- data/spec/task/file_transfer_spec.rb +107 -0
- data/spec/{task_generator_spec.rb → task/task_generator_spec.rb} +2 -2
- data/spec/{task_spec.rb → task/task_spec.rb} +3 -1
- data/spec/utility/argument_spec.rb +39 -0
- data/spec/utility/command_line/command_base_spec.rb +33 -0
- data/spec/utility/command_line/commands_spec.rb +15 -0
- data/spec/utility/misc_spec.rb +77 -0
- data/spec/utility/server_define_spec.rb +59 -0
- data/spec/utility/temporary_spec.rb +39 -0
- metadata +158 -93
- data/example/drbqs-manage-test.rb +0 -3
- data/example/drbqs-node-test.rb +0 -3
- data/example/drbqs-server-test.rb +0 -3
- data/lib/drbqs/acl_file.rb +0 -13
- data/lib/drbqs/config.rb +0 -98
- data/lib/drbqs/connection.rb +0 -67
- data/lib/drbqs/history.rb +0 -34
- data/lib/drbqs/manage.rb +0 -84
- data/lib/drbqs/message.rb +0 -119
- data/lib/drbqs/node_list.rb +0 -52
- data/lib/drbqs/queue.rb +0 -138
- data/lib/drbqs/server_hook.rb +0 -67
- data/lib/drbqs/ssh/host.rb +0 -26
- data/lib/drbqs/ssh/shell.rb +0 -139
- data/lib/drbqs/task_client.rb +0 -86
- data/lib/drbqs/utils.rb +0 -19
- data/spec/acl_file_spec.rb +0 -9
- data/spec/config_spec.rb +0 -14
- data/spec/connection_spec.rb +0 -49
- data/spec/manage_spec.rb +0 -57
- data/spec/message_spec.rb +0 -81
- data/spec/node_list_spec.rb +0 -68
- data/spec/queue_spec.rb +0 -59
- data/spec/server_define_spec.rb +0 -45
- data/spec/server_spec.rb +0 -56
- data/spec/task_client_spec.rb +0 -53
- data/spec/test/test1.rb +0 -13
- data/spec/test1_spec.rb +0 -80
- data/spec/test2_spec.rb +0 -69
- data/spec/transfer_spec.rb +0 -13
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
|
3
|
-
require 'drbqs/
|
|
3
|
+
require 'drbqs/manage/ssh_shell'
|
|
4
4
|
|
|
5
|
-
describe DRbQS::SSHShell do
|
|
5
|
+
describe DRbQS::Manage::SSHShell do
|
|
6
6
|
it "should split destination" do
|
|
7
|
-
ssh = DRbQS::SSHShell.new('user@hostname')
|
|
7
|
+
ssh = DRbQS::Manage::SSHShell.new('user@hostname')
|
|
8
8
|
ssh.user.should == 'user'
|
|
9
9
|
ssh.host.should == 'hostname'
|
|
10
10
|
ssh.port.should be_nil
|
|
@@ -12,7 +12,7 @@ describe DRbQS::SSHShell do
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it "should split destination including directory" do
|
|
15
|
-
ssh = DRbQS::SSHShell.new('user@hostname:22', :dir => '/path/to/directory')
|
|
15
|
+
ssh = DRbQS::Manage::SSHShell.new('user@hostname:22', :dir => '/path/to/directory')
|
|
16
16
|
ssh.user.should == 'user'
|
|
17
17
|
ssh.host.should == 'hostname'
|
|
18
18
|
ssh.port.should == 22
|
|
@@ -21,19 +21,19 @@ describe DRbQS::SSHShell do
|
|
|
21
21
|
|
|
22
22
|
it "should raise error: not include '@'" do
|
|
23
23
|
lambda do
|
|
24
|
-
DRbQS::SSHShell.new('userhostname')
|
|
24
|
+
DRbQS::Manage::SSHShell.new('userhostname')
|
|
25
25
|
end.should raise_error
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it "should raise error: empty user name" do
|
|
29
29
|
lambda do
|
|
30
|
-
DRbQS::SSHShell.new('@hostname')
|
|
30
|
+
DRbQS::Manage::SSHShell.new('@hostname')
|
|
31
31
|
end.should raise_error
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "should raise error: empty host name" do
|
|
35
35
|
lambda do
|
|
36
|
-
DRbQS::SSHShell.new('user:22')
|
|
36
|
+
DRbQS::Manage::SSHShell.new('user:22')
|
|
37
37
|
end.should raise_error
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/node/connection.rb'
|
|
4
|
+
|
|
5
|
+
describe DRbQS::Node::Connection do
|
|
6
|
+
before(:all) do
|
|
7
|
+
@message = Rinda::TupleSpace.new
|
|
8
|
+
@connection = DRbQS::Node::Connection.new(@message)
|
|
9
|
+
@node_id = 23
|
|
10
|
+
@message.write([@connection.id, @node_id])
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should get node ID." do
|
|
14
|
+
@connection.node_number.should == @node_id
|
|
15
|
+
@message.take([:server, :connect, nil], 0).should be_true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should get no initialization method." do
|
|
19
|
+
@connection.get_initialization.should be_nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should get initialization." do
|
|
23
|
+
ary = [:initialize, [1, 2], :size, []]
|
|
24
|
+
@message.write(ary)
|
|
25
|
+
@connection.get_initialization.should == ary[1..-1]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should get no finalization method." do
|
|
29
|
+
@connection.get_finalization.should be_nil
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should get finalization." do
|
|
33
|
+
ary = [:finalize, [1, 2], :size, []]
|
|
34
|
+
@message.write(ary)
|
|
35
|
+
@connection.get_finalization.should == ary[1..-1]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should raise error for invalid signal." do
|
|
39
|
+
@message.write([@node_id, :alive_p])
|
|
40
|
+
@connection.respond_signal
|
|
41
|
+
@message.take([:server, :alive, nil], 0).should be_true
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should respond :alive_p signal" do
|
|
45
|
+
@message.write([@node_id, :invalid])
|
|
46
|
+
lambda do
|
|
47
|
+
@connection.respond_signal
|
|
48
|
+
end.should raise_error
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
[:exit, :finalize, :exit_after_task].each do |sym|
|
|
52
|
+
it "should respond #{sym} signal" do
|
|
53
|
+
@message.write([@node_id, sym])
|
|
54
|
+
@connection.respond_signal.should == sym
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should send node error message." do
|
|
59
|
+
err_mes = "Node Error"
|
|
60
|
+
@connection.send_node_error(err_mes)
|
|
61
|
+
ary = @message.take([:server, :node_error, Array])
|
|
62
|
+
ary[2][0].should == @node_id
|
|
63
|
+
ary[2][1].should == err_mes
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/node/task_client'
|
|
4
|
+
|
|
5
|
+
describe DRbQS::Node::TaskClient do
|
|
6
|
+
def init_task_client(node_number = 10)
|
|
7
|
+
@node_number = node_number
|
|
8
|
+
@ts_queue = Rinda::TupleSpace.new
|
|
9
|
+
@ts_result = Rinda::TupleSpace.new
|
|
10
|
+
@task_client = DRbQS::Node::TaskClient.new(@node_number, @ts_queue, @ts_result)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def add_task_to_tuplespace(task_id, task_ary)
|
|
14
|
+
@ts_queue.write([task_id] + task_ary)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def check_empty_queue_tuplespace
|
|
18
|
+
@ts_queue.read_all([nil, nil, nil, nil]).size.should == 0
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
subject do
|
|
22
|
+
@task_client
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context "when we get initial task client" do
|
|
26
|
+
before(:all) do
|
|
27
|
+
init_task_client
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should have empty task queue." do
|
|
31
|
+
subject.task_empty?.should be_true
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should have empty result queue." do
|
|
35
|
+
subject.result_empty?.should be_true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should not have calculating task." do
|
|
39
|
+
subject.calculating_task.should be_nil
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should return no task" do
|
|
43
|
+
subject.get_task.should be_nil
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context "when getting task" do
|
|
48
|
+
before(:all) do
|
|
49
|
+
init_task_client
|
|
50
|
+
@task_id = 3
|
|
51
|
+
@task_ary = ["hello world", :size, []]
|
|
52
|
+
add_task_to_tuplespace(@task_id, @task_ary)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should return task" do
|
|
56
|
+
subject.get_task.should == @task_ary.dup.unshift(@task_id)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "should take out task from tuplespace." do
|
|
60
|
+
check_empty_queue_tuplespace
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context "when adding new task" do
|
|
65
|
+
before(:all) do
|
|
66
|
+
init_task_client(7)
|
|
67
|
+
@task_id = 3
|
|
68
|
+
@task_ary = [[1, 3, 5, 7], :size, []]
|
|
69
|
+
add_task_to_tuplespace(@task_id, @task_ary)
|
|
70
|
+
subject.add_new_task
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should have non empty task queue." do
|
|
74
|
+
subject.task_empty?.should_not be_true
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should have empty result queue." do
|
|
78
|
+
subject.result_empty?.should be_true
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should have calculating task" do
|
|
82
|
+
subject.calculating_task.should == @task_id
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should take out task from tuplespace." do
|
|
86
|
+
check_empty_queue_tuplespace
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "should get :accept signal." do
|
|
90
|
+
@ts_result.take([:accept, nil, nil], 0).should == [:accept, @task_id, subject.node_number]
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
context "when dequeueing a task" do
|
|
95
|
+
before(:all) do
|
|
96
|
+
init_task_client(14)
|
|
97
|
+
@task_id = 8
|
|
98
|
+
@task_ary = [[1, 3, 5, 7], :size, []]
|
|
99
|
+
add_task_to_tuplespace(@task_id, @task_ary)
|
|
100
|
+
subject.add_new_task
|
|
101
|
+
@dequeued_task = subject.dequeue_task
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "should get a task" do
|
|
105
|
+
@dequeued_task.should == @task_ary
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "should have empty task queue." do
|
|
109
|
+
subject.task_empty?.should be_true
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "should have empty result queue." do
|
|
113
|
+
subject.result_empty?.should be_true
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it "should have calculating task." do
|
|
117
|
+
subject.calculating_task.should == @task_id
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
context "when queueing result" do
|
|
122
|
+
before(:all) do
|
|
123
|
+
init_task_client(2)
|
|
124
|
+
@task_id = 27
|
|
125
|
+
@task_ary = ["abcdef", :size, []]
|
|
126
|
+
add_task_to_tuplespace(@task_id, @task_ary)
|
|
127
|
+
subject.add_new_task
|
|
128
|
+
@dequeued_task = subject.dequeue_task
|
|
129
|
+
subject.queue_result(:result_object)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it "should have empty task queue." do
|
|
133
|
+
subject.task_empty?.should be_true
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it "should have non empty result queue." do
|
|
137
|
+
subject.result_empty?.should_not be_true
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "should have calculating task." do
|
|
141
|
+
subject.calculating_task.should == @task_id
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
context "when sending result" do
|
|
146
|
+
before(:all) do
|
|
147
|
+
init_task_client(2)
|
|
148
|
+
@task_id = 27
|
|
149
|
+
@task_ary = ["abcdef", :size, []]
|
|
150
|
+
add_task_to_tuplespace(@task_id, @task_ary)
|
|
151
|
+
subject.add_new_task
|
|
152
|
+
@dequeued_task = subject.dequeue_task
|
|
153
|
+
subject.queue_result(:result_object)
|
|
154
|
+
@send_returned_value = subject.send_result
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
it "should get nil returned value." do
|
|
158
|
+
@send_returned_value.should be_nil
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it "should have empty task queue." do
|
|
162
|
+
subject.task_empty?.should be_true
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
it "should have empty result queue." do
|
|
166
|
+
subject.result_empty?.should_not be_nil
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it "should not have calculating task." do
|
|
170
|
+
subject.calculating_task.should be_nil
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it "should get result from tuplespace." do
|
|
174
|
+
@ts_result.take([:result, nil, nil, nil], 0).should be_true
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
context "when setting exit_after_task" do
|
|
179
|
+
before(:all) do
|
|
180
|
+
init_task_client(2)
|
|
181
|
+
@task_id = 27
|
|
182
|
+
@task_ary = ["abcdef", :size, []]
|
|
183
|
+
add_task_to_tuplespace(@task_id, @task_ary)
|
|
184
|
+
subject.add_new_task
|
|
185
|
+
subject.set_exit_after_task
|
|
186
|
+
@dequeued_task = subject.dequeue_task
|
|
187
|
+
subject.queue_result(:result_object)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it "should return true" do
|
|
191
|
+
subject.send_result.should be_true
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
context "when dumping result queue" do
|
|
196
|
+
before(:all) do
|
|
197
|
+
init_task_client(2)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
it "should return nil for empty result queue." do
|
|
201
|
+
subject.dump_result_queue.should be_nil
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
it "should return string for non empty result queue." do
|
|
205
|
+
results = [:result_object1, :result_object2]
|
|
206
|
+
results.each do |sym|
|
|
207
|
+
subject.queue_result(sym)
|
|
208
|
+
end
|
|
209
|
+
subject.dump_result_queue.should == Marshal.dump(results)
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
require 'drbqs/server/acl_file'
|
|
3
|
+
|
|
4
|
+
describe DRbQS::Server::ACLFile do
|
|
5
|
+
it "should return an ACL object" do
|
|
6
|
+
acl = DRbQS::Server::ACLFile.load(File.dirname(__FILE__) + '/data/acl.txt')
|
|
7
|
+
acl.should be_an_instance_of ACL
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
|
3
|
-
require 'drbqs/server'
|
|
3
|
+
require 'drbqs/server/check_alive'
|
|
4
4
|
|
|
5
|
-
describe DRbQS::CheckAlive do
|
|
5
|
+
describe DRbQS::Server::CheckAlive do
|
|
6
6
|
it "should raise error with not a number" do
|
|
7
7
|
lambda do
|
|
8
|
-
DRbQS::CheckAlive.new('abc')
|
|
8
|
+
DRbQS::Server::CheckAlive.new('abc')
|
|
9
9
|
end.should raise_error
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
it "should raise error with a minus number" do
|
|
13
13
|
lambda do
|
|
14
|
-
DRbQS::CheckAlive.new(-10)
|
|
14
|
+
DRbQS::Server::CheckAlive.new(-10)
|
|
15
15
|
end.should raise_error
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "should return true" do
|
|
19
|
-
check = DRbQS::CheckAlive.new(0.
|
|
20
|
-
sleep(0.
|
|
19
|
+
check = DRbQS::Server::CheckAlive.new(0.01)
|
|
20
|
+
sleep(0.03)
|
|
21
21
|
check.significant_interval?.should be_true
|
|
22
|
-
check.set_checking
|
|
23
|
-
sleep(0.01)
|
|
24
|
-
check.significant_interval?.should be_false
|
|
25
22
|
end
|
|
26
23
|
|
|
27
24
|
it "should return false" do
|
|
28
|
-
check = DRbQS::CheckAlive.new(100)
|
|
25
|
+
check = DRbQS::Server::CheckAlive.new(100)
|
|
26
|
+
check.significant_interval?.should be_false
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should set checking" do
|
|
30
|
+
check = DRbQS::Server::CheckAlive.new(0.1)
|
|
31
|
+
sleep(0.2)
|
|
32
|
+
check.set_checking
|
|
29
33
|
check.significant_interval?.should be_false
|
|
30
34
|
end
|
|
31
35
|
end
|
|
File without changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
|
|
3
|
-
require 'drbqs/history'
|
|
3
|
+
require 'drbqs/server/history'
|
|
4
4
|
|
|
5
|
-
describe DRbQS::History do
|
|
5
|
+
describe DRbQS::Server::History do
|
|
6
6
|
|
|
7
7
|
def check_event(event, *vals)
|
|
8
8
|
event[0].should be_an_instance_of Time
|
|
@@ -13,7 +13,7 @@ describe DRbQS::History do
|
|
|
13
13
|
|
|
14
14
|
context "when setting events" do
|
|
15
15
|
before(:all) do
|
|
16
|
-
@history = DRbQS::History.new
|
|
16
|
+
@history = DRbQS::Server::History.new
|
|
17
17
|
@history.set(1, :abc)
|
|
18
18
|
@history.set(1, :def)
|
|
19
19
|
@history.set(2, 'ABC', 'DEF')
|
|
@@ -55,10 +55,14 @@ describe DRbQS::History do
|
|
|
55
55
|
events = @history.events(3)
|
|
56
56
|
check_event(events[0], :ghi)
|
|
57
57
|
end
|
|
58
|
+
|
|
59
|
+
it "should return strings of log" do
|
|
60
|
+
@history.log_strings.should be_an_instance_of String
|
|
61
|
+
end
|
|
58
62
|
end
|
|
59
63
|
|
|
60
64
|
context "when executing a method" do
|
|
61
|
-
subject { DRbQS::History.new }
|
|
65
|
+
subject { DRbQS::Server::History.new }
|
|
62
66
|
|
|
63
67
|
it "should add new event" do
|
|
64
68
|
id = 1
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/server/message.rb'
|
|
4
|
+
require 'drbqs/task/task'
|
|
5
|
+
|
|
6
|
+
describe DRbQS::Server::Message do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@message = Rinda::TupleSpace.new
|
|
9
|
+
@message_server = DRbQS::Server::Message.new(@message)
|
|
10
|
+
@node_list = @message_server.instance_variable_get(:@node_list)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def set_nodes(num)
|
|
14
|
+
num.times do |i|
|
|
15
|
+
id_str = "connect_test_#{i}"
|
|
16
|
+
@message.write([:server, :connect, id_str])
|
|
17
|
+
@message_server.get_message.should == [:connect]
|
|
18
|
+
id_str_reply, id_num = @message.take([id_str, nil])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def clear_all_node
|
|
23
|
+
@message_server.get_all_nodes.each do |id_num, id_str|
|
|
24
|
+
@node_list.delete(id_num)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "when getting messages" do
|
|
29
|
+
it "should return nil" do
|
|
30
|
+
@message_server.get_message.should be_nil
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should get :connect message" do
|
|
34
|
+
5.times do |i|
|
|
35
|
+
id_str = "connect_test_#{i}"
|
|
36
|
+
@message.write([:server, :connect, id_str])
|
|
37
|
+
@message_server.get_message.should == [:connect]
|
|
38
|
+
id_str_reply, id_num = @message.take([id_str, nil])
|
|
39
|
+
id_num.should > 0
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should get :alive message" do
|
|
44
|
+
node_id = 73
|
|
45
|
+
@message.write([:server, :alive, node_id])
|
|
46
|
+
@node_list.should_receive(:set_alive).with(node_id)
|
|
47
|
+
@message_server.get_message.should == [:alive]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should get :exit_server message" do
|
|
51
|
+
@message.write([:server, :exit_server, 'message_test'])
|
|
52
|
+
@message_server.get_message.should == [:exit_server]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should get :exit_after_task message" do
|
|
56
|
+
@message.write([:server, :exit_after_task, 1])
|
|
57
|
+
@message_server.get_message.should == [:exit_after_task, 1]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should get :request_status message" do
|
|
61
|
+
@message.write([:server, :request_status, 'message_test'])
|
|
62
|
+
@message_server.get_message.should == [:request_status]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "should get :node_error message" do
|
|
66
|
+
node_id = 74
|
|
67
|
+
@message.write([:server, :node_error, [node_id, 'Error occurs.']])
|
|
68
|
+
@node_list.should_receive(:delete).with(node_id)
|
|
69
|
+
@message_server.get_message.should == [:node_error, node_id]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should return nil for invalid message" do
|
|
73
|
+
@message.write([:server, :invalid_message])
|
|
74
|
+
@message_server.get_message.should be_nil
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
after(:all) do
|
|
78
|
+
clear_all_node
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
context "when sending messages" do
|
|
83
|
+
before(:all) do
|
|
84
|
+
set_nodes(5)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should send exit message" do
|
|
88
|
+
@message_server.send_exit
|
|
89
|
+
@message_server.get_all_nodes.each do |id_num, id_str|
|
|
90
|
+
@message.take([id_num, :exit]).should be_true
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "should send finalization message" do
|
|
95
|
+
@message_server.send_finalization
|
|
96
|
+
@message_server.get_all_nodes.each do |id_num, id_str|
|
|
97
|
+
@message.take([id_num, :finalize]).should be_true
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should send exit_after_task message" do
|
|
102
|
+
id = @message_server.get_all_nodes.to_a[0][0]
|
|
103
|
+
@message_server.send_exit_after_task(id)
|
|
104
|
+
@message.take([id, :exit_after_task]).should be_true
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "should send status" do
|
|
108
|
+
@message_server.send_status({})
|
|
109
|
+
sym, status = @message.take([:status, nil])
|
|
110
|
+
status.should be_an_instance_of String
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
after(:all) do
|
|
114
|
+
clear_all_node
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
context "when setting special tasks" do
|
|
119
|
+
it "should set initialization task" do
|
|
120
|
+
lambda do
|
|
121
|
+
@message.take([:initialize, nil, Symbol, nil], 0)
|
|
122
|
+
end.should raise_error Rinda::RequestExpiredError
|
|
123
|
+
@message_server.set_initialization(DRbQS::Task.new(Object.new, :object_id))
|
|
124
|
+
@message.take([:initialize, nil, Symbol, nil], 0).should be_true
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "should set finalization task" do
|
|
128
|
+
lambda do
|
|
129
|
+
@message.take([:finalization, nil, Symbol, nil], 0)
|
|
130
|
+
end.should raise_error Rinda::RequestExpiredError
|
|
131
|
+
@message_server.set_finalization(DRbQS::Task.new(Object.new, :object_id))
|
|
132
|
+
@message.take([:finalization, nil, Symbol, nil], 0).should be_true
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
context "when checking existence of nodes" do
|
|
137
|
+
before(:all) do
|
|
138
|
+
clear_all_node
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it "should return a hash" do
|
|
142
|
+
@message_server.get_all_nodes.should be_an_instance_of Hash
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it "should have no node" do
|
|
146
|
+
@message_server.node_not_exist?.should be_true
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it "should return nil" do
|
|
150
|
+
# Minus ID is invalid. So the node of the ID does not exist.
|
|
151
|
+
@message_server.node_exist?(-100).should_not be_true
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it "should return true" do
|
|
155
|
+
id_str = "checking_node"
|
|
156
|
+
@message.write([:server, :connect, id_str])
|
|
157
|
+
@message_server.get_message.should == [:connect]
|
|
158
|
+
id_str_reply, id_num = @message.take([id_str, nil])
|
|
159
|
+
@message_server.node_exist?(id_num).should be_true
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
after(:all) do
|
|
163
|
+
clear_all_node
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
context "when checking connection" do
|
|
168
|
+
before(:all) do
|
|
169
|
+
set_nodes(5)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
it "should send :alive_p message" do
|
|
173
|
+
@message_server.check_connection.should == []
|
|
174
|
+
@message_server.get_all_nodes.each do |id_num, id_str|
|
|
175
|
+
@message.take([id_num, :alive_p]).should be_true
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
it "should delete nodes" do
|
|
180
|
+
node_id_list = @message_server.get_all_nodes.to_a.map do |ary|
|
|
181
|
+
ary[0]
|
|
182
|
+
end.sort
|
|
183
|
+
@message_server.check_connection.sort.should == node_id_list
|
|
184
|
+
node_id_list.each do |id_num|
|
|
185
|
+
lambda do
|
|
186
|
+
@message.take([id_num, :alive_p], 0)
|
|
187
|
+
end.should raise_error Rinda::RequestExpiredError
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
after(:all) do
|
|
192
|
+
clear_all_node
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|