From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 31B5A1F70F for ; Thu, 26 Jan 2017 23:32:46 +0000 (UTC) From: Eric Wong To: mogilefs-client-public@bogomips.org Subject: [PATCH] test: switch to cmogstored for testing Content-Range PUTs Date: Thu, 26 Jan 2017 23:32:46 +0000 Message-Id: <20170126233246.30316-1-e@80x24.org> List-Id: mogstored_rack is long abandoned since I decided to work on cmogstored (in C, not Ruby :) instead. We still need this test since the original Perl mogstored does not yet support Content-Range: in PUT requests. --- test/fresh.rb | 8 ++- .../{test_mogstored_rack.rb => test_cmogstored.rb} | 71 +++++----------------- 2 files changed, 19 insertions(+), 60 deletions(-) rename test/{test_mogstored_rack.rb => test_cmogstored.rb} (74%) diff --git a/test/fresh.rb b/test/fresh.rb index 4c53ac2..972f834 100644 --- a/test/fresh.rb +++ b/test/fresh.rb @@ -42,7 +42,7 @@ def setup_mogilefs(plugins = nil) 50.times do break if File.size(@mogstored_pid.path) > 0 sleep 0.1 - end + end unless Integer === @mogstored_pid end def start_tracker @@ -108,10 +108,12 @@ def add_host_device_domain def teardown_mogilefs return if $$ != @teardown_pid - if @mogstored_pid + if Integer === @mogstored_pid + pid = @mogstored_pid + else pid = File.read(@mogstored_pid.path).to_i - Process.kill(:TERM, pid) if pid > 0 end + Process.kill(:TERM, pid) if pid > 0 if @mogilefsd_pid s = TCPSocket.new(@test_host, @tracker_port) s.write "!shutdown\r\n" diff --git a/test/test_mogstored_rack.rb b/test/test_cmogstored.rb similarity index 74% rename from test/test_mogstored_rack.rb rename to test/test_cmogstored.rb index de27c53..6c5f2f6 100644 --- a/test/test_mogstored_rack.rb +++ b/test/test_cmogstored.rb @@ -1,12 +1,5 @@ # -*- encoding: binary -*- require "./test/fresh" -begin - require 'mogstored_rack' - require 'unicorn' - ok = true -rescue LoadError - ok = false -end class TestMogstoredRack < Test::Unit::TestCase include TestFreshSetup @@ -136,60 +129,24 @@ def setup_mogstored @mogstored_http = TCPServer.new(@test_host, 0) @mogstored_mgmt_port = @mogstored_mgmt.addr[1] @mogstored_http_port = @mogstored_http.addr[1] - @mogstored_conf = Tempfile.new(["mogstored", "conf"]) - @mogstored_pid = Tempfile.new(["mogstored", "pid"]) - @mogstored_conf.write < 0 - sleep 0.1 + @mogstored_pid = fork do + mgmt_fd = @mogstored_mgmt.fileno + http_fd = @mogstored_http.fileno + args = [] + ENV["CMOGSTORED_FD"] = "#{mgmt_fd},#{http_fd}" + if @mogstored_mgmt.respond_to?(:close_on_exec=) + @mogstored_mgmt.close_on_exec = @mogstored_http.close_on_exec = false + args << { mgmt_fd => mgmt_fd, http_fd => http_fd } + end + $stderr.reopen('/dev/null', 'a') + exec "cmogstored", "--httplisten=#@test_host:#@mogstored_http_port", + "--mgmtlisten=#@test_host:#@mogstored_mgmt_port", + "--maxconns=1000", "--docroot=#@docroot", *args end end def teardown - pid = File.read(@unicorn_pid.path).to_i - Process.kill(:QUIT, pid) if pid > 0 teardown_mogilefs - puts(@unicorn_stderr.read) if $DEBUG end -end if ok && `which unicorn`.chomp.size > 0 +end if `which cmogstored`.chomp.size > 0 -- EW