From 63cc3ee529250a6b09dd7e032dc73ec509000c0f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 16 Jan 2015 03:09:09 +0000 Subject: tests: create fresh intances for all integration tests This should make it easier to fully test on machines without access to an existing MogileFS instance. You'll still need mogilefsd and mogstored available, however, but these tests are skipped on machines without them. --- test/test_mogilefs_integration.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'test/test_mogilefs_integration.rb') diff --git a/test/test_mogilefs_integration.rb b/test/test_mogilefs_integration.rb index 3c79308..6d16cd7 100644 --- a/test/test_mogilefs_integration.rb +++ b/test/test_mogilefs_integration.rb @@ -1,12 +1,16 @@ # -*- encoding: binary -*- -require './test/integration' +require './test/fresh' -class TestMogileFSIntegration < TestMogIntegration +class TestMogileFSIntegration < Test::Unit::TestCase + include TestFreshSetup def setup - super + setup_mogilefs + add_host_device_domain @client = MogileFS::MogileFS.new(:hosts => @trackers, :domain => @domain) end + alias teardown teardown_mogilefs + def test_CRUD assert ! @client.exist?("CRUD") assert_equal 4, @client.store_content("CRUD", "default", "DATA") @@ -157,9 +161,14 @@ class TestMogileFSIntegration < TestMogIntegration end end - # TODO: move this to a fresh instance def test_admin_each_fid admin = MogileFS::Admin.new(:hosts => @trackers) + input = %w(a b c d e) + input.each do |k| + rv = @client.new_file(k) + rv.write(k) + assert_nil rv.close + end seen = {} count = admin.each_fid do |info| seen[info["fid"]] = true @@ -171,7 +180,8 @@ class TestMogileFSIntegration < TestMogIntegration assert_kind_of String, info["domain"] end assert_equal count, seen.size - end if ENV["TEST_EXPENSIVE"] + assert_equal count, input.size + end def test_new_file_no_block rv = @client.new_file("no_block") -- cgit v1.2.3-24-ge0c7