diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-11-07 08:44:55 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-11-07 08:44:55 +0000 |
commit | 4f927415dc2a8e8dcaeda510d351192e3cc88747 (patch) | |
tree | edaed73c7025f26956454aad368b9075ec4d37dc /test/integration.rb | |
parent | 5a4650a07f394268884a8dad58fac42f9a9288c5 (diff) | |
download | mogilefs-client-4f927415dc2a8e8dcaeda510d351192e3cc88747.tar.gz |
We'll need to setup a fresh MogileFS instance for some tests.
Diffstat (limited to 'test/integration.rb')
-rw-r--r-- | test/integration.rb | 61 |
1 files changed, 2 insertions, 59 deletions
diff --git a/test/integration.rb b/test/integration.rb index cd63c3c..f3fd618 100644 --- a/test/integration.rb +++ b/test/integration.rb @@ -1,20 +1,8 @@ # -*- encoding: binary -*- -$stdout.sync = $stderr.sync = true -require 'test/unit' -require 'securerandom' -require 'tempfile' -require 'digest' -require 'stringio' -require 'pp' -require 'mogilefs' +require './test/exec' class TestMogIntegration < Test::Unit::TestCase - def uuid - SecureRandom.uuid - rescue NoMethodError - require "uuid" - UUID.generate - end + include TestExec def setup @to_close = [] @@ -29,51 +17,6 @@ class TestMogIntegration < Test::Unit::TestCase @domain = domain end - def yield_for_monitor_update # mogilefsd should update every 4 seconds - 50.times do - yield - sleep 0.1 - end - end - - def mogadm(*args) - x("mogadm", "--trackers=#{@trackers.join(',')}", *args) - end - - def x(*cmd) - out, err = tmpfile("out"), tmpfile("err") - puts cmd.join(' ') if $VERBOSE - pid = fork do - $stderr.reopen(err.path, "a") - $stdout.reopen(out.path, "a") - out.close - err.close - exec(*cmd) - end - _, status = Process.waitpid2(pid) - out.rewind - err.rewind - [ status, out, err ] - end - - def mogadm!(*args) - status, out, err = mogadm(*args) - assert status.success?, "#{status.inspect} / #{out.read} / #{err.read}" - [ status, out, err ] - end - - def x!(*cmd) - status, out, err = x(*cmd) - assert status.success?, "#{status.inspect} / #{out.read} / #{err.read}" - [ status, out, err ] - end - - def tmpfile(name) - tmp = Tempfile.new(name) - @to_close << tmp - tmp - end - def teardown if defined?(@domain) client = MogileFS::MogileFS.new :hosts => @trackers, :domain => @domain |