drbqs 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/.document +3 -0
  2. data/README.md +137 -128
  3. data/VERSION +1 -1
  4. data/docs/FormatExecute.md +119 -0
  5. data/docs/GettingStarted.md +242 -0
  6. data/drbqs.gemspec +36 -13
  7. data/example/command/server_def.rb +4 -5
  8. data/example/execute/execute.rb +41 -0
  9. data/example/execute/server.rb +14 -0
  10. data/example/execute/task.rb +0 -0
  11. data/example/mandelbrot/README.md +15 -0
  12. data/example/mandelbrot/execute.rb +10 -0
  13. data/example/mandelbrot/mandelbrot.rb +56 -0
  14. data/example/mandelbrot/server.rb +49 -0
  15. data/example/server/server.rb +3 -6
  16. data/example/simple/README.md +18 -0
  17. data/example/simple/execute.rb +11 -0
  18. data/example/simple/server.rb +8 -0
  19. data/example/simple/task.rb +11 -0
  20. data/example/sum/server_def.rb +1 -1
  21. data/example/sum2/execute_def.rb +21 -8
  22. data/example/sum2/server_def.rb +8 -7
  23. data/example/transfer/file.rb +42 -8
  24. data/example/transfer/server_def.rb +43 -9
  25. data/lib/drbqs.rb +1 -1
  26. data/lib/drbqs/command_line/command_execute.rb +3 -3
  27. data/lib/drbqs/command_line/command_line.rb +1 -1
  28. data/lib/drbqs/execute/execute_node.rb +50 -0
  29. data/lib/drbqs/execute/process_define.rb +102 -54
  30. data/lib/drbqs/execute/register.rb +241 -87
  31. data/lib/drbqs/execute/server_define.rb +69 -58
  32. data/lib/drbqs/ext/task.rb +2 -0
  33. data/lib/drbqs/ext/task/command_task.rb +43 -0
  34. data/lib/drbqs/manage/manage.rb +5 -4
  35. data/lib/drbqs/manage/ssh_shell.rb +2 -8
  36. data/lib/drbqs/node/connection.rb +1 -1
  37. data/lib/drbqs/node/node.rb +8 -14
  38. data/lib/drbqs/node/task_client.rb +1 -1
  39. data/lib/drbqs/server/history.rb +5 -1
  40. data/lib/drbqs/server/message.rb +7 -34
  41. data/lib/drbqs/server/queue.rb +14 -2
  42. data/lib/drbqs/server/server.rb +86 -43
  43. data/lib/drbqs/server/server_hook.rb +3 -0
  44. data/lib/drbqs/server/test/node.rb +1 -1
  45. data/lib/drbqs/server/test/prof.rb +50 -0
  46. data/lib/drbqs/server/test/server.rb +2 -2
  47. data/lib/drbqs/server/transfer_setting.rb +23 -11
  48. data/lib/drbqs/setting/base.rb +15 -0
  49. data/lib/drbqs/setting/data_container.rb +1 -1
  50. data/lib/drbqs/setting/execute.rb +3 -3
  51. data/lib/drbqs/setting/node.rb +1 -1
  52. data/lib/drbqs/setting/server.rb +2 -2
  53. data/lib/drbqs/task/registrar.rb +39 -0
  54. data/lib/drbqs/task/task.rb +139 -59
  55. data/lib/drbqs/task/task_generator.rb +93 -116
  56. data/lib/drbqs/utility/misc.rb +15 -10
  57. data/lib/drbqs/utility/temporary.rb +7 -2
  58. data/lib/drbqs/utility/transfer/transfer.rb +81 -0
  59. data/lib/drbqs/utility/transfer/transfer_client.rb +68 -69
  60. data/lib/drbqs/utility/transfer/transfer_client_connect.rb +83 -0
  61. data/lib/drbqs/utility/transfer/transfer_file_list.rb +40 -0
  62. data/spec/execute/def/execute1.rb +4 -4
  63. data/spec/execute/def/execute2.rb +24 -0
  64. data/spec/execute/process_define_spec.rb +43 -6
  65. data/spec/execute/register_spec.rb +403 -9
  66. data/spec/execute/server_define_spec.rb +1 -1
  67. data/spec/ext/task/command_task_spec.rb +16 -0
  68. data/spec/integration_test/01_basic_usage_spec.rb +1 -1
  69. data/spec/integration_test/02_use_generator_spec.rb +2 -2
  70. data/spec/integration_test/04_use_unix_domain_spec.rb +1 -1
  71. data/spec/integration_test/05_server_exit_signal_spec.rb +1 -1
  72. data/spec/integration_test/06_node_exit_after_task_spec.rb +4 -4
  73. data/spec/integration_test/08_shutdown_unused_nodes_spec.rb +2 -2
  74. data/spec/integration_test/09_server_process_data_spec.rb +1 -1
  75. data/spec/integration_test/definition/server01.rb +4 -5
  76. data/spec/integration_test/definition/server02.rb +2 -4
  77. data/spec/node/node_spec.rb +34 -0
  78. data/spec/server/message_spec.rb +1 -1
  79. data/spec/server/queue_spec.rb +34 -7
  80. data/spec/server/server_spec.rb +21 -9
  81. data/spec/server/transfer_setting_spec.rb +59 -24
  82. data/spec/setting/base_spec.rb +11 -0
  83. data/spec/setting/data_container_spec.rb +8 -0
  84. data/spec/spec_helper.rb +1 -7
  85. data/spec/task/registrar_spec.rb +34 -0
  86. data/spec/task/task_generator_spec.rb +15 -15
  87. data/spec/task/task_spec.rb +132 -23
  88. data/spec/utility/misc_spec.rb +2 -2
  89. data/spec/utility/transfer/transfer_client_connect_spec.rb +90 -0
  90. data/spec/utility/transfer/transfer_file_list_spec.rb +27 -0
  91. data/spec/{task/file_transfer_spec.rb → utility/transfer/transfer_spec.rb} +24 -24
  92. metadata +66 -45
  93. data/lib/drbqs/manage/execute_node.rb +0 -50
  94. data/lib/drbqs/server/prof.rb +0 -48
  95. data/lib/drbqs/task/command_task.rb +0 -43
  96. data/lib/drbqs/utility/transfer/file_transfer.rb +0 -73
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- describe DRbQS::ServerDefinition do
3
+ describe DRbQS::Execution::ServerDefinition do
4
4
  context "when we call class methods" do
5
5
  subject do
6
6
  DRbQS.class_variable_get(:@@server_def)
@@ -0,0 +1,16 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ require 'drbqs/ext/task'
4
+
5
+ describe DRbQS::CommandTask::CommandExecute do
6
+ it "should execute command" do
7
+ cmd_exec = DRbQS::CommandTask::CommandExecute.new('ls > /dev/null')
8
+ cmd_exec.exec.should == 0
9
+ end
10
+
11
+ it "should enqueue files" do
12
+ DRbQS::Transfer.should_receive(:enqueue).exactly(2)
13
+ cmd_exec = DRbQS::CommandTask::CommandExecute.new('ls > /dev/null', :transfer => ['hello', 'world'])
14
+ cmd_exec.exec
15
+ end
16
+ end
@@ -6,7 +6,7 @@ require_relative 'definition/task_obj_definition.rb'
6
6
  describe DRbQS do
7
7
  before(:all) do
8
8
  @tasks = 5.times.map do |i|
9
- DRbQS::Task.new(Test1.new, :echo, [i])
9
+ DRbQS::Task.new(Test1.new, :echo, args: [i])
10
10
  end
11
11
  @process_id, @uri = drbqs_fork_server(14010, :task => @tasks)
12
12
  @node = DRbQS::Node.new(@uri, :log_file => $stdout, :continue => true)
@@ -5,11 +5,11 @@ require_relative 'definition/task_obj_definition.rb'
5
5
 
6
6
  describe DRbQS do
7
7
  before(:all) do
8
- @task_generators = [DRbQS::TaskGenerator.new(:iterate => 3), DRbQS::TaskGenerator.new(:iterate => 4)]
8
+ @task_generators = [DRbQS::Task::Generator.new(:iterate => 3), DRbQS::Task::Generator.new(:iterate => 4)]
9
9
  @task_generators.each do |tg|
10
10
  tg.set do
11
11
  @iterate.times do |i|
12
- create_add_task(Test1.new, :echo, [i])
12
+ create_add(Test1.new, :echo, args: [i])
13
13
  end
14
14
  end
15
15
  end
@@ -6,7 +6,7 @@ require_relative 'definition/task_obj_definition.rb'
6
6
  describe DRbQS::Server do
7
7
  before(:all) do
8
8
  @tasks = 2.times.map do |i|
9
- DRbQS::Task.new(Test1.new, :echo, [i])
9
+ DRbQS::Task.new(Test1.new, :echo, args: [i])
10
10
  end
11
11
  path = "/tmp/drbqs"
12
12
  @process_id, @uri = drbqs_fork_server(path, :task => @tasks)
@@ -6,7 +6,7 @@ require_relative 'definition/task_obj_definition.rb'
6
6
  describe DRbQS do
7
7
  before(:all) do
8
8
  @tasks = 3.times.map do |i|
9
- DRbQS::Task.new(Test1.new, :echo, [i])
9
+ DRbQS::Task.new(Test1.new, :echo, args: [i])
10
10
  end
11
11
  @process_id, @uri = drbqs_fork_server(14050, :task => @tasks)
12
12
  @manage = DRbQS::Manage.new(:uri => @uri)
@@ -1,20 +1,20 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- require 'drbqs/manage/execute_node'
3
+ require 'drbqs/execute/execute_node'
4
4
  require_relative 'definition/task_obj_definition.rb'
5
5
 
6
6
  describe DRbQS::Server do
7
7
  before(:all) do
8
8
  @wait = 2
9
9
  @tasks = 10.times.map do |i|
10
- DRbQS::Task.new(Test2.new, :echo_wait, [@wait])
10
+ DRbQS::Task.new(Test2.new, :echo_wait, args: [@wait])
11
11
  end
12
- @server_process_id, @uri = drbqs_fork_server(14060, :task => @tasks, :continue => true)
12
+ @server_process_id, @uri = drbqs_fork_server(14060, :task => @tasks, :opts => { :not_exit => true })
13
13
  @manage = DRbQS::Manage.new(:uri => @uri)
14
14
  end
15
15
 
16
16
  it "should send node exit" do
17
- execute_node = DRbQS::ExecuteNode.new(@uri, nil, nil)
17
+ execute_node = DRbQS::Execution::ExecuteNode.new(@uri, nil, nil)
18
18
  execute_node.execute(1)
19
19
  client_process_id = execute_node.pid[0]
20
20
  sleep(@wait)
@@ -6,12 +6,12 @@ require 'drbqs/command_line/command_line'
6
6
  describe DRbQS::Server do
7
7
  before(:all) do
8
8
  @max_wait_time = 10
9
- @server_process_id, @uri = drbqs_fork_server(14080, :continue => true, :opts => { :shutdown_unused_nodes => true })
9
+ @server_process_id, @uri = drbqs_fork_server(14080, :opts => { :shutdown_unused_nodes => true, :not_exit => true })
10
10
  @manage = DRbQS::Manage.new(:uri => @uri)
11
11
  end
12
12
 
13
13
  it "should send node exit" do
14
- execute_node = DRbQS::ExecuteNode.new(@uri, nil, nil)
14
+ execute_node = DRbQS::Execution::ExecuteNode.new(@uri, nil, nil)
15
15
  execute_node.execute(1)
16
16
  client_process_id = execute_node.pid[0]
17
17
  th = Process.detach(client_process_id)
@@ -18,7 +18,7 @@ describe DRbQS::Server do
18
18
  @file = DRbQS::Temporary.file
19
19
  @initial_data = ['abc', 'def']
20
20
  @max_wait_time = 10
21
- @server_process_id, @uri = drbqs_fork_server(14090, :continue => true) do |server|
21
+ @server_process_id, @uri = drbqs_fork_server(14090, :opts => { :not_exit => true }) do |server|
22
22
  server.add_hook(:process_data) do |srv, data|
23
23
  open(@file, 'a+') do |f|
24
24
  f.print data
@@ -7,14 +7,13 @@ DRbQS.option_parser do |opt, hash|
7
7
  end
8
8
  end
9
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
10
+ DRbQS.define_server do |server, argv, opts|
11
+ step = opts[:step]
12
+ server.task_generator(:generate => 2) do |reg|
13
13
  1.step(100, 50) do |i|
14
- create_add_task(TestSum.new, :calc, [i, i + 10, @step]) do |srv, result|
14
+ reg.create_add(TestSum.new, :calc, args: [i, i + 10, step]) do |srv, result|
15
15
  puts result
16
16
  end
17
17
  end
18
18
  end
19
- server.add_task_generator(tgen)
20
19
  end
@@ -7,10 +7,8 @@ DRbQS.option_parser do |opt, hash|
7
7
  end
8
8
  end
9
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
10
+ DRbQS.define_server do |server, argv, opts|
11
+ server.task_generator(:generate => 2) do
13
12
  raise "Error raise"
14
13
  end
15
- server.add_task_generator(tgen)
16
14
  end
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe DRbQS::Node do
4
+ context "when starting node" do
5
+ def init_node_objects(object = {})
6
+ @uri = 'drbunix:/tmp/drb_test'
7
+ @drb_object = {
8
+ :message => Rinda::TupleSpace.new,
9
+ :queue => Rinda::TupleSpace.new,
10
+ :result => Rinda::TupleSpace.new,
11
+ :key => 'server_key',
12
+ :transfer => nil
13
+ }.merge(object)
14
+ end
15
+
16
+ subject do
17
+ DRbQS::Node.new(@uri, :log_file => STDOUT)
18
+ end
19
+
20
+ before(:all) do
21
+ init_node_objects
22
+ end
23
+
24
+ it "should connect to server." do
25
+ DRb::DRbObject.should_receive(:new_with_uri).and_return(@drb_object)
26
+ node_connection = mock('node connection')
27
+ node_connection.stub(:node_number).and_return(10)
28
+ node_connection.stub(:get_initialization).and_return(nil)
29
+ DRbQS::Node::Connection.should_receive(:new).and_return(node_connection)
30
+ DRbQS::Node::TaskClient.should_receive(:new)
31
+ subject.connect
32
+ end
33
+ end
34
+ end
@@ -110,7 +110,7 @@ describe DRbQS::Server::Message do
110
110
  end
111
111
 
112
112
  it "should send status" do
113
- @message_server.send_status({})
113
+ @message_server.send_status('status message')
114
114
  sym, status = @message.take([:status, nil])
115
115
  status.should be_an_instance_of String
116
116
  end
@@ -18,7 +18,7 @@ describe DRbQS::Server::Queue do
18
18
  end
19
19
 
20
20
  before(:all) do
21
- @task = { :obj => DRbQS::Task.new([1, 2, 3], :size, []), :id => nil }
21
+ @task = { :obj => DRbQS::Task.new([1, 2, 3], :size), :id => nil }
22
22
  end
23
23
 
24
24
  context "when initializing queue" do
@@ -222,9 +222,9 @@ describe DRbQS::Server::Queue do
222
222
  before(:all) do
223
223
  object_init
224
224
  @node_ids = [200, 300]
225
- @tasks = [DRbQS::Task.new([1, 2, 3], :size, []),
226
- DRbQS::Task.new([-1, -2], :size, []),
227
- DRbQS::Task.new([8, 9, 10, 11], :size, [])]
225
+ @tasks = [DRbQS::Task.new([1, 2, 3], :size),
226
+ DRbQS::Task.new([-1, -2], :size),
227
+ DRbQS::Task.new([8, 9, 10, 11], :size)]
228
228
  @task_ids = @tasks.map do |t|
229
229
  subject.add(t)
230
230
  end
@@ -287,9 +287,9 @@ describe DRbQS::Server::Queue do
287
287
 
288
288
  context "when managing some tasks" do
289
289
  before(:all) do
290
- @task_ary = [DRbQS::Task.new([1, 2, 3], :size, []),
291
- DRbQS::Task.new([1, 3], :size, []),
292
- DRbQS::Task.new([2, 1, 2, 3], :size, [])]
290
+ @task_ary = [DRbQS::Task.new([1, 2, 3], :size, note: 'task1'),
291
+ DRbQS::Task.new([1, 3], :size, note: 'task2'),
292
+ DRbQS::Task.new([2, 1, 2, 3], :size, note: 'task3')]
293
293
  object_init
294
294
  @node_id = 100
295
295
  @task_id_ary = @task_ary.map do |task|
@@ -325,4 +325,31 @@ describe DRbQS::Server::Queue do
325
325
  end
326
326
  end
327
327
 
328
+ context "when creating messages of calculating tasks" do
329
+ before(:all) do
330
+ @task_ary = [DRbQS::Task.new([1, 2, 3], :size, note: 'task1'),
331
+ DRbQS::Task.new([1, 3], :size, note: 'task2'),
332
+ DRbQS::Task.new([2, 1, 2, 3], :size, note: 'task3')]
333
+ object_init
334
+ @node_id = 100
335
+ @task_id_ary = @task_ary.map do |task|
336
+ subject.add(task)
337
+ end
338
+ @ts[:result].write([:accept, @task_id_ary[0], 100])
339
+ @ts[:result].write([:accept, @task_id_ary[1], 101])
340
+ @ts[:result].write([:result, @task_id_ary[0], @node_id, :result_object])
341
+ end
342
+
343
+ it "should return number of acceptances of signals." do
344
+ subject.get_accept_signal.should == 2
345
+ end
346
+
347
+ it "should return calculating task messages." do
348
+ messages = subject.calculating_task_message
349
+ messages.should have(2).items
350
+ messages[100].should == [[@task_id_ary[0], 'task1']]
351
+ messages[101].should == [[@task_id_ary[1], 'task2']]
352
+ end
353
+ end
354
+
328
355
  end
@@ -59,31 +59,43 @@ describe DRbQS::Server do
59
59
  server_hook = mock
60
60
  DRbQS::Server::Hook.stub!(:new).and_return(server_hook)
61
61
  server_hook.should_receive(:set_finish_exit)
62
- DRbQS::Server.new(:finish_exit => true)
62
+ DRbQS::Server.new
63
63
  end
64
64
  end
65
65
 
66
66
  context "when starting DRbQS::Server" do
67
- it "should not set DRbQS::FileTransfer" do
67
+ it "should not set DRbQS::Transfer" do
68
68
  server = DRbQS::Server.new
69
- DRbQS::TransferClient.should_not_receive(:new)
69
+ DRbQS::Transfer::Client.should_not_receive(:new)
70
70
  DRb.should_receive(:start_service).once
71
71
  server.start
72
72
  end
73
73
 
74
- it "should set DRbQS::FileTransfer" do
75
- server = DRbQS::Server.new(:file_directory => '/tmp', :sftp_user => 'hello', :sftp_host => 'example.com')
76
- DRbQS::TransferClient::SFTP.should_receive(:new).with('hello', 'example.com', '/tmp')
74
+ it "should set DRbQS::Transfer" do
75
+ dir = '/tmp/drbqs_transfer_test'
77
76
  DRb.should_receive(:start_service).once
77
+ server = DRbQS::Server.new(:file_directory => dir, :sftp_user => 'hello', :sftp_host => 'example.com')
78
78
  server.start
79
+ transfer = server.instance_variable_get(:@ts)[:transfer]
80
+ transfer.user.should == 'hello'
81
+ transfer.host.should == 'example.com'
82
+ transfer.directory.should == dir
83
+ File.exist?(dir).should be_true
84
+ FileUtils.rm_r(dir)
79
85
  end
80
86
 
81
- it "should set DRbQS::FileTransfer by DRbQS::Server#set_file_transfer with optional arguments" do
87
+ it "should set DRbQS::Transfer by DRbQS::Server#set_file_transfer with optional arguments" do
88
+ dir = '/tmp/drbqs_transfer_test'
82
89
  server = DRbQS::Server.new
83
- DRbQS::TransferClient::SFTP.should_receive(:new).with('hello', 'example.com', '/tmp')
84
90
  DRb.should_receive(:start_service).once
85
- server.set_file_transfer('/tmp', :user => 'hello', :host => 'example.com')
91
+ server.set_file_transfer(dir, :user => 'hello', :host => 'example.com')
86
92
  server.start
93
+ transfer = server.instance_variable_get(:@ts)[:transfer]
94
+ transfer.user.should == 'hello'
95
+ transfer.host.should == 'example.com'
96
+ transfer.directory.should == dir
97
+ File.exist?(dir).should be_true
98
+ FileUtils.rm_r(dir)
87
99
  end
88
100
  end
89
101
  end
@@ -3,35 +3,70 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
3
  require 'drbqs/utility/temporary'
4
4
 
5
5
  describe DRbQS::Server::TransferSetting do
6
- it "should return nil." do
7
- setting = DRbQS::Server::TransferSetting.new('example.com', 'user', nil)
8
- setting.create(nil).should be_nil
6
+ context "when setup does not execute" do
7
+ it "should return nil." do
8
+ setting = DRbQS::Server::TransferSetting.new('example.com', 'user', nil)
9
+ setting.setup_server(nil).should be_nil
10
+ end
9
11
  end
10
12
 
11
- it "should return transfer client." do
12
- dir = DRbQS::Temporary.file
13
- setting = DRbQS::Server::TransferSetting.new('example.com', 'user', dir)
14
- client = setting.create(nil)
15
- client.should be_an_instance_of DRbQS::TransferClient
16
- client.sftp.should be_an_instance_of DRbQS::TransferClient::SFTP
17
- setting.create(nil).should be_nil
13
+ context "when setup transfer settings" do
14
+ it "should set transfer settings by initializing." do
15
+ dir = DRbQS::Temporary.file
16
+ setting = DRbQS::Server::TransferSetting.new('example.com', 'user', dir)
17
+ setting.setup_server(nil).should be_true
18
+ setting.user.should == 'user'
19
+ setting.host.should == 'example.com'
20
+ setting.directory.should == dir
21
+ end
22
+
23
+ it "should set directory by setup_server." do
24
+ dir = DRbQS::Temporary.file
25
+ setting = DRbQS::Server::TransferSetting.new('example.com', 'user', nil)
26
+ setting.setup_server(dir).should be_true
27
+ setting.user.should == 'user'
28
+ setting.host.should == 'example.com'
29
+ setting.directory.should == dir
30
+ end
31
+
32
+ it "should not set sftp settings." do
33
+ dir = DRbQS::Temporary.file
34
+ setting = DRbQS::Server::TransferSetting.new(nil, nil, dir)
35
+ setting.setup_server(nil).should be_true
36
+ setting.host.should be_nil
37
+ setting.directory.should == dir
38
+ end
18
39
  end
19
40
 
20
- it "should return transfer client with a directory argument." do
21
- dir = DRbQS::Temporary.file
22
- setting = DRbQS::Server::TransferSetting.new('example.com', 'user', nil)
23
- client = setting.create(dir)
24
- client.should be_an_instance_of DRbQS::TransferClient
25
- client.sftp.should be_an_instance_of DRbQS::TransferClient::SFTP
26
- setting.create(dir).should be_nil
41
+ context "when creating transfer client" do
42
+ it "should return nil because setup is not executed." do
43
+ dir = DRbQS::Temporary.file
44
+ setting = DRbQS::Server::TransferSetting.new('example.com', 'user', dir)
45
+ setting.get_client(true).should be_nil
46
+ end
47
+
48
+ it "should return local and sftp transfer client." do
49
+ dir = DRbQS::Temporary.file
50
+ setting = DRbQS::Server::TransferSetting.new('example.com', 'user', dir)
51
+ setting.setup_server(nil).should be_true
52
+ client = setting.get_client(true)
53
+ client.directory.should == dir
54
+ client.local.should be_an_instance_of DRbQS::Transfer::Client::Local
55
+ client.sftp.should be_an_instance_of DRbQS::Transfer::Client::SFTP
56
+ end
57
+
58
+ it "should return only local transfer client." do
59
+ dir = DRbQS::Temporary.file
60
+ setting = DRbQS::Server::TransferSetting.new(nil, nil, dir)
61
+ setting.setup_server(nil).should be_true
62
+ client = setting.get_client(true)
63
+ client.directory.should == dir
64
+ client.local.should be_an_instance_of DRbQS::Transfer::Client::Local
65
+ client.sftp.should be_nil
66
+ end
27
67
  end
28
68
 
29
- it "should return transfer client without sftp" do
30
- dir = DRbQS::Temporary.file
31
- setting = DRbQS::Server::TransferSetting.new(nil, nil, dir)
32
- client = setting.create(nil)
33
- client.should be_an_instance_of DRbQS::TransferClient
34
- client.sftp.should be_nil
35
- setting.create(nil).should be_nil
69
+ after(:all) do
70
+ DRbQS::Temporary.delete_all
36
71
  end
37
72
  end
@@ -32,4 +32,15 @@ describe DRbQS::Setting::Base do
32
32
  obj.parse!
33
33
  end.should_not change(obj, :string_for_shell)
34
34
  end
35
+
36
+ it "should clone an object." do
37
+ obj = DRbQS::Setting::Base.new(:all_keys_defined => true, :log_level => true, :daemon => true)
38
+ obj.value.daemon '/path/to/log'
39
+ obj.value.log_level 'debug'
40
+ obj_clone = obj.clone
41
+ obj.value.daemon << '/add'
42
+ obj.value.daemon.should_not == obj_clone.value.daemon
43
+ obj_clone.value.debug 'error'
44
+ obj_clone.value.debug.should_not == obj.value.debug
45
+ end
35
46
  end
@@ -88,5 +88,13 @@ describe DRbQS::Setting::Source::DataContainer do
88
88
  subject.key1 = 'def'
89
89
  subject.key1.should_not == container_clone.key1
90
90
  end
91
+
92
+ it "should not change a cloned object." do
93
+ subject.key1 = 'abc'
94
+ container_clone = DRbQS::Setting::Source.clone_container(subject)
95
+ subject.key1 << 'def'
96
+ container_clone.key1.should_not include('def')
97
+ subject.key1.should include('def')
98
+ end
91
99
  end
92
100
  end