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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/config/config'
|
|
4
|
+
|
|
5
|
+
describe DRbQS::ProcessList::Server do
|
|
6
|
+
before(:all) do
|
|
7
|
+
@dir = File.join(File.dirname(__FILE__), 'tmp_process_list/server')
|
|
8
|
+
FileUtils.mkdir_p(@dir)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
subject do
|
|
12
|
+
DRbQS::ProcessList::Server.new(@dir)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should save data" do
|
|
16
|
+
uri = 'druby://:13000'
|
|
17
|
+
h = { :pid => 1111 }
|
|
18
|
+
subject.save(uri, h)
|
|
19
|
+
subject.get(uri).should == h
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should return list of server." do
|
|
23
|
+
uri = 'druby://:13001'
|
|
24
|
+
h = { :pid => 1234 }
|
|
25
|
+
subject.save(uri, h)
|
|
26
|
+
list = subject.list
|
|
27
|
+
list.should be_an_instance_of Hash
|
|
28
|
+
list[uri].should == h
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should delete." do
|
|
32
|
+
uri = 'druby://:13002'
|
|
33
|
+
h = { :pid => 2222 }
|
|
34
|
+
subject.save(uri, h)
|
|
35
|
+
subject.delete(uri)
|
|
36
|
+
subject.get(uri).should be_nil
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should get from uri." do
|
|
40
|
+
h = { :pid => 1111 }
|
|
41
|
+
subject.save('druby://:13003', h)
|
|
42
|
+
subject.get('druby://example.com:13003').should == h
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should have server of key." do
|
|
46
|
+
subject.save('druby://:13004', { :key => 'key1' })
|
|
47
|
+
subject.server_of_key_exist?('druby://example.com:13004', 'key1').should be_true
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should not have server of key." do
|
|
51
|
+
subject.save('druby://:13005', { :key => 'key2' })
|
|
52
|
+
subject.server_of_key_exist?('druby://example.com:13005', 'invalid_key').should be_false
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should not have server." do
|
|
56
|
+
subject.delete('druby://:13005')
|
|
57
|
+
subject.server_of_key_exist?('druby://example.com:13006', 'key').should be_false
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should clear server data that does not exist." do
|
|
61
|
+
uri = 'druby://:13006'
|
|
62
|
+
subject.save(uri, { :pid => 1 })
|
|
63
|
+
subject.should_receive(:delete).at_least(:once)
|
|
64
|
+
subject.clear_process_not_exist
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
after(:all) do
|
|
68
|
+
FileUtils.rm_r(@dir)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe DRbQS::ProcessList::Node do
|
|
74
|
+
before(:all) do
|
|
75
|
+
@dir = File.join(File.dirname(__FILE__), 'tmp_process_list/node')
|
|
76
|
+
FileUtils.mkdir_p(@dir)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
subject do
|
|
80
|
+
DRbQS::ProcessList::Node.new(@dir)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "should save data" do
|
|
84
|
+
pid = 10000
|
|
85
|
+
h = { :uri => 'druby://:13000' }
|
|
86
|
+
subject.save(pid, h)
|
|
87
|
+
subject.get(pid).should == h
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "should return list of server." do
|
|
91
|
+
pid = 10001
|
|
92
|
+
h = { :uri => 'druby://:13001' }
|
|
93
|
+
subject.save(pid, h)
|
|
94
|
+
list = subject.list
|
|
95
|
+
list.should be_an_instance_of Hash
|
|
96
|
+
list[pid].should == h
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "should delete." do
|
|
100
|
+
pid = 10002
|
|
101
|
+
h = { :uri => 'druby://:13002' }
|
|
102
|
+
subject.save(pid, h)
|
|
103
|
+
subject.delete(pid)
|
|
104
|
+
subject.get(pid).should be_nil
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "should clear node data that does not exist." do
|
|
108
|
+
pid = 10003
|
|
109
|
+
h = { :uri => 'druby://:13003' }
|
|
110
|
+
subject.save(pid, h)
|
|
111
|
+
subject.should_receive(:delete).at_least(:once)
|
|
112
|
+
subject.clear_process_not_exist
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
after(:all) do
|
|
116
|
+
FileUtils.rm_r(@dir)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
describe DRbQS::ProcessList do
|
|
122
|
+
before(:all) do
|
|
123
|
+
@dir = File.join(File.dirname(__FILE__), 'tmp_process_list')
|
|
124
|
+
FileUtils.mkdir_p(@dir)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
subject do
|
|
128
|
+
DRbQS::ProcessList.new(@dir)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it "should create directory." do
|
|
132
|
+
subject
|
|
133
|
+
hostname = Socket.gethostname
|
|
134
|
+
File.exist?(File.join(@dir, 'process')).should be_true
|
|
135
|
+
File.exist?(File.join(@dir, 'process', 'server', hostname)).should be_true
|
|
136
|
+
File.exist?(File.join(@dir, 'process', 'node', hostname)).should be_true
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it "should execute clear data of which process does not exist." do
|
|
140
|
+
subject.node.should_receive(:clear_process_not_exist)
|
|
141
|
+
subject.server.should_receive(:clear_process_not_exist)
|
|
142
|
+
subject.clear_process_not_exist
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
after(:all) do
|
|
146
|
+
FileUtils.rm_r(@dir)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/config/config'
|
|
4
|
+
require 'drbqs/utility/temporary'
|
|
5
|
+
|
|
6
|
+
describe DRbQS::Config::SSHHost do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@dir = DRbQS::Temporary.directory
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
subject do
|
|
12
|
+
DRbQS::Config::SSHHost.new(@dir)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return empty data" do
|
|
16
|
+
subject.get_options('host0').should == [nil, {}]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should return path with extension '\.yaml'." do
|
|
20
|
+
path = File.join(@dir, 'host1.yaml')
|
|
21
|
+
data = { :abc => 123 }
|
|
22
|
+
open(path, 'w') do |f|
|
|
23
|
+
f.print YAML.dump(data)
|
|
24
|
+
end
|
|
25
|
+
ary = subject.get_options('host1')
|
|
26
|
+
ary[0].should == path
|
|
27
|
+
ary[1].should == data
|
|
28
|
+
FileUtils.rm(path)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should return path with extension '\.yml'." do
|
|
32
|
+
path = File.join(@dir, 'host2.yml')
|
|
33
|
+
data = { :abc => 123 }
|
|
34
|
+
open(path, 'w') do |f|
|
|
35
|
+
f.print YAML.dump(data)
|
|
36
|
+
end
|
|
37
|
+
ary = subject.get_options('host2')
|
|
38
|
+
ary[0].should == path
|
|
39
|
+
ary[1].should == data
|
|
40
|
+
FileUtils.rm(path)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should return nil for invalid extension." do
|
|
44
|
+
path = File.join(@dir, 'host3.txt')
|
|
45
|
+
data = { :abc => 123 }
|
|
46
|
+
open(path, 'w') do |f|
|
|
47
|
+
f.print YAML.dump(data)
|
|
48
|
+
end
|
|
49
|
+
subject.get_options('host3').should == [nil, {}]
|
|
50
|
+
FileUtils.rm(path)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should return list of names." do
|
|
54
|
+
names = ['name1', 'name2', 'name3']
|
|
55
|
+
files = names.map do |n|
|
|
56
|
+
File.join(@dir, n + '.yaml')
|
|
57
|
+
end
|
|
58
|
+
data = { :abc => 123 }
|
|
59
|
+
files.each do |path|
|
|
60
|
+
open(path, 'w') do |f|
|
|
61
|
+
f.print YAML.dump(data)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
subject.config_names.should == names.sort
|
|
65
|
+
FileUtils.rm(files)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should return only path." do
|
|
69
|
+
path = File.join(@dir, 'host4.yml')
|
|
70
|
+
data = { :abc => 123 }
|
|
71
|
+
open(path, 'w') do |f|
|
|
72
|
+
f.print YAML.dump(data)
|
|
73
|
+
end
|
|
74
|
+
subject.get_path('host4').should == path
|
|
75
|
+
FileUtils.rm(path)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
after(:all) do
|
|
79
|
+
DRbQS::Temporary.delete_all
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/task/task'
|
|
4
|
+
require_relative 'definition/task_obj_definition.rb'
|
|
5
|
+
|
|
6
|
+
describe DRbQS do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@tasks = 5.times.map do |i|
|
|
9
|
+
DRbQS::Task.new(Test1.new, :echo, [i])
|
|
10
|
+
end
|
|
11
|
+
@process_id, @uri = drbqs_fork_server(13501, @tasks)
|
|
12
|
+
@node = DRbQS::Node.new(@uri, :log_file => $stdout, :continue => true)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should have nil instance variables" do
|
|
16
|
+
@node.instance_variable_get(:@task_client).should be_nil
|
|
17
|
+
@node.instance_variable_get(:@connection).should be_nil
|
|
18
|
+
@node.connect
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should initialize @task_client" do
|
|
22
|
+
task_node = @node.instance_variable_get(:@task_client)
|
|
23
|
+
task_node.should be_an_instance_of DRbQS::Node::TaskClient
|
|
24
|
+
task_node.node_number.should be_an_instance_of Fixnum
|
|
25
|
+
task_node.task_empty?.should be_true
|
|
26
|
+
task_node.result_empty?.should be_true
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should initialize @connection" do
|
|
30
|
+
connection = @node.instance_eval { @connection }
|
|
31
|
+
connection.should be_an_instance_of DRbQS::Node::Connection
|
|
32
|
+
connection.node_number.should be_an_instance_of Fixnum
|
|
33
|
+
connection.id.should be_an_instance_of String
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should calculate" do
|
|
37
|
+
task_node = @node.instance_eval { @task_node }
|
|
38
|
+
# *** Too late ***
|
|
39
|
+
# task_node.should_receive(:add_new_task).at_least(:once)
|
|
40
|
+
# task_node.should_receive(:transit).exactly(5).times
|
|
41
|
+
# task_node.should_receive(:send_result).exactly(5).times
|
|
42
|
+
lambda do
|
|
43
|
+
@node.calculate
|
|
44
|
+
end.should_not raise_error
|
|
45
|
+
Test1.get_execute_echo_number.should == @tasks.size
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
after(:all) do
|
|
49
|
+
lambda do
|
|
50
|
+
drbqs_wait_kill_server(@process_id)
|
|
51
|
+
end.should_not raise_error
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/task/task'
|
|
4
|
+
require_relative 'definition/task_obj_definition.rb'
|
|
5
|
+
|
|
6
|
+
describe DRbQS do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@task_generators = [DRbQS::TaskGenerator.new(:iterate => 3), DRbQS::TaskGenerator.new(:iterate => 4)]
|
|
9
|
+
@task_generators.each do |tg|
|
|
10
|
+
tg.set do
|
|
11
|
+
@iterate.times do |i|
|
|
12
|
+
create_add_task(Test1.new, :echo, [i])
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
@process_id, @uri = drbqs_fork_server(13501, @task_generators)
|
|
17
|
+
@node = DRbQS::Node.new(@uri, :log_file => $stdout, :continue => true)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should have nil instance variables" do
|
|
21
|
+
@node.instance_variable_get(:@task_client).should be_nil
|
|
22
|
+
@node.instance_variable_get(:@connection).should be_nil
|
|
23
|
+
@node.connect
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should initialize @task_client" do
|
|
27
|
+
task_client = @node.instance_variable_get(:@task_client)
|
|
28
|
+
task_client.should be_an_instance_of DRbQS::Node::TaskClient
|
|
29
|
+
task_client.node_number.should be_an_instance_of Fixnum
|
|
30
|
+
task_client.task_empty?.should be_true
|
|
31
|
+
task_client.result_empty?.should be_true
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should initialize @connection" do
|
|
35
|
+
connection = @node.instance_eval { @connection }
|
|
36
|
+
connection.should be_an_instance_of DRbQS::Node::Connection
|
|
37
|
+
connection.node_number.should be_an_instance_of Fixnum
|
|
38
|
+
connection.id.should be_an_instance_of String
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should calculate" do
|
|
42
|
+
lambda do
|
|
43
|
+
@node.calculate
|
|
44
|
+
end.should_not raise_error
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
after(:all) do
|
|
48
|
+
lambda do
|
|
49
|
+
drbqs_wait_kill_server(@process_id)
|
|
50
|
+
end.should_not raise_error
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/task/task'
|
|
4
|
+
require_relative 'definition/task_obj_definition.rb'
|
|
5
|
+
|
|
6
|
+
describe DRbQS do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@tasks = [DRbQS::Task.new(Test3.new, :temp_file)]
|
|
9
|
+
@process_id, @uri = drbqs_fork_server(13503, @tasks)
|
|
10
|
+
@node = DRbQS::Node.new(@uri, :log_file => $stdout, :continue => true)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should initialize @task_client" do
|
|
14
|
+
lambda do
|
|
15
|
+
@node.connect
|
|
16
|
+
@node.calculate
|
|
17
|
+
end.should_not raise_error
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
after(:all) do
|
|
21
|
+
lambda do
|
|
22
|
+
drbqs_wait_kill_server(@process_id)
|
|
23
|
+
end.should_not raise_error
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs'
|
|
4
|
+
require_relative 'definition/task_obj_definition.rb'
|
|
5
|
+
|
|
6
|
+
describe DRbQS::Server do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@tasks = 2.times.map do |i|
|
|
9
|
+
DRbQS::Task.new(Test1.new, :echo, [i])
|
|
10
|
+
end
|
|
11
|
+
path = "/tmp/drbqs"
|
|
12
|
+
@process_id, @uri = drbqs_fork_server(path, @tasks)
|
|
13
|
+
@manage = DRbQS::Manage.new(:uri => @uri)
|
|
14
|
+
@node = DRbQS::Node.new(@uri, :log_file => $stdout, :continue => true)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should send signal and get status" do
|
|
18
|
+
@manage.get_status.should be_true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should calculate task" do
|
|
22
|
+
@node.connect
|
|
23
|
+
lambda do
|
|
24
|
+
@node.calculate
|
|
25
|
+
end.should_not raise_error
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
after(:all) do
|
|
29
|
+
lambda do
|
|
30
|
+
drbqs_wait_kill_server(@process_id)
|
|
31
|
+
end.should_not raise_error
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/task/task'
|
|
4
|
+
require_relative 'definition/task_obj_definition.rb'
|
|
5
|
+
|
|
6
|
+
describe DRbQS do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@tasks = 3.times.map do |i|
|
|
9
|
+
DRbQS::Task.new(Test1.new, :echo, [i])
|
|
10
|
+
end
|
|
11
|
+
@process_id, @uri = drbqs_fork_server(13501, @tasks)
|
|
12
|
+
@manage = DRbQS::Manage.new(:uri => @uri)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should send exit signal" do
|
|
16
|
+
lambda do
|
|
17
|
+
@manage.send_exit_signal
|
|
18
|
+
end.should_not raise_error
|
|
19
|
+
lambda do
|
|
20
|
+
drbqs_wait_kill_server(@process_id)
|
|
21
|
+
end.should_not raise_error
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/manage/execute_node'
|
|
4
|
+
require_relative 'definition/task_obj_definition.rb'
|
|
5
|
+
|
|
6
|
+
describe DRbQS::Server do
|
|
7
|
+
before(:all) do
|
|
8
|
+
@wait = 2
|
|
9
|
+
@tasks = 10.times.map do |i|
|
|
10
|
+
DRbQS::Task.new(Test2.new, :echo_wait, [@wait])
|
|
11
|
+
end
|
|
12
|
+
@server_process_id, @uri = drbqs_fork_server(13501, @tasks, :continue => true)
|
|
13
|
+
@manage = DRbQS::Manage.new(:uri => @uri)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should send node exit" do
|
|
17
|
+
execute_node = DRbQS::ExecuteNode.new(@uri, nil, nil)
|
|
18
|
+
execute_node.execute(1)
|
|
19
|
+
client_process_id = execute_node.pid[0]
|
|
20
|
+
sleep(@wait)
|
|
21
|
+
@manage.send_node_exit_after_task(1)
|
|
22
|
+
th = Process.detach(client_process_id)
|
|
23
|
+
max_wait_time = @wait * 3
|
|
24
|
+
max_wait_time.times do |i|
|
|
25
|
+
sleep(1)
|
|
26
|
+
unless th.alive?
|
|
27
|
+
break
|
|
28
|
+
end
|
|
29
|
+
if i == (max_wait_time - 1)
|
|
30
|
+
raise "Client does not exit."
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
after(:all) do
|
|
36
|
+
@manage.send_exit_signal
|
|
37
|
+
lambda do
|
|
38
|
+
drbqs_wait_kill_server(@server_process_id)
|
|
39
|
+
end.should_not raise_error
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/task/task'
|
|
4
|
+
require 'drbqs/utility/command_line'
|
|
5
|
+
|
|
6
|
+
describe DRbQS do
|
|
7
|
+
context "when server is executed with nodes." do
|
|
8
|
+
it "should exit normally." do
|
|
9
|
+
@path = File.expand_path(File.join(File.dirname(__FILE__), 'definition/server01.rb'))
|
|
10
|
+
@port = 13600
|
|
11
|
+
@pid_server = fork do
|
|
12
|
+
DRbQS::CommandServer.exec([@path, '-p', @port.to_s, '--execute-node', '2'])
|
|
13
|
+
end
|
|
14
|
+
lambda do
|
|
15
|
+
i = 0
|
|
16
|
+
until exit_data = Process.waitpid2(@pid_server, Process::WNOHANG)
|
|
17
|
+
sleep(1)
|
|
18
|
+
if i > 10
|
|
19
|
+
raise "Server can not stop within 10 seconds."
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
exit_data[1].success?.should be_true
|
|
23
|
+
end.should_not raise_error
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should raise error in server." do
|
|
27
|
+
@path = File.expand_path(File.join(File.dirname(__FILE__), 'definition/server02.rb'))
|
|
28
|
+
@port = 13601
|
|
29
|
+
@pid_server = fork do
|
|
30
|
+
DRbQS::CommandServer.exec([@path, '-p', @port.to_s, '--execute-node', '2'])
|
|
31
|
+
end
|
|
32
|
+
lambda do
|
|
33
|
+
i = 0
|
|
34
|
+
until exit_data = Process.waitpid2(@pid_server, Process::WNOHANG)
|
|
35
|
+
sleep(1)
|
|
36
|
+
if i > 10
|
|
37
|
+
raise "Server can not stop within 10 seconds."
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
exit_data[1].success?.should_not be_true
|
|
41
|
+
end.should_not raise_error
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require_relative 'task_obj_definition.rb'
|
|
2
|
+
|
|
3
|
+
DRbQS.option_parser do |opt, hash|
|
|
4
|
+
hash[:step] = 1
|
|
5
|
+
opt.on('--step NUM', Integer, 'Set the step size.') do |v|
|
|
6
|
+
hash[:step] = v
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
DRbQS.define_server(:finish_exit => true) do |server, argv, opts|
|
|
11
|
+
tgen = DRbQS::TaskGenerator.new(:step => opts[:step])
|
|
12
|
+
tgen.set(:generate => 2) do
|
|
13
|
+
1.step(100, 50) do |i|
|
|
14
|
+
create_add_task(TestSum.new, :calc, [i, i + 10, @step]) do |srv, result|
|
|
15
|
+
puts result
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
server.add_task_generator(tgen)
|
|
20
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require_relative 'task_obj_definition.rb'
|
|
2
|
+
|
|
3
|
+
DRbQS.option_parser do |opt, hash|
|
|
4
|
+
hash[:step] = 1
|
|
5
|
+
opt.on('--step NUM', Integer, 'Set the step size.') do |v|
|
|
6
|
+
hash[:step] = v
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
DRbQS.define_server(:finish_exit => true) do |server, argv, opts|
|
|
11
|
+
tgen = DRbQS::TaskGenerator.new(:step => opts[:step])
|
|
12
|
+
tgen.set(:generate => 2) do
|
|
13
|
+
raise "Error raise"
|
|
14
|
+
end
|
|
15
|
+
server.add_task_generator(tgen)
|
|
16
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
class Test1
|
|
2
|
+
@@execute_echo_number = 0
|
|
3
|
+
|
|
4
|
+
def echo(*args)
|
|
5
|
+
puts "execute Test1#echo(*#{args.inspect.strip})"
|
|
6
|
+
@@execute_echo_number += 1
|
|
7
|
+
args
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.get_execute_echo_number
|
|
11
|
+
@@execute_echo_number
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Test2
|
|
16
|
+
|
|
17
|
+
def echo_wait(wait_time)
|
|
18
|
+
puts "execute Test2#echo(#{wait_time})"
|
|
19
|
+
sleep(wait_time)
|
|
20
|
+
true
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Test3
|
|
25
|
+
def temp_file
|
|
26
|
+
dir = DRbQS::Temporary.directory
|
|
27
|
+
file1 = File.join(dir, 'hello')
|
|
28
|
+
open(file1, 'w') do |f|
|
|
29
|
+
f.puts 'hello world'
|
|
30
|
+
end
|
|
31
|
+
file2 = DRbQS::Temporary.file
|
|
32
|
+
open(file2, 'w') do |f|
|
|
33
|
+
f.puts 'temporary'
|
|
34
|
+
end
|
|
35
|
+
puts File.read(file1)
|
|
36
|
+
puts File.read(file2)
|
|
37
|
+
true
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class TestSum
|
|
42
|
+
def calc(start_num, end_num, step)
|
|
43
|
+
sum = 0
|
|
44
|
+
start_num.step(end_num, step) do |i|
|
|
45
|
+
sum += i
|
|
46
|
+
end
|
|
47
|
+
sum
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/server/message.rb'
|
|
4
|
+
|
|
5
|
+
# describe DRbQS::Manage do
|
|
6
|
+
# before(:all) do
|
|
7
|
+
# @uri = "druby://:13600"
|
|
8
|
+
# @ts = drbqs_test_tuple_space(@uri)
|
|
9
|
+
# @message = DRbQS::Server::Message.new(@ts[:message])
|
|
10
|
+
# @manage = DRbQS::Manage.new
|
|
11
|
+
# end
|
|
12
|
+
|
|
13
|
+
# it "should send exit signal" do
|
|
14
|
+
# lambda do
|
|
15
|
+
# @manage.send_exit_signal(@uri)
|
|
16
|
+
# end.should_not raise_error
|
|
17
|
+
# @message.get_message.should == [:exit_server]
|
|
18
|
+
# end
|
|
19
|
+
|
|
20
|
+
# it "should send node exit signal" do
|
|
21
|
+
# node_id = 100
|
|
22
|
+
# lambda do
|
|
23
|
+
# @manage.send_node_exit_after_task(@uri, node_id)
|
|
24
|
+
# end.should_not raise_error
|
|
25
|
+
# @message.get_message.should == [:exit_after_task, node_id]
|
|
26
|
+
# end
|
|
27
|
+
|
|
28
|
+
# it "should get status" do
|
|
29
|
+
# dummy_status = "status data"
|
|
30
|
+
# @ts[:message].write([:status, dummy_status])
|
|
31
|
+
# @manage.get_status(@uri).should == dummy_status
|
|
32
|
+
# end
|
|
33
|
+
# end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
+
|
|
3
|
+
require 'drbqs/manage/manage'
|
|
4
|
+
|
|
5
|
+
describe DRbQS::Manage::SendSignal do
|
|
6
|
+
before(:all) do
|
|
7
|
+
@ts = Rinda::TupleSpace.new
|
|
8
|
+
@send_signal = DRbQS::Manage::SendSignal.new(@ts)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
subject do
|
|
12
|
+
@send_signal
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should get ID of sender." do
|
|
16
|
+
subject.sender_id.should be_an_instance_of String
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should send :exit_signal." do
|
|
20
|
+
@send_signal.send_exit_signal
|
|
21
|
+
lambda do
|
|
22
|
+
@ts.take([:server, :exit_server, @send_signal.sender_id], 0)
|
|
23
|
+
end.should_not raise_error
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should send :exit_after_task." do
|
|
27
|
+
node_id = 100
|
|
28
|
+
@send_signal.send_node_exit_after_task(node_id)
|
|
29
|
+
lambda do
|
|
30
|
+
@ts.take([:server, :exit_after_task, node_id], 0)
|
|
31
|
+
end.should_not raise_error
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should send signal to get status." do
|
|
35
|
+
mes = 'message'
|
|
36
|
+
@ts.should_receive(:take).once.and_return([:status, mes])
|
|
37
|
+
@send_signal.get_status.should == mes
|
|
38
|
+
end
|
|
39
|
+
end
|