Fixed FlexNBD#serve parameters, added detection of non-starting server.
This commit is contained in:
@@ -16,19 +16,24 @@ class FlexNBD
|
|||||||
@port = port
|
@port = port
|
||||||
end
|
end
|
||||||
|
|
||||||
def serve(ip, port, file, *acl)
|
def serve(file, *acl)
|
||||||
File.unlink(ctrl) if File.exists?(ctrl)
|
File.unlink(ctrl) if File.exists?(ctrl)
|
||||||
|
cmd ="#{@bin} serve "\
|
||||||
|
"--addr #{ip} "\
|
||||||
|
"--port #{port} "\
|
||||||
|
"--file #{file} "\
|
||||||
|
"--sock #{ctrl} "\
|
||||||
|
"#{@debug} "\
|
||||||
|
"#{acl.join(' ')}"
|
||||||
@pid = fork do
|
@pid = fork do
|
||||||
cmd ="#{@bin} serve "\
|
|
||||||
"--addr #{ip} "\
|
|
||||||
"--port #{port} "\
|
|
||||||
"--file #{file} "\
|
|
||||||
"--sock #{ctrl} "\
|
|
||||||
"#{@debug} "\
|
|
||||||
"#{acl.join(' ')}"
|
|
||||||
exec(cmd)
|
exec(cmd)
|
||||||
end
|
end
|
||||||
sleep 0.1 until File.socket?(ctrl)
|
while !File.socket?(ctrl)
|
||||||
|
pid, status = Process.wait2(@pid, Process::WNOHANG)
|
||||||
|
raise "server did not start (#{cmd})" if pid
|
||||||
|
sleep 0.1
|
||||||
|
end
|
||||||
|
at_exit { kill }
|
||||||
end
|
end
|
||||||
|
|
||||||
def kill
|
def kill
|
||||||
|
@@ -17,7 +17,6 @@ class NBDScenarios < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
@nbd1.kill rescue nil
|
|
||||||
[@filename1, @filename2].each do |f|
|
[@filename1, @filename2].each do |f|
|
||||||
File.unlink(f) if File.exists?(f)
|
File.unlink(f) if File.exists?(f)
|
||||||
end
|
end
|
||||||
@@ -73,7 +72,7 @@ class NBDScenarios < Test::Unit::TestCase
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
def serve1(*acl)
|
def serve1(*acl)
|
||||||
@nbd1.serve(@ip, @port1, @filename1, *acl)
|
@nbd1.serve(@filename1, *acl)
|
||||||
end
|
end
|
||||||
|
|
||||||
def writefile1(data)
|
def writefile1(data)
|
||||||
|
Reference in New Issue
Block a user