mogilefs-client 1.0.1
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/LICENSE +32 -0
- data/Manifest.txt +18 -0
- data/README +9 -0
- data/Rakefile +56 -0
- data/lib/mogilefs.rb +24 -0
- data/lib/mogilefs/admin.rb +274 -0
- data/lib/mogilefs/backend.rb +219 -0
- data/lib/mogilefs/client.rb +64 -0
- data/lib/mogilefs/httpfile.rb +144 -0
- data/lib/mogilefs/mogilefs.rb +214 -0
- data/lib/mogilefs/nfsfile.rb +81 -0
- data/lib/mogilefs/pool.rb +50 -0
- data/test/setup.rb +55 -0
- data/test/test_admin.rb +37 -0
- data/test/test_backend.rb +208 -0
- data/test/test_client.rb +49 -0
- data/test/test_mogilefs.rb +123 -0
- data/test/test_pool.rb +98 -0
- metadata +63 -0
data/test/test_pool.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
$TESTING = true
|
4
|
+
|
5
|
+
require 'mogilefs/pool'
|
6
|
+
|
7
|
+
class MogileFS::Pool
|
8
|
+
|
9
|
+
attr_reader :objects, :queue
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
class Resource; end
|
14
|
+
|
15
|
+
class ResourceWithArgs
|
16
|
+
|
17
|
+
def initialize(args)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class TestPool < Test::Unit::TestCase
|
23
|
+
|
24
|
+
def setup
|
25
|
+
@pool = MogileFS::Pool.new Resource
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_get
|
29
|
+
o1 = @pool.get
|
30
|
+
o2 = @pool.get
|
31
|
+
assert_kind_of Resource, o1
|
32
|
+
assert_kind_of Resource, o2
|
33
|
+
assert_not_equal o1, o2
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_get_with_args
|
37
|
+
@pool = MogileFS::Pool.new ResourceWithArgs, 'my arg'
|
38
|
+
o = @pool.get
|
39
|
+
assert_kind_of ResourceWithArgs, o
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_put
|
43
|
+
o = @pool.get
|
44
|
+
@pool.put o
|
45
|
+
|
46
|
+
assert_raises(MogileFS::Pool::BadObjectError) { @pool.put nil }
|
47
|
+
assert_raises(MogileFS::Pool::BadObjectError) { @pool.put Resource.new }
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_put_destroy
|
51
|
+
objs = (0...7).map { @pool.get } # pool full
|
52
|
+
|
53
|
+
assert_equal 7, @pool.objects.length
|
54
|
+
assert_equal 0, @pool.queue.length
|
55
|
+
|
56
|
+
4.times { @pool.put objs.shift }
|
57
|
+
|
58
|
+
assert_equal 7, @pool.objects.length
|
59
|
+
assert_equal 4, @pool.queue.length
|
60
|
+
|
61
|
+
@pool.put objs.shift # trip threshold
|
62
|
+
|
63
|
+
assert_equal 4, @pool.objects.length
|
64
|
+
assert_equal 2, @pool.queue.length
|
65
|
+
|
66
|
+
@pool.put objs.shift # don't need to remove any more
|
67
|
+
|
68
|
+
assert_equal 4, @pool.objects.length
|
69
|
+
assert_equal 3, @pool.queue.length
|
70
|
+
|
71
|
+
@pool.put objs.shift until objs.empty?
|
72
|
+
|
73
|
+
assert_equal 4, @pool.objects.length
|
74
|
+
assert_equal 4, @pool.queue.length
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_use
|
78
|
+
val = @pool.use { |o| assert_kind_of Resource, o }
|
79
|
+
assert_equal nil, val, "Don't return object from pool"
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_use_with_exception
|
83
|
+
@pool.use { |o| raise } rescue nil
|
84
|
+
assert_equal 1, @pool.queue.length, "Resource not returned to pool"
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_use_reuse
|
88
|
+
o1 = nil
|
89
|
+
o2 = nil
|
90
|
+
|
91
|
+
@pool.use { |o| o1 = o }
|
92
|
+
@pool.use { |o| o2 = o }
|
93
|
+
|
94
|
+
assert_equal o1, o2, "Objects must be reused"
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11.6
|
3
|
+
specification_version: 1
|
4
|
+
name: mogilefs-client
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 1.0.1
|
7
|
+
date: 2006-03-21 00:00:00 -08:00
|
8
|
+
summary: A Ruby MogileFS client
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: eric@robotcoop.com
|
12
|
+
homepage:
|
13
|
+
rubyforge_project:
|
14
|
+
description: A Ruby MogileFS client. MogileFS is a distributed filesystem written by Danga Interactive. This client supports NFS mode and has untested support for HTTP mode.
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Eric Hodel
|
31
|
+
files:
|
32
|
+
- LICENSE
|
33
|
+
- Manifest.txt
|
34
|
+
- README
|
35
|
+
- Rakefile
|
36
|
+
- lib/mogilefs.rb
|
37
|
+
- lib/mogilefs/admin.rb
|
38
|
+
- lib/mogilefs/backend.rb
|
39
|
+
- lib/mogilefs/client.rb
|
40
|
+
- lib/mogilefs/httpfile.rb
|
41
|
+
- lib/mogilefs/mogilefs.rb
|
42
|
+
- lib/mogilefs/nfsfile.rb
|
43
|
+
- lib/mogilefs/pool.rb
|
44
|
+
- test/setup.rb
|
45
|
+
- test/test_admin.rb
|
46
|
+
- test/test_backend.rb
|
47
|
+
- test/test_client.rb
|
48
|
+
- test/test_mogilefs.rb
|
49
|
+
- test/test_pool.rb
|
50
|
+
test_files: []
|
51
|
+
|
52
|
+
rdoc_options: []
|
53
|
+
|
54
|
+
extra_rdoc_files: []
|
55
|
+
|
56
|
+
executables: []
|
57
|
+
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
dependencies: []
|
63
|
+
|