Merge "Remove logic for old swift-ring-builder"
This commit is contained in:
@@ -20,55 +20,21 @@ class Puppet::Provider::SwiftRingBuilder < Puppet::Provider
|
||||
def lookup_ring
|
||||
object_hash = {}
|
||||
if File.exists?(builder_file_path(policy_index))
|
||||
# Swift < 2.2.2 Skip first 4 info lines from swift-ring-builder output
|
||||
if rows = swift_ring_builder(builder_file_path(policy_index)).split("\n")[4..-1]
|
||||
# Skip "Ring file ... is up-to-date" message, if printed.
|
||||
if !rows[0].nil? and rows[0] =~ /Ring file\b.*\bis up-to-date/
|
||||
rows.shift
|
||||
end
|
||||
# Swift 2.2.2+ Skip additional line to account for Overload info
|
||||
if !rows[0].nil? and rows[0].start_with?('Devices:')
|
||||
rows.shift
|
||||
if rows = swift_ring_builder(builder_file_path(policy_index)).split("\n")
|
||||
while row = rows.shift do
|
||||
if row.start_with?('Devices:')
|
||||
break
|
||||
end
|
||||
end
|
||||
rows.each do |row|
|
||||
# Swift 1.7+ output example:
|
||||
# /etc/swift/object.builder, build version 1
|
||||
# 262144 partitions, 1.000000 replicas, 1 regions, 1 zones, 1 devices, 0.00 balance, 0.00 dispersion
|
||||
# The minimum number of hours before a partition can be reassigned is 1
|
||||
# Devices: id region zone ip address port name weight partitions balance meta
|
||||
# 0 1 2 127.0.0.1 6022 2 1.00 262144 0.00
|
||||
# 0 1 3 192.168.101.15 6002 1 1.00 262144 -100.00
|
||||
#
|
||||
# Swift 1.8.0 output example:
|
||||
# /etc/swift/object.builder, build version 1
|
||||
# 262144 partitions, 1.000000 replicas, 1 regions, 1 zones, 1 devices, 0.00 balance, 0.00 dispersion
|
||||
# The minimum number of hours before a partition can be reassigned is 1
|
||||
# Devices: id region zone ip address port name weight partitions balance meta
|
||||
# 2 1 2 192.168.101.14 6002 1 1.00 262144 200.00 m2
|
||||
# 0 1 3 192.168.101.15 6002 1 1.00 262144-100.00 m2
|
||||
#
|
||||
# Swift 1.8+ output example:
|
||||
# /etc/swift/object.builder, build version 1
|
||||
# 262144 partitions, 1.000000 replicas, 1 regions, 1 zones, 1 devices, 0.00 balance, 0.00 dispersion
|
||||
# The minimum number of hours before a partition can be reassigned is 1
|
||||
# Devices: id region zone ip address port replication ip replication port name weight partitions balance meta
|
||||
# 0 1 2 127.0.0.1 6021 127.0.0.1 6021 2 1.00 262144 0.00
|
||||
#
|
||||
# Swift 2.2.2+ output example:
|
||||
# /etc/swift/object.builder, build version 1
|
||||
# 262144 partitions, 1.000000 replicas, 1 regions, 1 zones, 1 devices, 0.00 balance, 0.00 dispersion
|
||||
# The minimum number of hours before a partition can be reassigned is 1
|
||||
# The overload factor is 0.00% (0.000000)
|
||||
# Devices: id region zone ip address port replication ip replication port name weight partitions balance meta
|
||||
# 0 1 2 127.0.0.1 6021 127.0.0.1 6021 2 1.00 262144 0.00
|
||||
# Swift 2.9.1+ output example:
|
||||
# /etc/swift/object.builder, build version 1
|
||||
# 262144 partitions, 1.000000 replicas, 1 regions, 1 zones, 1 devices, 0.00 balance, 0.00 dispersion
|
||||
# The minimum number of hours before a partition can be reassigned is 1
|
||||
# The overload factor is 0.00% (0.000000)
|
||||
# Devices: id region zone ip address:port replication ip:replication port name weight partitions balance meta
|
||||
# 0 1 2 127.0.0.1:6021 127.0.0.1:6021 2 1.00 262144 0.00
|
||||
# Swift 2.9.1+ output example:
|
||||
# /etc/swift/object.builder, build version 1
|
||||
# 262144 partitions, 1.000000 replicas, 1 regions, 1 zones, 1 devices, 0.00 balance, 0.00 dispersion
|
||||
# The minimum number of hours before a partition can be reassigned is 1
|
||||
# The overload factor is 0.00% (0.000000)
|
||||
# Ring file /etc/swift/object.ring.gz is up-to-date
|
||||
# Devices: id region zone ip address:port replication ip:replication port name weight partitions balance meta
|
||||
# 0 1 2 127.0.0.1:6021 127.0.0.1:6021 2 1.00 262144 0.00
|
||||
if row =~ /^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S+):(\d+)\s+\S+:\d+\s+(\S+)\s+(\d+\.\d+)\s+(\d+)\s*((-|\s-?)?\d+\.\d+)\s*(\S*)/
|
||||
address = address_string("#{$4}")
|
||||
if !policy_index.nil?
|
||||
@@ -86,52 +52,6 @@ class Puppet::Provider::SwiftRingBuilder < Puppet::Provider
|
||||
:meta => $11,
|
||||
:policy_index => "#{policy_index}"
|
||||
}
|
||||
|
||||
# Swift 1.8+ output example:
|
||||
elsif row =~ /^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\d+)\s+\S+\s+\d+\s+(\S+)\s+(\d+\.\d+)\s+(\d+)\s*((-|\s-?)?\d+\.\d+)\s*(\S*)/
|
||||
|
||||
address = address_string("#{$4}")
|
||||
if !policy_index.nil?
|
||||
policy = "#{policy_index}:"
|
||||
else
|
||||
policy = ''
|
||||
end
|
||||
object_hash["#{policy}#{address}:#{$5}/#{$6}"] = {
|
||||
:id => $1,
|
||||
:region => $2,
|
||||
:zone => $3,
|
||||
:weight => $7,
|
||||
:partitions => $8,
|
||||
:balance => $9,
|
||||
:meta => $11
|
||||
}
|
||||
|
||||
# Swift 1.8.0 output example:
|
||||
elsif row =~ /^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\S+)\s+(\d+\.\d+)\s+(\d+)\s*((-|\s-?)?\d+\.\d+)\s*(\S*)/
|
||||
|
||||
address = address_string("#{$4}")
|
||||
object_hash["#{address}:#{$5}/#{$6}"] = {
|
||||
:id => $1,
|
||||
:region => $2,
|
||||
:zone => $3,
|
||||
:weight => $7,
|
||||
:partitions => $8,
|
||||
:balance => $9,
|
||||
:meta => $11
|
||||
}
|
||||
# This regex is for older swift versions
|
||||
elsif row =~ /^\s+(\d+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\S+)\s+(\d+\.\d+)\s+(\d+)\s+(-?\d+\.\d+)\s+(\S*)$/
|
||||
|
||||
address = address_string("#{$3}")
|
||||
object_hash["#{address}:#{$4}/#{$5}"] = {
|
||||
:id => $1,
|
||||
:region => 'none',
|
||||
:zone => $2,
|
||||
:weight => $6,
|
||||
:partitions => $7,
|
||||
:balance => $8,
|
||||
:meta => $9
|
||||
}
|
||||
else
|
||||
Puppet.warning("Unexpected line: #{row}")
|
||||
end
|
||||
|
@@ -30,11 +30,12 @@ describe provider_class do
|
||||
)
|
||||
end
|
||||
|
||||
let :account_builder_output_2_9_1 do
|
||||
let :account_builder_output do
|
||||
'/etc/swift/account.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
The overload factor is 0.00% (0.000000)
|
||||
Ring file /etc/swift/account.ring.gz is up-to-date
|
||||
Devices: id region zone ip address:port replic_ip:replic_port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13:6002 192.168.101.13:6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14:6002 192.168.101.14:6002 1 1.00 262144 200.00 m2
|
||||
@@ -43,7 +44,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
'
|
||||
end
|
||||
|
||||
describe "with no storage policy_index set on swift 2.9.1+" do
|
||||
describe "with no storage policy_index set" do
|
||||
|
||||
it 'account builder file should be account.builder when object name has no policy_index' do
|
||||
policy_index = provider.policy_index
|
||||
@@ -51,7 +52,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
end
|
||||
|
||||
it 'ring_account_device should exist when found in builder file' do
|
||||
provider.class.stubs(:swift_ring_builder).returns account_builder_output_2_9_1
|
||||
provider.class.stubs(:swift_ring_builder).returns account_builder_output
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
expect(provider.exists?).to eq({:id=>"1", :region=>"1", :zone=>"1", :weight=>"1.00", :partitions=>"262144", :balance=>"0.00", :meta=>"", :policy_index=>''})
|
||||
end
|
||||
@@ -59,7 +60,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
it 'should be able to lookup the local ring' do
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
provider.expects(:swift_ring_builder).returns account_builder_output_2_9_1
|
||||
provider.expects(:swift_ring_builder).returns account_builder_output
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
@@ -86,198 +87,11 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
end
|
||||
end
|
||||
|
||||
describe "with a storage policy_index set on swift 2.9.1+" do
|
||||
describe "with a storage policy_index set" do
|
||||
|
||||
it 'ring_account_device should fail when object name has a policy_index' do
|
||||
expect {
|
||||
Puppet::Type.type(:ring_account_device).new(:name => "1:192.168.101.13:6002/1", :zone => '1', :weight => '1', :provider => :swift_ring_builder)}.to raise_error(Puppet::Error, /Policy_index is not supported on account device/)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it 'should be able to lookup the local ring and build an object 2.2.2+' do
|
||||
# Swift 1.8 output
|
||||
provider.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/account.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
The overload factor is 0.00% (0.000000)
|
||||
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13 6002 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14 6002 192.168.101.14 6002 1 1.00 262144 200.00 m2
|
||||
0 1 3 192.168.101.15 6002 192.168.101.15 6002 1 1.00 262144-100.00 m2
|
||||
3 1 1 192.168.101.16 6002 192.168.101.16 6002 1 1.00 262144-100.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.16:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '200.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql 'm2'
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object 1.8+' do
|
||||
# Swift 1.8+ output
|
||||
provider_class.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/account.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13 6002 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14 6002 192.168.101.14 6002 1 1.00 262144 200.00 m2
|
||||
0 1 3 192.168.101.15 6002 192.168.101.15 6002 1 1.00 262144-100.00 m2
|
||||
3 1 1 192.168.101.16 6002 192.168.101.16 6002 1 1.00 262144-100.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.16:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '200.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql 'm2'
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object 1.8.0' do
|
||||
# Swift 1.8 output
|
||||
provider_class.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/account.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
Devices: id region zone ip address port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14 6002 1 1.00 262144 200.00 m2
|
||||
0 1 3 192.168.101.15 6002 1 1.00 262144-100.00 m2
|
||||
3 1 1 192.168.101.16 6002 1 1.00 262144-100.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.16:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '200.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql 'm2'
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object 1.7' do
|
||||
# Swift 1.7 output
|
||||
provider_class.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/account.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
Devices: id region zone ip address port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14 6002 1 1.00 262144 0.00
|
||||
0 1 3 192.168.101.15 6002 1 1.00 262144 0.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql ''
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object legacy' do
|
||||
provider_class.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/account.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
Devices: id zone ip address port name weight partitions balance meta
|
||||
2 2 192.168.101.14 6002 1 1.00 262144 0.00
|
||||
0 3 192.168.101.15 6002 1 1.00 262144 0.00
|
||||
1 1 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql 'none'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql 'none'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql ''
|
||||
end
|
||||
end
|
||||
|
@@ -27,11 +27,12 @@ describe provider_class do
|
||||
end
|
||||
|
||||
|
||||
let :container_builder_output_2_9_1 do
|
||||
let :container_builder_output do
|
||||
'/etc/swift/container.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
The overload factor is 0.00% (0.000000)
|
||||
Ring file /etc/swift/container.ring.gz is up-to-date
|
||||
Devices: id region zone ip address:port replic_ip:replic_port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13:6002 192.168.101.13:6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14:6002 192.168.101.14:6002 1 1.00 262144 200.00 m2
|
||||
@@ -40,7 +41,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
'
|
||||
end
|
||||
|
||||
describe "with no storage policy_index set on swift 2.9.1+" do
|
||||
describe "with no storage policy_index set" do
|
||||
|
||||
it 'container builder file should be container.builder when object name has no policy_index' do
|
||||
policy_index = provider.policy_index
|
||||
@@ -48,7 +49,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
end
|
||||
|
||||
it 'ring_container_device should exist when found in builder file' do
|
||||
provider.expects(:swift_ring_builder).returns container_builder_output_2_9_1
|
||||
provider.expects(:swift_ring_builder).returns container_builder_output
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
expect(provider.exists?).to eq({:id=>"1", :region=>"1", :zone=>"1", :weight=>"1.00", :partitions=>"262144", :balance=>"0.00", :meta=>"", :policy_index=>''})
|
||||
end
|
||||
@@ -56,7 +57,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
it 'should be able to lookup the local ring' do
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
provider.expects(:swift_ring_builder).returns container_builder_output_2_9_1
|
||||
provider.expects(:swift_ring_builder).returns container_builder_output
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
@@ -83,7 +84,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
end
|
||||
end
|
||||
|
||||
describe "with a storage policy_index set on swift 2.9.1+" do
|
||||
describe "with a storage policy_index set" do
|
||||
|
||||
it 'ring_container_device should fail when object name has a policy_index' do
|
||||
expect {
|
||||
@@ -95,190 +96,4 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
)}.to raise_error(Puppet::Error, /Policy_index is not supported on container device/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object 2.2.2+' do
|
||||
# Swift 1.8 output
|
||||
provider.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/container.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
The overload factor is 0.00% (0.000000)
|
||||
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13 6002 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14 6002 192.168.101.14 6002 1 1.00 262144 200.00 m2
|
||||
0 1 3 192.168.101.15 6002 192.168.101.15 6002 1 1.00 262144-100.00 m2
|
||||
3 1 1 192.168.101.16 6002 192.168.101.16 6002 1 1.00 262144-100.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.16:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '200.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql 'm2'
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object 1.8+' do
|
||||
# Swift 1.8+ output
|
||||
provider_class.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/container.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13 6002 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14 6002 192.168.101.14 6002 1 1.00 262144 200.00 m2
|
||||
0 1 3 192.168.101.15 6002 192.168.101.15 6002 1 1.00 262144-100.00 m2
|
||||
3 1 1 192.168.101.16 6002 192.168.101.16 6002 1 1.00 262144-100.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.16:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '200.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql 'm2'
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object 1.8.0' do
|
||||
# Swift 1.8 output
|
||||
provider_class.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/container.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
Devices: id region zone ip address port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14 6002 1 1.00 262144 200.00 m2
|
||||
0 1 3 192.168.101.15 6002 1 1.00 262144-100.00 m2
|
||||
3 1 1 192.168.101.16 6002 1 1.00 262144-100.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.16:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '200.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql 'm2'
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object 1.7' do
|
||||
# Swift 1.7 output
|
||||
provider_class.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/container.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
Devices: id region zone ip address port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14 6002 1 1.00 262144 0.00
|
||||
0 1 3 192.168.101.15 6002 1 1.00 262144 0.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql ''
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object legacy' do
|
||||
provider_class.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/container.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
Devices: id zone ip address port name weight partitions balance meta
|
||||
2 2 192.168.101.14 6002 1 1.00 262144 0.00
|
||||
0 3 192.168.101.15 6002 1 1.00 262144 0.00
|
||||
1 1 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql 'none'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql 'none'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql ''
|
||||
end
|
||||
end
|
||||
|
@@ -26,11 +26,12 @@ describe provider_class do
|
||||
)
|
||||
end
|
||||
|
||||
let :object_builder_output_2_9_1 do
|
||||
let :object_builder_output do
|
||||
'/etc/swift/object.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
The overload factor is 0.00% (0.000000)
|
||||
Ring file /etc/swift/object.ring.gz is up-to-date
|
||||
Devices: id region zone ip address:port replic_ip:replic_port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13:6002 192.168.101.13:6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14:6002 192.168.101.14:6002 1 1.00 262144 200.00 m2
|
||||
@@ -39,7 +40,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
'
|
||||
end
|
||||
|
||||
describe "with no storage policy_index set on swift 2.9.1+" do
|
||||
describe "with no storage policy_index set" do
|
||||
|
||||
it 'object builder file should be object.builder when object name has no policy_index' do
|
||||
policy_index = provider.policy_index
|
||||
@@ -60,7 +61,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
end
|
||||
|
||||
it 'ring_object_device should exist when found in builder file' do
|
||||
provider.expects(:swift_ring_builder).returns object_builder_output_2_9_1
|
||||
provider.expects(:swift_ring_builder).returns object_builder_output
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
expect(provider.exists?).to eq({:id=>"1", :region=>"1", :zone=>"1", :weight=>"1.00", :partitions=>"262144", :balance=>"0.00", :meta=>"", :policy_index=>''})
|
||||
end
|
||||
@@ -68,7 +69,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
it 'should be able to lookup the local ring' do
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
provider.expects(:swift_ring_builder).returns object_builder_output_2_9_1
|
||||
provider.expects(:swift_ring_builder).returns object_builder_output
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
@@ -110,11 +111,12 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
)
|
||||
end
|
||||
|
||||
let :object_builder_policy1_output_2_9_1 do
|
||||
let :object_builder_policy1_output do
|
||||
'/etc/swift/object-1.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
The overload factor is 0.00% (0.000000)
|
||||
Ring file /etc/swift/object-1.ring.gz is up-to-date
|
||||
Devices: id region zone ip address:port replic_ip:replic_port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13:6002 192.168.101.13:6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14:6002 192.168.101.14:6002 1 1.00 262144 200.00 m2
|
||||
@@ -123,7 +125,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
'
|
||||
end
|
||||
|
||||
describe "with a storage policy_index set on swift 2.9.1+" do
|
||||
describe "with a storage policy_index set" do
|
||||
|
||||
it 'object builder file should be object-1.builder when object name has policy_index 1' do
|
||||
policy_index = provider_policy1.policy_index
|
||||
@@ -136,7 +138,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
end
|
||||
|
||||
it 'ring_object_device should exist when found in builder file with policy_index=1' do
|
||||
provider_policy1.expects(:swift_ring_builder).returns object_builder_policy1_output_2_9_1
|
||||
provider_policy1.expects(:swift_ring_builder).returns object_builder_policy1_output
|
||||
File.expects(:exists?).with(builder_file_path_policy1).returns(true)
|
||||
expect(provider_policy1.exists?).to eq({:id=>"1", :region=>"1", :zone=>"1", :weight=>"1.00", :partitions=>"262144", :balance=>"0.00", :meta=>"", :policy_index=>"1"})
|
||||
end
|
||||
@@ -144,7 +146,7 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
it 'lookup local ring and object resource names should start with policy_index if a policy is set' do
|
||||
File.expects(:exists?).with(builder_file_path_policy1).returns(true)
|
||||
provider_policy1.expects(:builder_file_path).twice.returns(builder_file_path_policy1)
|
||||
provider_policy1.expects(:swift_ring_builder).returns object_builder_output_2_9_1
|
||||
provider_policy1.expects(:swift_ring_builder).returns object_builder_output
|
||||
resources = provider_policy1.lookup_ring
|
||||
expect(resources['1:192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['1:192.168.101.14:6002/1']).to_not be_nil
|
||||
@@ -170,191 +172,4 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
expect(resources['1:192.168.101.14:6002/1'][:policy_index]).to eql '1'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it 'should be able to lookup the local ring and build an object 2.2.2+' do
|
||||
# Swift 1.8 output
|
||||
provider.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/object.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
The overload factor is 0.00% (0.000000)
|
||||
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13 6002 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14 6002 192.168.101.14 6002 1 1.00 262144 200.00 m2
|
||||
0 1 3 192.168.101.15 6002 192.168.101.15 6002 1 1.00 262144-100.00 m2
|
||||
3 1 1 192.168.101.16 6002 192.168.101.16 6002 1 1.00 262144-100.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.16:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '200.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql 'm2'
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object 1.8+' do
|
||||
# Swift 1.8+ output
|
||||
provider_class.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/object.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13 6002 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14 6002 192.168.101.14 6002 1 1.00 262144 200.00 m2
|
||||
0 1 3 192.168.101.15 6002 192.168.101.15 6002 1 1.00 262144-100.00 m2
|
||||
3 1 1 192.168.101.16 6002 192.168.101.16 6002 1 1.00 262144-100.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.16:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '200.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql 'm2'
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object 1.8.0' do
|
||||
# Swift 1.8 output
|
||||
provider_class.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/object.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
Devices: id region zone ip address port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14 6002 1 1.00 262144 200.00 m2
|
||||
0 1 3 192.168.101.15 6002 1 1.00 262144-100.00 m2
|
||||
3 1 1 192.168.101.16 6002 1 1.00 262144-100.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.16:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '200.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql 'm2'
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object 1.7' do
|
||||
# Swift 1.7 output
|
||||
provider_class.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/object.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
Devices: id region zone ip address port name weight partitions balance meta
|
||||
1 1 1 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
2 1 2 192.168.101.14 6002 1 1.00 262144 0.00
|
||||
0 1 3 192.168.101.15 6002 1 1.00 262144 0.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql '1'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql ''
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring and build an object legacy' do
|
||||
provider_class.expects(:swift_ring_builder).returns(
|
||||
'/etc/swift/object.builder, build version 3
|
||||
262144 partitions, 3 replicas, 3 zones, 3 devices, 0.00 balance
|
||||
The minimum number of hours before a partition can be reassigned is 1
|
||||
Devices: id zone ip address port name weight partitions balance meta
|
||||
2 2 192.168.101.14 6002 1 1.00 262144 0.00
|
||||
0 3 192.168.101.15 6002 1 1.00 262144 0.00
|
||||
1 1 192.168.101.13 6002 1 1.00 262144 0.00
|
||||
'
|
||||
)
|
||||
File.expects(:exists?).with(builder_file_path).returns(true)
|
||||
provider.expects(:builder_file_path).twice.returns(builder_file_path)
|
||||
resources = provider.lookup_ring
|
||||
expect(resources['192.168.101.15:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.13:6002/1']).to_not be_nil
|
||||
expect(resources['192.168.101.14:6002/1']).to_not be_nil
|
||||
|
||||
expect(resources['192.168.101.13:6002/1'][:id]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:region]).to eql 'none'
|
||||
expect(resources['192.168.101.13:6002/1'][:zone]).to eql '1'
|
||||
expect(resources['192.168.101.13:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.13:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.13:6002/1'][:meta]).to eql ''
|
||||
|
||||
expect(resources['192.168.101.14:6002/1'][:id]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:region]).to eql 'none'
|
||||
expect(resources['192.168.101.14:6002/1'][:zone]).to eql '2'
|
||||
expect(resources['192.168.101.14:6002/1'][:weight]).to eql '1.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:partitions]).to eql '262144'
|
||||
expect(resources['192.168.101.14:6002/1'][:balance]).to eql '0.00'
|
||||
expect(resources['192.168.101.14:6002/1'][:meta]).to eql ''
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user