Created
August 1, 2010 05:25
-
-
Save alk/502980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
gem 'escape' | |
require 'escape' | |
require 'test/unit' | |
Dir.chdir(File.dirname(__FILE__) + "/moxi") | |
system 'make -j2' || exit(1) | |
$childs = [] | |
def Kernel.start_child(*args) | |
cmd_line = case args.length | |
when 1 | |
"port_adaptor 1 sh -c '#{args[0]}'" | |
else | |
Escape.shell_command(["port_adaptor", "1", *args]) | |
end | |
io = IO.popen(cmd_line, 'w') | |
puts "Started child: #{cmd_line.inspect} pid: #{io.pid}" | |
$childs << io | |
end | |
def Kernel.kill_childs! | |
$childs.each do |io| | |
pid = nil | |
begin | |
pid = io.pid | |
io.close_write | |
rescue IOError | |
pid = nil | |
end | |
Process.wait(pid) unless pid | |
end | |
$childs = [] | |
end | |
at_exit {Kernel.kill_childs!} | |
$u = "-u #{`whoami`.strip}" | |
class TS < Test::Unit::TestCase | |
def start_child(*args); Kernel.start_child(*args); end | |
def teardown | |
Kernel.kill_childs! | |
end | |
def sh(*args) | |
rv = system(*args) | |
assert rv | |
end | |
def test_moxi_all | |
sh './t/moxi_all.pl' | |
end | |
def test_a2a | |
start_child "./moxi-debug #{$u} -z ./t/moxi_mock.cfg -p 0 -U 0 -vvv -t 1 -Z downstream_max=1,downstream_protocol=ascii" | |
sh "python ./t/moxi_mock_a2a.py" | |
end | |
def test_a2b | |
start_child "./moxi-debug #{$u} -z ./t/moxi_mock.cfg -p 0 -U 0 -vvv -t 1 -Z downstream_max=1,downstream_protocol=binary" | |
sh "python ./t/moxi_mock_a2b.py" | |
end | |
def test_auth | |
start_child "ruby ./t/rest_mock.rb" | |
start_child "./moxi-debug #{$u} -z url=http://127.0.0.1:4567/pools/default/bucketsStreamingConfig/default -p 0 -U 0 -vvv -t 1 -Z usr=TheUser,pwd=ThePassword,port_listen=11333,downstream_max=1,downstream_protocol=binary" | |
sh "python ./t/moxi_mock_a2b_auth.py" | |
end | |
def test_b2b | |
start_child "./moxi-debug #{$u} -z ./t/moxi_mock.cfg -p 0 -U 0 -vvv -t 1 -Z downstream_max=1,downstream_protocol=binary" | |
sh "python ./t/moxi_mock_b2b.py" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment