Permalink
Browse files

improves test case of CAS

  • Loading branch information...
1 parent d16a506 commit 995fe9ece451059a9d2fbd1665284eaf9bc703a6 @frsyuki frsyuki committed May 14, 2010
Showing with 26 additions and 4 deletions.
  1. +26 −4 rt/09_cas.rt
View
@@ -4,7 +4,7 @@ require 'common'
include Chukan::Test
LOOP_RESTART = (ARGV[0] || ENV["LOOP_RESTART"] || (ENV["HEAVY"] ? 20 : 3)).to_i
-NUM_STORE = (ARGV[2] || 500).to_i
+NUM_STORE = (ARGV[2] || 5).to_i
NUM_THREAD = (ARGV[3] || 1).to_i
mgr, gw, srv1, srv2, srv3 = init_cluster(false, 3)
@@ -33,18 +33,39 @@ test "run normally" do
LOOP_RESTART.times {
NUM_STORE.times do |i|
- test "cas value" do
+ test "cas fail" do
c = gw.client
key = keyf % i
val = valf % i
+
begin
- c.cas(key) do |val|
+
+ result = c.cas(key) do |val|
+
+ test "cas success" do
+ begin
+ c.cas(key) do |val2|
+ "val#{i}"
+ end
+ rescue
+ raise "cas failed #{key.inspect} => #{val.inspect}: #{$!.inspect}"
+ end
+ end
+
"val#{i}"
end
- true
+
+ if result =~ /EXISTS/
+ true
+ else
+ $stderr.puts "cas unexpectedly succeeded #{key.inspect} => #{val.inspect}: #{$!.inspect}"
+ false
+ end
+
rescue
raise "cas failed #{key.inspect} => #{val.inspect}: #{$!.inspect}"
end
+
end
end
@@ -54,5 +75,6 @@ test "run normally" do
true
end
+
term_daemons *((mgrs + srvs).map {|r| r.get } + [gw])

0 comments on commit 995fe9e

Please sign in to comment.