|
|
@ -3,6 +3,17 @@ require "./spec_helper" |
|
|
|
describe Crystal::Scatter do |
|
|
|
# TODO: Write tests |
|
|
|
|
|
|
|
it "add elements to RingGraphs" do |
|
|
|
rg = Crystal::Scatter::RingGraph.new |
|
|
|
rg.add(UInt64.new(1),[0,0,0,0,0,0],"OSD0") |
|
|
|
rg.add(UInt64.new(1),[0,0,0,0,0,1],"OSD1") |
|
|
|
rg.add(UInt64.new(1),[0,0,0,0,1,0],"OSD2") |
|
|
|
rg.get_weight.should eq(3) |
|
|
|
rg.generate_ring(BigRational.new(1)) |
|
|
|
rg[0][0][0][0][0][0].range_effector.not_nil!.[0].should eq(0) |
|
|
|
rg[0][0][0][0][1][0].range_effector.not_nil!.[1].should eq(UInt64::MAX) |
|
|
|
end |
|
|
|
|
|
|
|
it "slices data into multiple pods" do |
|
|
|
mr = Crystal::Scatter::MetaRing.new(3) |
|
|
|
mr.add Crystal::Scatter::Daemon.new(1,[0,0,0,0,0,0],"OSD0") |
|
|
@ -18,17 +29,6 @@ describe Crystal::Scatter do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
it "add elements to RingGraphs" do |
|
|
|
rg = Crystal::Scatter::RingGraph.new |
|
|
|
rg.add(UInt64.new(1),[0,0,0,0,0,0],"OSD0") |
|
|
|
rg.add(UInt64.new(1),[0,0,0,0,0,1],"OSD1") |
|
|
|
rg.add(UInt64.new(1),[0,0,0,0,1,0],"OSD2") |
|
|
|
rg.get_weight.should eq(3) |
|
|
|
rg.generate_ring(BigRational.new(1)) |
|
|
|
rg[0][0][0][0][0][0].range_effector.not_nil!.[0].should eq(0) |
|
|
|
rg[0][0][0][0][1][0].range_effector.not_nil!.[1].should eq(UInt64::MAX) |
|
|
|
end |
|
|
|
|
|
|
|
it "hashes data fast" do |
|
|
|
v = Crystal::Scatter::MetaRing.new(3) |
|
|
|
time = Time.now |
|
|
|