Navigation Menu

Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
add quick and dirty test for multiple tables
Browse files Browse the repository at this point in the history
  • Loading branch information
freels committed Jan 4, 2011
1 parent 18ce477 commit 2fbf82b
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions test/gizzmo_spec.rb
Expand Up @@ -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

0 comments on commit 2fbf82b

Please sign in to comment.