diff --git a/test/gizzmo_spec.rb b/test/gizzmo_spec.rb index c33faba..0fb55ae 100644 --- a/test/gizzmo_spec.rb +++ b/test/gizzmo_spec.rb @@ -421,5 +421,79 @@ def nameserver link(id("localhost", "s_0_002_replicating"), id("127.0.0.1", "s_0_0002"), 1), link(id("localhost", "s_0_002_replicating"), id("localhost", "s_0_002_a"), 1) ] end + + it "works with multiple forwarding tables" do + 0.upto(1) do |table| + 1.upto(2) do |i| + gizzmo "create TestShard -s Int -d Int localhost/s_#{table}_00#{i}_a" + #gizzmo "create TestShard -s Int -d Int 127.0.0.1/s_#{table}_000#{i}_b" + gizzmo "create ReplicatingShard localhost/s_#{table}_00#{i}_replicating" + gizzmo "addlink localhost/s_#{table}_00#{i}_replicating localhost/s_#{table}_00#{i}_a 1" + #gizzmo "addlink localhost/s_#{table}_00#{i}_replicating 127.0.0.1/s_#{table}_000#{i}_b 1" + gizzmo "addforwarding #{table} #{i} localhost/s_#{table}_00#{i}_replicating" + end + end + gizzmo "-f reload" + + gizzmo('-f -T0,1 transform --no-progress --poll-interval=1 "ReplicatingShard -> TestShard(localhost,1,Int,Int)" "ReplicatingShard -> (TestShard(localhost,1,Int,Int), TestShard(127.0.0.1))"').should == <<-EOF +ReplicatingShard(1) -> TestShard(localhost,1,Int,Int) => ReplicatingShard(1) -> (TestShard(localhost,1,Int,Int), TestShard(127.0.0.1,1)) : + PREPARE + create_shard(TestShard/127.0.0.1) + create_shard(WriteOnlyShard) + add_link(WriteOnlyShard -> TestShard/127.0.0.1) + add_link(ReplicatingShard -> WriteOnlyShard) + COPY + copy_shard(TestShard/127.0.0.1) + CLEANUP + add_link(ReplicatingShard -> TestShard/127.0.0.1) + remove_link(WriteOnlyShard -> TestShard/127.0.0.1) + remove_link(ReplicatingShard -> WriteOnlyShard) + delete_shard(WriteOnlyShard) +Applied to: + [0] 1 = localhost/s_0_001_replicating + [0] 2 = localhost/s_0_002_replicating + [1] 1 = localhost/s_1_001_replicating + [1] 2 = localhost/s_1_002_replicating + +STARTING: + [0] 1 = localhost/s_0_001_replicating: ReplicatingShard(1) -> TestShard(localhost,1,Int,Int) => ReplicatingShard(1) -> (TestShard(localhost,1,Int,Int), TestShard(127.0.0.1,1)) + [0] 2 = localhost/s_0_002_replicating: ReplicatingShard(1) -> TestShard(localhost,1,Int,Int) => ReplicatingShard(1) -> (TestShard(localhost,1,Int,Int), TestShard(127.0.0.1,1)) + [1] 1 = localhost/s_1_001_replicating: ReplicatingShard(1) -> TestShard(localhost,1,Int,Int) => ReplicatingShard(1) -> (TestShard(localhost,1,Int,Int), TestShard(127.0.0.1,1)) + [1] 2 = localhost/s_1_002_replicating: ReplicatingShard(1) -> TestShard(localhost,1,Int,Int) => ReplicatingShard(1) -> (TestShard(localhost,1,Int,Int), TestShard(127.0.0.1,1)) +COPIES: + localhost/s_0_001_a -> 127.0.0.1/s_0_0001 + localhost/s_0_002_a -> 127.0.0.1/s_0_0002 + localhost/s_1_001_a -> 127.0.0.1/s_1_0001 + localhost/s_1_002_a -> 127.0.0.1/s_1_0002 +FINISHING: + [0] 1 = localhost/s_0_001_replicating: ReplicatingShard(1) -> TestShard(localhost,1,Int,Int) => ReplicatingShard(1) -> (TestShard(localhost,1,Int,Int), TestShard(127.0.0.1,1)) + [0] 2 = localhost/s_0_002_replicating: ReplicatingShard(1) -> TestShard(localhost,1,Int,Int) => ReplicatingShard(1) -> (TestShard(localhost,1,Int,Int), TestShard(127.0.0.1,1)) + [1] 1 = localhost/s_1_001_replicating: ReplicatingShard(1) -> TestShard(localhost,1,Int,Int) => ReplicatingShard(1) -> (TestShard(localhost,1,Int,Int), TestShard(127.0.0.1,1)) + [1] 2 = localhost/s_1_002_replicating: ReplicatingShard(1) -> TestShard(localhost,1,Int,Int) => ReplicatingShard(1) -> (TestShard(localhost,1,Int,Int), TestShard(127.0.0.1,1)) +4 transformations applied. Total time elapsed: 1 second + EOF + + nameserver[:shards].should == [ info("127.0.0.1", "s_0_0001", "TestShard"), + info("127.0.0.1", "s_0_0002", "TestShard"), + info("127.0.0.1", "s_1_0001", "TestShard"), + info("127.0.0.1", "s_1_0002", "TestShard"), + info("localhost", "s_0_001_a", "TestShard", "Int", "Int"), + info("localhost", "s_0_001_replicating", "ReplicatingShard"), + info("localhost", "s_0_002_a", "TestShard", "Int", "Int"), + info("localhost", "s_0_002_replicating", "ReplicatingShard"), + info("localhost", "s_1_001_a", "TestShard", "Int", "Int"), + info("localhost", "s_1_001_replicating", "ReplicatingShard"), + info("localhost", "s_1_002_a", "TestShard", "Int", "Int"), + info("localhost", "s_1_002_replicating", "ReplicatingShard") ] + + nameserver[:links].should == [ link(id("localhost", "s_0_001_replicating"), id("127.0.0.1", "s_0_0001"), 1), + link(id("localhost", "s_0_001_replicating"), id("localhost", "s_0_001_a"), 1), + link(id("localhost", "s_0_002_replicating"), id("127.0.0.1", "s_0_0002"), 1), + link(id("localhost", "s_0_002_replicating"), id("localhost", "s_0_002_a"), 1), + link(id("localhost", "s_1_001_replicating"), id("127.0.0.1", "s_1_0001"), 1), + link(id("localhost", "s_1_001_replicating"), id("localhost", "s_1_001_a"), 1), + link(id("localhost", "s_1_002_replicating"), id("127.0.0.1", "s_1_0002"), 1), + link(id("localhost", "s_1_002_replicating"), id("localhost", "s_1_002_a"), 1) ] + end end end