mogilefs-client 3.7.1 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_fresh.rb CHANGED
@@ -197,4 +197,75 @@ class TestMogFresh < Test::Unit::TestCase
197
197
  @mogilefsd_pid = nil
198
198
  assert_raises(MogileFS::UnreachableBackendError) { client.list_keys }
199
199
  end
200
+
201
+ def test_admin_setup_new_host_and_devices
202
+ assert_equal [], @admin.get_hosts
203
+ args = { :ip => @test_host, :port => @mogstored_http_port }
204
+ @admin.create_host("me", args)
205
+ yield_for_monitor_update { @admin.get_hosts.empty? or break }
206
+ hosts = @admin.get_hosts
207
+ assert_equal 1, hosts.size
208
+ host = @admin.get_hosts[0]
209
+ assert_equal "me", host["hostname"]
210
+ assert_equal @mogstored_http_port, host["http_port"]
211
+ assert_nil host["http_get_port"]
212
+ assert_equal @test_host, host["hostip"]
213
+ assert_kind_of Integer, host["hostid"]
214
+ assert_equal hosts, @admin.get_hosts(host["hostid"])
215
+
216
+ assert_equal [], @admin.get_devices
217
+ end
218
+
219
+ def test_replicate_now
220
+ assert_equal({"count" => 0}, @admin.replicate_now)
221
+ end
222
+
223
+ def test_clear_cache
224
+ assert_nil @admin.clear_cache
225
+ end
226
+
227
+ def test_create_update_delete_class
228
+ domain = "rbmogtest#{Time.now.strftime('%Y%m%d%H%M%S')}.#{uuid}"
229
+ @admin.create_domain(domain)
230
+ yield_for_monitor_update { @admin.get_domains.include?(domain) and break }
231
+
232
+ @admin.create_class(domain, "klassy", 1)
233
+
234
+ assert_raises(MogileFS::Backend::ClassExistsError) do
235
+ @admin.create_class(domain, "klassy", 1)
236
+ end
237
+
238
+ @admin.update_class(domain, "klassy",
239
+ :mindevcount => 1, :replpolicy => "MultipleHosts(1)")
240
+
241
+ tmp = nil
242
+ yield_for_monitor_update do
243
+ tmp = @admin.get_domains[domain]["klassy"]
244
+ break if tmp && tmp["replpolicy"] == "MultipleHosts(1)"
245
+ end
246
+ assert tmp, "domain did not show up"
247
+ assert_equal 1, tmp["mindevcount"]
248
+ assert_equal "MultipleHosts(1)", tmp["replpolicy"]
249
+ @admin.update_class(domain, "klassy", 2)
250
+ ensure
251
+ @admin.delete_class(domain, "klassy") rescue nil
252
+ end
253
+
254
+ def test_device_file_add
255
+ add_host_device_domain
256
+ client = MogileFS::MogileFS.new :hosts => @hosts, :domain => @domain
257
+ r, w = IO.pipe
258
+ thr = Thread.new do
259
+ (0..9).each do |i|
260
+ sleep 0.05
261
+ w.write("#{i}\n")
262
+ end
263
+ w.close
264
+ :ok
265
+ end
266
+ assert_equal 20, client.store_file("pipe", nil, r)
267
+ assert_equal :ok, thr.value
268
+ r.close
269
+ assert_equal "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n", client.get_file_data("pipe")
270
+ end
200
271
  end
@@ -6,10 +6,17 @@ require 'fileutils'
6
6
 
7
7
  class TestMogileFS__MogileFS < TestMogileFS
8
8
  def setup
9
+ @tmpsrv = []
9
10
  @klass = MogileFS::MogileFS
10
11
  super
11
12
  end
12
13
 
14
+ def tmpsrv(blk)
15
+ t = TempServer.new(blk)
16
+ @tmpsrv << t
17
+ t
18
+ end
19
+
13
20
  def read_headers(client)
14
21
  headers = ""
15
22
  while line = client.gets
@@ -40,8 +47,8 @@ class TestMogileFS__MogileFS < TestMogileFS
40
47
  client.send("HTTP/1.0 200 OK\r\nContent-Length: 5\r\n\r\ndata!", 0)
41
48
  client.close
42
49
  end
43
- t1 = TempServer.new(svr)
44
- t2 = TempServer.new(svr)
50
+ t1 = tmpsrv(svr)
51
+ t2 = tmpsrv(svr)
45
52
  path1 = "http://127.0.0.1:#{t1.port}/dev1/0/000/000/0000000062.fid"
46
53
  path2 = "http://127.0.0.1:#{t2.port}/dev2/0/000/000/0000000062.fid"
47
54
 
@@ -49,8 +56,6 @@ class TestMogileFS__MogileFS < TestMogileFS
49
56
 
50
57
  assert_equal 'data!', @client.get_file_data('key')
51
58
  assert_equal 1, accept.stat.size
52
- ensure
53
- TempServer.destroy_all!
54
59
  end
55
60
 
56
61
  def test_get_file_data_http_not_found_failover
@@ -80,16 +85,14 @@ class TestMogileFS__MogileFS < TestMogileFS
80
85
  client.close
81
86
  end
82
87
 
83
- t1 = TempServer.new(svr1)
84
- t2 = TempServer.new(svr2)
88
+ t1 = tmpsrv(svr1)
89
+ t2 = tmpsrv(svr2)
85
90
  path1 = "http://127.0.0.1:#{t1.port}/dev1/0/000/000/0000000062.fid"
86
91
  path2 = "http://127.0.0.1:#{t2.port}/dev2/0/000/000/0000000062.fid"
87
92
  @backend.get_paths = { 'paths' => 2, 'path1' => path1, 'path2' => path2 }
88
93
 
89
94
  assert_equal 'data!', @client.get_file_data('key')
90
95
  assert_equal 2, accept.stat.size
91
- ensure
92
- TempServer.destroy_all!
93
96
  end
94
97
 
95
98
  def test_get_file_data_http_block
@@ -117,8 +120,8 @@ class TestMogileFS__MogileFS < TestMogileFS
117
120
  client.close
118
121
  exit 0
119
122
  end
120
- t1 = TempServer.new(svr)
121
- t2 = TempServer.new(svr)
123
+ t1 = tmpsrv(svr)
124
+ t2 = tmpsrv(svr)
122
125
  path1 = "http://127.0.0.1:#{t1.port}/dev1/0/000/000/0000000062.fid"
123
126
  path2 = "http://127.0.0.1:#{t2.port}/dev2/0/000/000/0000000062.fid"
124
127
 
@@ -237,7 +240,7 @@ class TestMogileFS__MogileFS < TestMogileFS
237
240
  to_store = Tempfile.new('small')
238
241
  to_store.syswrite('data')
239
242
 
240
- t = TempServer.new(Proc.new do |serv, accept|
243
+ t = tmpsrv(Proc.new do |serv, accept|
241
244
  client, _ = serv.accept
242
245
  while buf = client.readpartial(666)
243
246
  received.syswrite(buf)
@@ -260,14 +263,12 @@ class TestMogileFS__MogileFS < TestMogileFS
260
263
  assert_equal("data", a[-1])
261
264
  assert_equal("", a[-2])
262
265
  assert a.grep(%r{\AContent-Length: 4\z})[0]
263
- ensure
264
- TempServer.destroy_all!
265
266
  end
266
267
 
267
268
  def test_store_content_http
268
269
  received = Tempfile.new('received')
269
270
 
270
- t = TempServer.new(Proc.new do |serv, accept|
271
+ t = tmpsrv(Proc.new do |serv, accept|
271
272
  client, _ = serv.accept
272
273
  client.sync = true
273
274
  seen = ""
@@ -295,8 +296,6 @@ class TestMogileFS__MogileFS < TestMogileFS
295
296
  assert_equal("data", a[-1])
296
297
  assert_equal("", a[-2])
297
298
  assert a.grep(%r{\AContent-Length: 4\z})[0]
298
- ensure
299
- TempServer.destroy_all!
300
299
  end
301
300
 
302
301
 
@@ -306,7 +305,7 @@ class TestMogileFS__MogileFS < TestMogileFS
306
305
  10.times do
307
306
  expected += "data"
308
307
  end
309
- t = TempServer.new(Proc.new do |serv, accept|
308
+ t = tmpsrv(Proc.new do |serv, accept|
310
309
  client, _ = serv.accept
311
310
  client.sync = true
312
311
  nr = 0
@@ -343,8 +342,6 @@ class TestMogileFS__MogileFS < TestMogileFS
343
342
  assert_equal("data" * 10, a[-1])
344
343
  assert_equal("", a[-2])
345
344
  assert a.grep(%r{\AContent-Length: 40\z})[0]
346
- ensure
347
- TempServer.destroy_all!
348
345
  end
349
346
 
350
347
  def test_store_content_multi_dest_failover_path
@@ -355,7 +352,7 @@ class TestMogileFS__MogileFS < TestMogileFS
355
352
  received1 = Tempfile.new('received')
356
353
  received2 = Tempfile.new('received')
357
354
 
358
- t1 = TempServer.new(Proc.new do |serv, accept|
355
+ t1 = tmpsrv(Proc.new do |serv, accept|
359
356
  client, _ = serv.accept
360
357
  seen = ""
361
358
  while seen !~ /\r\n\r\ndata/
@@ -367,7 +364,7 @@ class TestMogileFS__MogileFS < TestMogileFS
367
364
  client.close
368
365
  end)
369
366
 
370
- t2 = TempServer.new(Proc.new do |serv, accept|
367
+ t2 = tmpsrv(Proc.new do |serv, accept|
371
368
  client, _ = serv.accept
372
369
  seen = ""
373
370
  while seen !~ /\r\n\r\ndata/
@@ -410,12 +407,10 @@ class TestMogileFS__MogileFS < TestMogileFS
410
407
  assert_equal("", b[-2])
411
408
  assert a.grep(%r{\AContent-Length: 4\z})[0]
412
409
  assert b.grep(%r{\AContent-Length: 4\z})[0]
413
- ensure
414
- TempServer.destroy_all!
415
410
  end
416
411
 
417
412
  def test_store_content_http_fail
418
- t = TempServer.new(Proc.new do |serv, accept|
413
+ t = tmpsrv(Proc.new do |serv, accept|
419
414
  client, _ = serv.accept
420
415
  client.sync = true
421
416
  read_headers(client)
@@ -435,7 +430,7 @@ class TestMogileFS__MogileFS < TestMogileFS
435
430
 
436
431
  def test_store_content_http_empty
437
432
  received = Tempfile.new('received')
438
- t = TempServer.new(Proc.new do |serv, accept|
433
+ t = tmpsrv(Proc.new do |serv, accept|
439
434
  client, _ = serv.accept
440
435
  client.sync = true
441
436
  received.syswrite(client.recv(4096, 0))
@@ -487,7 +482,7 @@ class TestMogileFS__MogileFS < TestMogileFS
487
482
  assert_equal expect_size, to_put.stat.size
488
483
 
489
484
  readed = Tempfile.new('readed')
490
- t = TempServer.new(Proc.new do |serv, accept|
485
+ t = tmpsrv(Proc.new do |serv, accept|
491
486
  client, _ = serv.accept
492
487
  client.sync = true
493
488
  nr = 0
@@ -523,9 +518,6 @@ class TestMogileFS__MogileFS < TestMogileFS
523
518
  assert( system(cmp_bin, expect.path, received.path) )
524
519
  break
525
520
  end
526
-
527
- ensure
528
- TempServer.destroy_all!
529
521
  end
530
522
 
531
523
  def test_store_content_readonly
@@ -868,6 +860,10 @@ class TestMogileFS__MogileFS < TestMogileFS
868
860
  assert_equal({}, @client.sleep(2))
869
861
  end
870
862
 
863
+ def teardown
864
+ @tmpsrv.each { |t| t.destroy! }
865
+ end
866
+
871
867
  private
872
868
 
873
869
  # tested with 1000, though it takes a while
@@ -1,12 +1,16 @@
1
1
  # -*- encoding: binary -*-
2
- require './test/integration'
2
+ require './test/fresh'
3
3
 
4
- class TestMogileFSIntegration < TestMogIntegration
4
+ class TestMogileFSIntegration < Test::Unit::TestCase
5
+ include TestFreshSetup
5
6
  def setup
6
- super
7
+ setup_mogilefs
8
+ add_host_device_domain
7
9
  @client = MogileFS::MogileFS.new(:hosts => @trackers, :domain => @domain)
8
10
  end
9
11
 
12
+ alias teardown teardown_mogilefs
13
+
10
14
  def test_CRUD
11
15
  assert ! @client.exist?("CRUD")
12
16
  assert_equal 4, @client.store_content("CRUD", "default", "DATA")
@@ -157,9 +161,14 @@ class TestMogileFSIntegration < TestMogIntegration
157
161
  end
158
162
  end
159
163
 
160
- # TODO: move this to a fresh instance
161
164
  def test_admin_each_fid
162
165
  admin = MogileFS::Admin.new(:hosts => @trackers)
166
+ input = %w(a b c d e)
167
+ input.each do |k|
168
+ rv = @client.new_file(k)
169
+ rv.write(k)
170
+ assert_nil rv.close
171
+ end
163
172
  seen = {}
164
173
  count = admin.each_fid do |info|
165
174
  seen[info["fid"]] = true
@@ -171,7 +180,8 @@ class TestMogileFSIntegration < TestMogIntegration
171
180
  assert_kind_of String, info["domain"]
172
181
  end
173
182
  assert_equal count, seen.size
174
- end if ENV["TEST_EXPENSIVE"]
183
+ assert_equal count, input.size
184
+ end
175
185
 
176
186
  def test_new_file_no_block
177
187
  rv = @client.new_file("no_block")
@@ -1,13 +1,17 @@
1
1
  # -*- encoding: binary -*-
2
- require './test/integration'
2
+ require './test/fresh'
3
3
  require "digest/sha1"
4
4
 
5
- class TestMogileFSLargePipe< TestMogIntegration
5
+ class TestMogileFSLargePipe < Test::Unit::TestCase
6
+ include TestFreshSetup
6
7
  def setup
7
- super
8
+ setup_mogilefs
9
+ add_host_device_domain
8
10
  @client = MogileFS::MogileFS.new(:hosts => @trackers, :domain => @domain)
9
11
  end
10
12
 
13
+ alias teardown teardown_mogilefs
14
+
11
15
  def test_large_pipe_test
12
16
  junk = File.open("/dev/urandom") { |fp| fp.read(1024) }
13
17
  junk *= 32
@@ -1,13 +1,17 @@
1
-
2
1
  # -*- encoding: binary -*-
3
- require './test/integration'
2
+ require './test/fresh'
3
+
4
+ class TestMogileFSIntegrationListKeys < Test::Unit::TestCase
5
+ include TestFreshSetup
4
6
 
5
- class TestMogileFSIntegrationListKeys < TestMogIntegration
6
7
  def setup
7
- super
8
+ setup_mogilefs
9
+ add_host_device_domain
8
10
  @client = MogileFS::MogileFS.new(:hosts => @trackers, :domain => @domain)
9
11
  end
10
12
 
13
+ alias teardown teardown_mogilefs
14
+
11
15
  def test_list_keys
12
16
  k = %w(a b c d e f g)
13
17
  k.each { |x| @client.store_content("lk_#{x}", nil, x) }
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: binary -*-
2
- require "./test/integration"
2
+ require "./test/fresh"
3
3
  require "net/http"
4
4
  ok = true
5
5
  unless File.executable?(`which mogtool 2>/dev/null`.strip)
@@ -7,7 +7,8 @@ unless File.executable?(`which mogtool 2>/dev/null`.strip)
7
7
  ok = false
8
8
  end
9
9
 
10
- class TestMogtoolBigfile < TestMogIntegration
10
+ class TestMogtoolBigfile < Test::Unit::TestCase
11
+ include TestFreshSetup
11
12
  buf = File.open("/dev/urandom") { |fp| fp.read(1024) }
12
13
  buf *= 1024
13
14
  RAND = Tempfile.new("rand")
@@ -18,12 +19,15 @@ class TestMogtoolBigfile < TestMogIntegration
18
19
  RAND_SHA1 = sha1.hexdigest
19
20
 
20
21
  def setup
21
- super
22
+ setup_mogilefs
23
+ add_host_device_domain
22
24
  RAND.rewind
23
25
  @big_uuid = "big-#{uuid}"
24
26
  @client = MogileFS::MogileFS.new(:hosts => @trackers, :domain => @domain)
25
27
  end
26
28
 
29
+ alias teardown teardown_mogilefs
30
+
27
31
  def mogtool!(*args)
28
32
  x!("mogtool", "--trackers=#{@trackers.join(',')}",
29
33
  "--domain=#@domain", *args)
metadata CHANGED
@@ -1,72 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mogilefs-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.1
5
- prerelease:
4
+ version: 3.8.0
6
5
  platform: ruby
7
6
  authors:
8
- - Eric Wong
7
+ - mogilefs-client hackers
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-10 00:00:00.000000000 Z
11
+ date: 2015-02-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: rdoc
14
+ name: olddoc
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '3.10'
19
+ version: '1.0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '3.10'
30
- - !ruby/object:Gem::Dependency
31
- name: hoe
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '3.5'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '3.5'
46
- description: ! '["A MogileFS client library for Ruby. MogileFS is an open source\ndistributed
47
- filesystem, see: http://mogilefs.org for more details. This\nlibrary allows any
48
- Ruby application to read, write and delete files in a\nMogileFS instance."]'
49
- email:
50
- - normalperson@yhbt.net
26
+ version: '1.0'
27
+ description: |-
28
+ A MogileFS client library for Ruby. MogileFS is an open source
29
+ distributed filesystem, see: http://mogilefs.org for more details. This
30
+ library allows any Ruby application to read, write and delete files in a
31
+ MogileFS instance.
32
+ email: e@80x24.org
51
33
  executables:
52
34
  - mog
53
35
  extensions: []
54
- extra_rdoc_files:
55
- - Manifest.txt
36
+ extra_rdoc_files: []
56
37
  files:
57
- - .document
58
- - .gitignore
59
- - .wrongdoc.yml
38
+ - ".document"
39
+ - ".gitignore"
40
+ - ".manifest"
41
+ - ".olddoc.yml"
42
+ - GIT-VERSION-FILE
60
43
  - GIT-VERSION-GEN
61
44
  - GNUmakefile
62
45
  - HACKING
63
46
  - History
47
+ - LATEST
64
48
  - LICENSE
49
+ - NEWS
65
50
  - README
66
- - Rakefile
67
51
  - TODO
68
52
  - bin/mog
53
+ - examples/mog-sync.rb
69
54
  - examples/stale_fid_checker.rb
55
+ - examples/usage_fetcher.rb
70
56
  - lib/mogilefs.rb
71
57
  - lib/mogilefs/admin.rb
72
58
  - lib/mogilefs/backend.rb
@@ -93,12 +79,14 @@ files:
93
79
  - lib/mogilefs/socket/pure_ruby.rb
94
80
  - lib/mogilefs/socket_common.rb
95
81
  - lib/mogilefs/util.rb
82
+ - lib/mogilefs/version.rb
83
+ - mogilefs-client.gemspec
84
+ - pkg.mk
96
85
  - setup.rb
97
86
  - test/.gitignore
98
87
  - test/aggregate.rb
99
88
  - test/exec.rb
100
89
  - test/fresh.rb
101
- - test/integration.rb
102
90
  - test/setup.rb
103
91
  - test/socket_test.rb
104
92
  - test/test_admin.rb
@@ -118,53 +106,28 @@ files:
118
106
  - test/test_mogtool_bigfile.rb
119
107
  - test/test_mysql.rb
120
108
  - test/test_pool.rb
121
- - Manifest.txt
122
- - ChangeLog
123
- - NEWS
124
- - lib/mogilefs/version.rb
125
- - .gemtest
126
- homepage: http://bogomips.org/mogilefs-client/
127
- licenses: []
109
+ homepage: http://bogomips.org/mogilefs-client
110
+ licenses:
111
+ - BSD-3-Clause
112
+ metadata: {}
128
113
  post_install_message:
129
- rdoc_options:
130
- - --main
131
- - README
114
+ rdoc_options: []
132
115
  require_paths:
133
116
  - lib
134
117
  required_ruby_version: !ruby/object:Gem::Requirement
135
- none: false
136
118
  requirements:
137
- - - ! '>='
119
+ - - ">="
138
120
  - !ruby/object:Gem::Version
139
121
  version: '0'
140
122
  required_rubygems_version: !ruby/object:Gem::Requirement
141
- none: false
142
123
  requirements:
143
- - - ! '>='
124
+ - - ">="
144
125
  - !ruby/object:Gem::Version
145
126
  version: '0'
146
127
  requirements: []
147
- rubyforge_project: seattlerb
148
- rubygems_version: 1.8.23
128
+ rubyforge_project:
129
+ rubygems_version: 2.4.5
149
130
  signing_key:
150
- specification_version: 3
151
- summary: MogileFS client library for Ruby
152
- test_files:
153
- - test/test_http_reader.rb
154
- - test/test_mogilefs_integration_list_keys.rb
155
- - test/test_db_backend.rb
156
- - test/test_mogilefs_socket_pure.rb
157
- - test/test_mysql.rb
158
- - test/test_backend.rb
159
- - test/test_mogilefs.rb
160
- - test/test_mogtool_bigfile.rb
161
- - test/test_client.rb
162
- - test/test_admin.rb
163
- - test/test_mogilefs_socket_kgio.rb
164
- - test/test_mogilefs_integration.rb
165
- - test/test_fresh.rb
166
- - test/test_pool.rb
167
- - test/test_bigfile.rb
168
- - test/test_mogilefs_integration_large_pipe.rb
169
- - test/test_mogstored_rack.rb
170
- - test/socket_test.rb
131
+ specification_version: 4
132
+ summary: client - MogileFS client library for Ruby
133
+ test_files: []