ceph_storage 0.1.0
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.
- checksums.yaml +7 -0
- data/.cluster.yml.example +19 -0
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +110 -0
- data/Guardfile +20 -0
- data/README.md +108 -0
- data/Rakefile +7 -0
- data/ceph_storage.gemspec +36 -0
- data/lib/ceph_storage.rb +28 -0
- data/lib/ceph_storage/cluster.rb +93 -0
- data/lib/ceph_storage/cluster_factory.rb +24 -0
- data/lib/ceph_storage/cluster_wrapper.rb +16 -0
- data/lib/ceph_storage/pool.rb +126 -0
- data/lib/ceph_storage/pool_enumerator.rb +24 -0
- data/lib/ceph_storage/pool_factory.rb +15 -0
- data/lib/ceph_storage/pool_wrapper.rb +17 -0
- data/lib/ceph_storage/storage_object.rb +48 -0
- data/lib/ceph_storage/storage_object/file_storage_object.rb +28 -0
- data/lib/ceph_storage/storage_object/rados_storage_object.rb +41 -0
- data/lib/ceph_storage/storage_object/rados_storage_object_enumerator.rb +29 -0
- data/lib/ceph_storage/storage_object/rados_wrapper.rb +21 -0
- data/lib/ceph_storage/storage_object/url_storage_object.rb +34 -0
- data/lib/ceph_storage/storage_object/xattr.rb +18 -0
- data/lib/ceph_storage/storage_object/xattr_enumerator.rb +29 -0
- data/lib/ceph_storage/version.rb +3 -0
- data/spec/ceph_storage_cluster_factory_spec.rb +14 -0
- data/spec/ceph_storage_cluster_spec.rb +76 -0
- data/spec/ceph_storage_file_storage_object_spec.rb +31 -0
- data/spec/ceph_storage_pool_enumerator.rb +34 -0
- data/spec/ceph_storage_pool_factory_spec.rb +14 -0
- data/spec/ceph_storage_pool_spec.rb +167 -0
- data/spec/ceph_storage_rados_storage_object_enumerator_spec.rb +72 -0
- data/spec/ceph_storage_rados_storage_object_spec.rb +112 -0
- data/spec/ceph_storage_storage_object_spec.rb +98 -0
- data/spec/ceph_storage_xattr_enumerator_spec.rb +75 -0
- data/spec/ceph_storage_xattr_spec.rb +69 -0
- data/spec/spec_helper.rb +30 -0
- data/tasks/rspec.rake +4 -0
- data/tasks/rubocop.rake +13 -0
- metadata +281 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
module CephStorage
|
2
|
+
module StorageObject
|
3
|
+
# Wrapper for RadosObjectEnumerator
|
4
|
+
class XattrEnumerator < ::CephRuby::XattrEnumerator
|
5
|
+
extend CephStorage::StorageObject::RadosWrapper
|
6
|
+
attr_accessor :pool_factory, :object
|
7
|
+
|
8
|
+
wrap_me :open, :close, :next_xattr_object
|
9
|
+
|
10
|
+
def initialize(object)
|
11
|
+
self.pool_factory = object.pool_factory
|
12
|
+
self.object = object
|
13
|
+
super(object)
|
14
|
+
end
|
15
|
+
|
16
|
+
def each
|
17
|
+
return enum_for(:each) unless block_given?
|
18
|
+
|
19
|
+
super do |x|
|
20
|
+
yield object.xattr(x.name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def log(message)
|
25
|
+
CephStorage.log("xattr_enumerator #{object.name} #{message}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CephStorage::ClusterFactory do
|
4
|
+
let(:cluster_factory) { CephStorage::ClusterFactory }
|
5
|
+
subject { cluster_factory }
|
6
|
+
|
7
|
+
it 'should respond to build' do
|
8
|
+
expect(subject).to respond_to :build
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should not respond to new' do
|
12
|
+
expect(subject).not_to respond_to :new
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CephStorage::Cluster do
|
4
|
+
let(:config) { cluster_config }
|
5
|
+
let(:cluster) { CephStorage::ClusterFactory.build config }
|
6
|
+
subject { cluster }
|
7
|
+
|
8
|
+
it 'should respond to rados_cluster' do
|
9
|
+
expect(subject).to respond_to :rados_cluster
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should respond to pool' do
|
13
|
+
expect(subject).to respond_to :pool
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should respond to open?' do
|
17
|
+
expect(subject).to respond_to :open?
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should respond to open' do
|
21
|
+
expect(subject).to respond_to :open
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should respond to shutdown' do
|
25
|
+
expect(subject).to respond_to :shutdown
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should respond to ensure open' do
|
29
|
+
expect(subject).to respond_to :ensure_open
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should be a ClusterFactory' do
|
33
|
+
expect(subject).to be_a CephStorage::ClusterFactory
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should be a ::CephRuby::Cluster' do
|
37
|
+
expect(subject).to be_a ::CephRuby::Cluster
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'calling build with the same attributes' do
|
41
|
+
let(:second_cluster) { CephStorage::ClusterFactory.build config }
|
42
|
+
it 'should be the same object as subject' do
|
43
|
+
expect(subject).to be(second_cluster)
|
44
|
+
end
|
45
|
+
|
46
|
+
let(:third_config) { config.clone }
|
47
|
+
before { third_config.delete(:flags) }
|
48
|
+
let(:third_cluster) { CephStorage::ClusterFactory.build third_config }
|
49
|
+
|
50
|
+
it 'should be the same when changing attribute to equivilent default' do
|
51
|
+
expect(subject).to be(third_cluster)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'Calling pool' do
|
56
|
+
let(:pool_name) { spec_config[:pool][:name] }
|
57
|
+
let(:pool) { cluster.pool(pool_name) }
|
58
|
+
subject { pool }
|
59
|
+
|
60
|
+
it 'should be a pool factory' do
|
61
|
+
expect(subject).to be_a CephStorage::PoolFactory
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'Calling inherited functions' do
|
66
|
+
describe 'status' do
|
67
|
+
it 'should not raise exception' do
|
68
|
+
expect { cluster.status }.not_to raise_exception
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should return a hash' do
|
72
|
+
expect(cluster.status).to be_a Hash
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CephStorage::StorageObject::FileStorageObject do
|
4
|
+
let(:config) { cluster_config }
|
5
|
+
let(:spconfig) { spec_config }
|
6
|
+
let(:object_name) { "/tmp/#{spconfig[:pool][:object_name]}" }
|
7
|
+
let(:storage_object) do
|
8
|
+
CephStorage::StorageObject::FileStorageObject.new(object_name, 'w+')
|
9
|
+
end
|
10
|
+
subject { storage_object }
|
11
|
+
|
12
|
+
it 'should be a FileStorageObject' do
|
13
|
+
expect(subject).to be_a ::CephStorage::StorageObject::FileStorageObject
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should be a ::File' do
|
17
|
+
expect(subject).to be_a ::File
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should be a StorageObject' do
|
21
|
+
expect(subject).to be_a ::CephStorage::StorageObject
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should respond to write_file' do
|
25
|
+
expect(subject).to respond_to :write_file
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should respond to read_file' do
|
29
|
+
expect(subject).to respond_to :read_file
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CephStorage::PoolEnumerator do
|
4
|
+
let(:config) { cluster_config }
|
5
|
+
let(:spconfig) { spec_config }
|
6
|
+
let(:cluster) { CephStorage::ClusterFactory.build config }
|
7
|
+
let(:pool_name) { spconfig[:pool][:name] }
|
8
|
+
let(:pool) { cluster.pool(pool_name) }
|
9
|
+
let(:object_name) { spconfig[:pool][:object] }
|
10
|
+
let(:pool_enumerator) { cluster.pools }
|
11
|
+
subject { pool_enumerator }
|
12
|
+
|
13
|
+
it 'should be a CephStorage::PoolEnumerator' do
|
14
|
+
expect(subject).to be_a ::CephStorage::PoolEnumerator
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'before pool creation' do
|
18
|
+
it 'should not have the test pool in it' do
|
19
|
+
expect(subject.any? { |p| p.name == pool_name }).to be false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'after pool creation' do
|
24
|
+
before { pool.create }
|
25
|
+
after { pool.destroy }
|
26
|
+
it 'should have the test pool in it' do
|
27
|
+
expect(subject.any? { |p| p.name == pool_name }).to be true
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should return pool objects' do
|
31
|
+
expect(subject.first).to be_a ::CephStorage::Pool
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CephStorage::PoolFactory do
|
4
|
+
let(:pool_factory) { CephStorage::PoolFactory }
|
5
|
+
subject { pool_factory }
|
6
|
+
|
7
|
+
it 'should respond to create' do
|
8
|
+
expect(subject).to respond_to :build
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should not respond to new' do
|
12
|
+
expect(subject).not_to respond_to :new
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CephStorage::Pool do
|
4
|
+
let(:config) { cluster_config }
|
5
|
+
let(:spconfig) { spec_config }
|
6
|
+
let(:cluster) { CephStorage::ClusterFactory.build config }
|
7
|
+
let(:pool_name) { spconfig[:pool][:name] }
|
8
|
+
let(:pool) { cluster.pool(pool_name) }
|
9
|
+
let(:object_name) { spconfig[:pool][:object] }
|
10
|
+
subject { pool }
|
11
|
+
|
12
|
+
it 'should be a PoolFactory' do
|
13
|
+
expect(subject).to be_a CephStorage::PoolFactory
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should respond to rados_pool' do
|
17
|
+
expect(subject).to respond_to :rados_pool
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should respond to rados_pool=' do
|
21
|
+
expect(subject).to respond_to :rados_pool=
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should respond to storage_object' do
|
25
|
+
expect(subject).to respond_to :storage_object
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should respond to storage_object_enumerator' do
|
29
|
+
expect(subject).to respond_to :storage_object_enumerator
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should respond to size' do
|
33
|
+
expect(subject).to respond_to :size
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should respond to num_locked' do
|
37
|
+
expect(subject).to respond_to :num_locked
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should respond to num_free' do
|
41
|
+
expect(subject).to respond_to :num_free
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should respond to close' do
|
45
|
+
expect(subject).to respond_to :close
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:rados_pool) { pool.rados_pool }
|
49
|
+
|
50
|
+
describe 'rados_pool method' do
|
51
|
+
subject { rados_pool }
|
52
|
+
it 'should be a CephRuby::Pool object' do
|
53
|
+
expect(subject).to be_a CephRuby::Pool
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should not equal another object popped off the stack' do
|
57
|
+
expect(subject).not_to equal(pool.rados_pool)
|
58
|
+
end
|
59
|
+
|
60
|
+
let(:rados_pool1) { pool.rados_pool { |p| return p } }
|
61
|
+
let(:rados_pool2) { pool.rados_pool { |p| return p } }
|
62
|
+
|
63
|
+
it 'should push the pool back on the queue when called with a block' do
|
64
|
+
expect(rados_pool1).to equal(rados_pool2)
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'when calling close on factory' do
|
68
|
+
it 'should close be closeable' do
|
69
|
+
expect { pool.close }.not_to raise_exception
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should have size 0' do
|
73
|
+
expect(pool.size).to eq(0)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'behaviour when popping then pushing' do
|
78
|
+
before(:each) { pool.rados_pool = pool.rados_pool }
|
79
|
+
|
80
|
+
it 'size should be 1 after popping and pushing' do
|
81
|
+
expect(pool.size).to eq(1)
|
82
|
+
expect(pool.num_free).to eq(1)
|
83
|
+
expect(pool.num_locked).to eq(0)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'size should still be 1 after doing that again' do
|
87
|
+
expect(pool.num_free).to eq(1)
|
88
|
+
expect(pool.num_locked).to eq(0)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'inherited methods' do
|
94
|
+
describe 'create' do
|
95
|
+
it 'should not throw exception' do
|
96
|
+
expect { subject.create }.not_to raise_exception
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe 'stat' do
|
101
|
+
subject { pool.stat }
|
102
|
+
it 'should not throw exception' do
|
103
|
+
expect { subject }.not_to raise_exception
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should be a Hash' do
|
107
|
+
expect(subject).to be_a Hash
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'id' do
|
112
|
+
subject { pool.id }
|
113
|
+
|
114
|
+
it 'should not throw an exception' do
|
115
|
+
expect { subject }.not_to raise_exception
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should return an integer' do
|
119
|
+
expect(subject).to be_a Fixnum
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe 'exists?' do
|
124
|
+
subject { pool.exists? }
|
125
|
+
|
126
|
+
it 'should not throw an exception' do
|
127
|
+
expect { subject }.not_to raise_exception
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should return true' do
|
131
|
+
expect(subject).to be true
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe 'auid' do
|
136
|
+
subject { pool.auid }
|
137
|
+
|
138
|
+
it 'should not throw an exception' do
|
139
|
+
expect { subject }.not_to raise_exception
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should return an integer' do
|
143
|
+
expect(subject).to be_a Fixnum
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe 'destroy' do
|
148
|
+
it 'should not throw an exception' do
|
149
|
+
expect { subject.destroy }.not_to raise_exception
|
150
|
+
end
|
151
|
+
describe 'after destroy' do
|
152
|
+
it 'should not exist' do
|
153
|
+
expect(subject.exists?).to be false
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe 'storage_object' do
|
160
|
+
let(:storage_object) { pool.storage_object(object_name) }
|
161
|
+
subject { storage_object }
|
162
|
+
|
163
|
+
it 'should be a CephStorage::StorageObject::RadosStorageObject' do
|
164
|
+
expect(subject).to be_a CephStorage::StorageObject::RadosStorageObject
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'logger'
|
3
|
+
describe CephStorage::StorageObject::RadosStorageObjectEnumerator do
|
4
|
+
let(:config) { cluster_config }
|
5
|
+
let(:spconfig) { spec_config }
|
6
|
+
let(:cluster) { CephStorage::ClusterFactory.build config }
|
7
|
+
let(:rule_id) { spconfig[:pool][:rule_id] }
|
8
|
+
let(:pool_name) { spconfig[:pool][:name] }
|
9
|
+
let(:pool) { cluster.pool(pool_name) }
|
10
|
+
|
11
|
+
describe 'pool creation' do
|
12
|
+
subject { pool }
|
13
|
+
it 'should be able to create pool' do
|
14
|
+
expect { subject.create(rule_id: rule_id) }.to_not raise_exception
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should be writable' do
|
18
|
+
expect { pool.stat }.not_to raise_exception
|
19
|
+
expect(pool.stat).to be_a Hash
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:object_name) { spconfig[:pool][:object_name] }
|
24
|
+
|
25
|
+
describe 'RadosStorageObjectEnumerator' do
|
26
|
+
let(:storage_object_enumerator) { pool.storage_object_enumerator }
|
27
|
+
subject { storage_object_enumerator }
|
28
|
+
|
29
|
+
it 'should be a StorageObject::RadosObjectEnumerator' do
|
30
|
+
expect(subject).to be_a(
|
31
|
+
::CephStorage::StorageObject::RadosStorageObjectEnumerator
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should be a CephRuby::RadosObjectEnumerator' do
|
36
|
+
expect(subject).to be_a ::CephRuby::RadosObjectEnumerator
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'before creation' do
|
40
|
+
it 'should not throw have any objects in it' do
|
41
|
+
expect(subject.inject(0) { |a, _e| a + 1 }).to be 0
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'after populating' do
|
46
|
+
before do
|
47
|
+
10.times do |i|
|
48
|
+
pool.storage_object("#{object_name}.#{i}").overwrite(
|
49
|
+
'some important content'
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should have 10 objects in it' do
|
55
|
+
expect(subject.inject(0) { |a, _e| a + 1 }).to be 10
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should return CephStorage::RadosStorageObject' do
|
59
|
+
expect(subject.first).to be_a(
|
60
|
+
CephStorage::StorageObject::RadosStorageObject
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'pool deletion' do
|
67
|
+
subject { pool }
|
68
|
+
it 'should be able to delete pool' do
|
69
|
+
expect { subject.destroy }.not_to raise_exception
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|