Permalink
Browse files

tiny fixes to tests

  • Loading branch information...
1 parent 3672c5f commit 9d95089e91662df2d2191ebf65082ea73c965e96 @funny-falcon funny-falcon committed Aug 3, 2012
Showing with 24 additions and 16 deletions.
  1. +19 −6 test/helper.rb
  2. +5 −10 test/shared_replicated_shard.rb
View
@@ -91,11 +91,25 @@ def self.clear(name)
conf.delete :dir
end
+ def self.clear_all
+ CONF.keys.each{|name| clear(name) }
+ end
+
def self.reset_and_up_all
- CONF.keys.each{|name|
- clear(name)
- run(name)
- }
+ clear_all
+ CONF.keys.each{|name| run(name) }
+ end
+
+ def self.reset_and_up_masters
+ clear_masters
+ run(:master1)
+ run(:master2)
+ sleep(0.01)
+ end
+
+ def self.clear_masters
+ clear(:master1)
+ clear(:master2)
end
def self.conf(name)
@@ -115,7 +129,6 @@ def self.promote_to_master(name)
end
def self.promote_to_slave(slave, master)
- conf = CONF.fetch(slave)
clear(slave)
prepare(slave)
fcfg = fjoin(dir(slave), 'tarantool.cfg')
@@ -293,7 +306,7 @@ def shared_examples_for(desc, &block)
end
def it_behaves_like(desc)
- class_eval &MiniTest::Spec.shared_examples.fetch(desc)
+ class_eval(&MiniTest::Spec.shared_examples.fetch(desc))
end
end
@@ -3,6 +3,7 @@
shared_examples_for 'replication and shards' do
before { TConf.reset_and_up_all }
+ after { TConf.clear_all }
let(:t_both) {
Tarantool.new(type: tarantool_type,
@@ -89,7 +90,7 @@
let(:space_second){ space1_array_second }
before {
blockrun {
- 100.times.map{|i|
+ 100.times{|i|
space_both.insert([i, "#{i+1}", i+2])
}
}
@@ -132,10 +133,6 @@
end
end
- describe "array space with default shard" do
- it_behaves_like "array space with simple shard"
- end
-
describe "array space with modulo shard" do
let(:shard_proc1) { :modulo }
it_behaves_like "array space with simple shard"
@@ -147,7 +144,7 @@
let(:space_second){ space1_hash_second }
before {
blockrun {
- 100.times.map{|i|
+ 100.times{|i|
space_both.insert({id: i, name: "#{i+1}", val: i+2})
}
}
@@ -190,10 +187,6 @@
end
end
- describe "hash space with default shard" do
- it_behaves_like "hash space with simple shard"
- end
-
describe "hash space with modulo shard" do
let(:shard_proc1) { :modulo }
it_behaves_like "hash space with simple shard"
@@ -374,6 +367,7 @@ def iii(pk) {first: pk[0], second: pk[1], third: pk.hash & 0xffffff} end
end
describe "array space with shard on not pk" do
+ let(:shard_proc0) { :modulo }
let(:shard_fields_array0) { [3] }
let(:space_both){ space0_array_both }
let(:space_first){ space0_array_first }
@@ -439,6 +433,7 @@ def iii(pk) {first: pk[0], second: pk[1], third: pk.hash & 0xffffff} end
end
describe "hash space with shard on not pk" do
+ let(:shard_proc0) { :modulo }
let(:shard_fields_hash0) { [:score] }
let(:space_both){ space0_hash_both }
let(:space_first){ space0_hash_first }

0 comments on commit 9d95089

Please sign in to comment.