Permalink
Browse files

Retry intermittently failing specs and produce failures rather than p…

…ending if test server fails.
  • Loading branch information...
1 parent cb20fb0 commit 678f08b256357d9176da44a73a06e18be2221456 @seancribbs seancribbs committed Feb 1, 2012
@@ -154,12 +154,15 @@ def threads(n, opts = {})
end
it 'should mapreduce in parallel' do
- # On a fresh node, this module might not have been loaded yet and
- # the mapred test exposes a race condition in riak_pipe_v when
- # verifying function validity.
- test_server.with_console do |console|
- console.command 'code:load(riak_kv_pipe_get).'
- console.command 'code:load(riak_kv_mrc_map).'
+ if ("1.0.0"..."1.1.0").include?(test_server.version)
+ # On a fresh node, this module might not have been loaded yet
+ # and the mapred test exposes a race condition in riak_pipe_v
+ # when verifying function validity. This race condition is
+ # fixed in 1.1.
+ test_server.with_console do |console|
+ console.command 'code:load(riak_kv_pipe_get), ok.'
+ console.command 'code:load(riak_kv_mrc_map), ok.'
+ end
end
count = 10
View
@@ -11,6 +11,7 @@
%w[integration_setup
version_filter
+ sometimes
http_backend_implementation_examples
unified_backend_examples
mocks
View
@@ -0,0 +1,16 @@
+# Emulates the QuickCheck ?SOMETIMES macro.
+
+RSpec.configure do |config|
+ config.around(:each, :max_retries => lambda { |m| !!m }) do |example|
+ retries = example.metadata[:max_retries]
+ begin
+ example.run
+ rescue => e
+ retries -= 1
+ retry if retries >= 0
+ raise
+ end
+ end
+end
+
+RSpec::Core::ExampleGroup.define_example_method :sometimes, :max_retries => 3
@@ -6,22 +6,19 @@ def test_server
begin
require 'yaml'
config = YAML.load_file(File.expand_path("../test_server.yml", __FILE__))
- server = Riak::TestServer.create(:root => config['root'],
+ $test_server = Riak::TestServer.create(:root => config['root'],
:source => config['source'],
:min_port => config['min_port'] || 15000)
- $test_server = server
rescue SocketError => e
- crash_log = $test_server.log + 'crash.log'
warn "Couldn't connect to Riak TestServer! #{$test_server.inspect}"
warn "Skipping remaining integration tests."
- warn crash_log.read if crash_log.exist?
+ warn_crash_log
$test_server_fatal = e
rescue => e
- crash_log = $test_server.log + 'crash.log'
warn "Can't run integration specs without the test server. Please create/verify spec/support/test_server.yml."
warn "Skipping remaining integration tests."
warn e.inspect
- warn crash_log.read if crash_log.exist?
+ warn_crash_log
$test_server_fatal = e
end
end
@@ -31,13 +28,19 @@ def test_server
def test_server_fatal
$test_server_fatal
end
+
+ def warn_crash_log
+ if $test_server && crash_log = $test_server.log + 'crash.log'
+ warn crash_log.read if crash_log.exist?
+ end
+ end
end
RSpec.configure do |config|
config.include TestServerSupport, :integration => true
config.before(:each, :integration => true) do
- pending "Test server not working: #{test_server_fatal}" if test_server_fatal
+ fail "Test server not working: #{test_server_fatal}" if test_server_fatal
if example.metadata[:test_server] == false
test_server.stop
else
@@ -45,9 +45,8 @@
end
it "should marshal indexes properly", :version => "1.0.0" do
- # This really tests both storing and fetching indexes, given the setup
@robject.indexes['test_bin'] << 'pass'
- @backend.store_object(@robject)
+ @backend.store_object(@robject, :w => :all, :dw => :all)
robj = @backend.fetch_object('test', 'fetch')
robj.indexes['test_bin'].should be

0 comments on commit 678f08b

Please sign in to comment.