sambala 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sambala_gardener.rb +1 -1
- data/test/tc_sambala_main.rb +53 -29
- metadata +2 -2
data/lib/sambala_gardener.rb
CHANGED
data/test/tc_sambala_main.rb
CHANGED
@@ -5,8 +5,11 @@ require 'fileutils'
|
|
5
5
|
require File.join( File.dirname( File.expand_path(__FILE__)), '..', 'lib', 'sambala')
|
6
6
|
|
7
7
|
TESTFILE = 'sambala_test'
|
8
|
-
|
8
|
+
LOCAL_DIR = File.join( File.dirname( File.expand_path(__FILE__)), 'sambala_test_dir')
|
9
|
+
REMOTE_DIR = 'sambala_test_dir'
|
9
10
|
WELCOME = <<TITLE
|
11
|
+
|
12
|
+
|
10
13
|
.|'''.| '|| '||
|
11
14
|
||.. ' .... .. .. .. || ... .... || ....
|
12
15
|
''|||. '' .|| || || || ||' || '' .|| || '' .||
|
@@ -25,38 +28,40 @@ class TestSambalaMain < Test::Unit::TestCase
|
|
25
28
|
get_samba_param_from_input
|
26
29
|
init_sambala
|
27
30
|
put_marker
|
28
|
-
Dir.mkdir(
|
31
|
+
Dir.mkdir(LOCAL_DIR)
|
29
32
|
end
|
30
33
|
|
31
34
|
def test_main
|
32
35
|
@log_test.info("Testing sample SMB operations...")
|
33
36
|
ls_one = check_ls
|
34
|
-
check_mkdir(
|
35
|
-
check_exist(
|
36
|
-
check_cd(
|
37
|
+
check_mkdir(REMOTE_DIR)
|
38
|
+
check_exist(REMOTE_DIR)
|
39
|
+
check_cd(REMOTE_DIR)
|
37
40
|
|
38
41
|
ls_two = check_ls
|
39
42
|
assert(ls_one != ls_two)
|
40
43
|
|
41
44
|
check_lcd_put_get
|
42
45
|
check_queue
|
46
|
+
|
47
|
+
check_big_chunk
|
43
48
|
|
44
49
|
check_cd('..')
|
45
|
-
check_rmdir(
|
50
|
+
check_rmdir(REMOTE_DIR)
|
46
51
|
end
|
47
52
|
|
48
53
|
def teardown
|
49
54
|
back_to_marker
|
50
55
|
@log_test.info("All Test Done!!! Tearing Down!!!")
|
51
|
-
@samba.rmdir(
|
56
|
+
@samba.rmdir(REMOTE_DIR).to_s if @samba.exist?(REMOTE_DIR)
|
52
57
|
@log_test.debug("remote directory clean")
|
53
58
|
close = @samba.close
|
54
59
|
assert(close)
|
55
60
|
@log_test.debug("samba client closed")
|
56
|
-
FileUtils.remove_dir(
|
61
|
+
FileUtils.remove_dir(LOCAL_DIR) if File.exist?(LOCAL_DIR)
|
57
62
|
@log_test.debug("local directory clean")
|
58
63
|
@log_test.close
|
59
|
-
puts "\nBEWARE, if test fails you may have to clean up your server and the test directory,\na folder named #{
|
64
|
+
puts "\nBEWARE, if test fails you may have to clean up your server and the test directory,\na folder named #{REMOTE_DIR} may be left after exiting... Sorry!"
|
60
65
|
end
|
61
66
|
|
62
67
|
private
|
@@ -78,6 +83,7 @@ class TestSambalaMain < Test::Unit::TestCase
|
|
78
83
|
|
79
84
|
def get_samba_param_from_input
|
80
85
|
puts WELCOME
|
86
|
+
puts "ATTENTION!!! You need 1gb free space on your local machine and 10gb on your server for this test to run!!!"
|
81
87
|
puts "I will need you to input some working Samba connection settings..."
|
82
88
|
print "\n"; sleep 1
|
83
89
|
print "host name or IP: "
|
@@ -133,14 +139,14 @@ class TestSambalaMain < Test::Unit::TestCase
|
|
133
139
|
|
134
140
|
def check_lcd_put_get
|
135
141
|
@log_test.debug("cd in testdir")
|
136
|
-
re = @samba.lcd(
|
142
|
+
re = @samba.lcd(LOCAL_DIR)
|
137
143
|
assert_equal(true,re)
|
138
144
|
|
139
145
|
@log_test.debug("making local test file")
|
140
|
-
f = File.new(
|
146
|
+
f = File.new(File.join(LOCAL_DIR,TESTFILE),'w')
|
141
147
|
f.puts "test file"
|
142
148
|
f.close
|
143
|
-
assert(File.exist?(
|
149
|
+
assert(File.exist?(File.join(LOCAL_DIR,TESTFILE)))
|
144
150
|
|
145
151
|
@log_test.debug("putting file")
|
146
152
|
re = @samba.put(:from => TESTFILE, :to => TESTFILE)
|
@@ -148,8 +154,8 @@ class TestSambalaMain < Test::Unit::TestCase
|
|
148
154
|
assert_equal(true,re[0])
|
149
155
|
|
150
156
|
@log_test.debug("deleting local test file")
|
151
|
-
File.delete(
|
152
|
-
assert(!File.exist?(
|
157
|
+
File.delete(File.join(LOCAL_DIR,TESTFILE))
|
158
|
+
assert(!File.exist?(File.join(LOCAL_DIR,TESTFILE)))
|
153
159
|
|
154
160
|
check_exist(TESTFILE)
|
155
161
|
|
@@ -163,9 +169,9 @@ class TestSambalaMain < Test::Unit::TestCase
|
|
163
169
|
assert_equal(true,re)
|
164
170
|
|
165
171
|
@log_test.debug("check local test file")
|
166
|
-
assert(File.exist?(
|
167
|
-
File.delete(
|
168
|
-
assert(!File.exist?(
|
172
|
+
assert(File.exist?(File.join(LOCAL_DIR,TESTFILE)))
|
173
|
+
File.delete(File.join(LOCAL_DIR,TESTFILE))
|
174
|
+
assert(!File.exist?(File.join(LOCAL_DIR,TESTFILE)))
|
169
175
|
|
170
176
|
re = @samba.lcd('..')
|
171
177
|
assert_equal(true,re)
|
@@ -173,25 +179,21 @@ class TestSambalaMain < Test::Unit::TestCase
|
|
173
179
|
end
|
174
180
|
|
175
181
|
def check_queue
|
176
|
-
jobs =
|
182
|
+
jobs = 23
|
177
183
|
@log_test.info("Testing queue... (be patient, this will take a couple minutes)")
|
178
184
|
assert_equal(true, @samba.queue_empty?)
|
179
185
|
assert_equal(true, @samba.queue_done?)
|
180
186
|
assert_equal(0,@samba.queue_waiting)
|
181
187
|
|
182
|
-
|
183
|
-
|
184
|
-
files.each do |file|
|
185
|
-
f = File.new("#{TESTDIR}/#{file}",'w')
|
186
|
-
f.puts content
|
187
|
-
f.close
|
188
|
-
end
|
188
|
+
local_file = File.join(LOCAL_DIR,'dummy')
|
189
|
+
system("mkfile 1k #{local_file}")
|
189
190
|
|
190
|
-
re = @samba.lcd(
|
191
|
+
re = @samba.lcd(LOCAL_DIR)
|
191
192
|
assert_equal(true,re)
|
192
193
|
|
194
|
+
files = Array.new(jobs) { |id| "file_" + id.to_s }
|
193
195
|
files.each do |file|
|
194
|
-
@samba.put(:from =>
|
196
|
+
@samba.put(:from => local_file, :to => file, :queue => true)
|
195
197
|
end
|
196
198
|
|
197
199
|
assert_equal(false, @samba.queue_empty?)
|
@@ -204,7 +206,7 @@ class TestSambalaMain < Test::Unit::TestCase
|
|
204
206
|
301.times do |n|
|
205
207
|
break unless result[0].nil?
|
206
208
|
sleep 1
|
207
|
-
result = @samba.
|
209
|
+
result = @samba.queue_processing
|
208
210
|
flunk("Could not get any queue done...") if n == 300
|
209
211
|
end
|
210
212
|
assert_kind_of(Array,result[0])
|
@@ -245,14 +247,36 @@ class TestSambalaMain < Test::Unit::TestCase
|
|
245
247
|
assert_equal(true, @samba.queue_done?)
|
246
248
|
assert_equal(0,@samba.queue_waiting)
|
247
249
|
|
250
|
+
File.delete(local_file)
|
248
251
|
files.each do |file|
|
249
252
|
del = @samba.del(file)
|
250
253
|
@log_test.debug("remote delete: #{del.inspect}")
|
251
|
-
File.delete("#{TESTDIR}/#{file}")
|
252
254
|
end
|
253
255
|
|
254
256
|
re = @samba.lcd('..')
|
255
257
|
assert_equal(true,re)
|
256
258
|
end
|
259
|
+
|
260
|
+
def check_big_chunk
|
261
|
+
jobs = 2
|
262
|
+
@log_test.info("Testing a big copy... (be patient, this can also take a couple minutes)")
|
263
|
+
local_file = File.join(LOCAL_DIR,'dummy')
|
264
|
+
system("mkfile 1g #{local_file}")
|
265
|
+
|
266
|
+
before = @samba.ls
|
267
|
+
files = Array.new(jobs) { |id| "file_" + id.to_s }
|
268
|
+
files.each do |file|
|
269
|
+
@samba.put(:from => local_file, :to => file, :queue => true)
|
270
|
+
end
|
271
|
+
|
272
|
+
result = @samba.queue_results
|
273
|
+
assert_equal(1, result.map { |item| item[1] }.uniq.size, "results were: #{result.inspect}")
|
274
|
+
|
275
|
+
File.delete(local_file)
|
276
|
+
files.each do |file|
|
277
|
+
del = @samba.del(file)
|
278
|
+
@log_test.debug("remote delete: #{del.inspect}")
|
279
|
+
end
|
280
|
+
end
|
257
281
|
|
258
282
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sambala
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Louis-Philippe Perron
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-13 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|