diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-07-12 02:53:17 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-07-12 06:44:08 +0000 |
commit | 0e5d6c6f4b28a75853d1020f07e493632031a054 (patch) | |
tree | 42e6fca7a5ffcaf7dfc1aa4efbab47081dfde0f3 /test | |
parent | 1c9fe8380f14e2b67bed99d16ef465db8d379b41 (diff) | |
download | cmogstored-0e5d6c6f4b28a75853d1020f07e493632031a054.tar.gz |
This is Perlbal functionality which works in Perl mogstored, so we will also support it here, as it makes upgrading to new versions easier.
Diffstat (limited to 'test')
-rw-r--r-- | test/http-parser-1.c | 4 | ||||
-rw-r--r-- | test/mgmt_persist_client.rb | 64 | ||||
-rw-r--r-- | test/ruby.mk | 2 |
3 files changed, 67 insertions, 3 deletions
diff --git a/test/http-parser-1.c b/test/http-parser-1.c index 053237a..138dc7f 100644 --- a/test/http-parser-1.c +++ b/test/http-parser-1.c @@ -3,7 +3,7 @@ * License: GPLv3 or later (see COPYING for details) */ #include "check.h" - +static struct mog_svc svc = { .persist_client = 1 }; static struct mog_http xhttp; static struct mog_http *http = &xhttp; static char *buf; @@ -21,7 +21,7 @@ static void assert_path_equal(const char *str) static void reset(void) { free(buf); - mog_http_init(http, NULL); + mog_http_init(http, &svc); } static void buf_set(const char *s) diff --git a/test/mgmt_persist_client.rb b/test/mgmt_persist_client.rb new file mode 100644 index 0000000..00c59f7 --- /dev/null +++ b/test/mgmt_persist_client.rb @@ -0,0 +1,64 @@ +#!/usr/bin/env ruby +# -*- encoding: binary -*- +require 'test/test_helper' +require 'net/http' + +class TestMgmtPersistClient < Test::Unit::TestCase + def setup + @tmpdir = Dir.mktmpdir('mgmt-persist-client-test') + @host = TEST_HOST + + srv = TCPServer.new(@host, 0) + @port = srv.addr[1] + srv.close + + srv = TCPServer.new(@host, 0) + @httpport = srv.addr[1] + srv.close + + @pid = nil + @to_close = [] + @err = Tempfile.new("stderr") + Dir.mkdir("#@tmpdir/dev666") + cmd = [ "cmogstored", "--docroot=#@tmpdir", "--mgmtlisten=#@host:#@port", + "--httplisten=#@host:#@httpport", + "--maxconns=500" ] + vg = ENV["VALGRIND"] and cmd = vg.split(/\s+/).concat(cmd) + @pid = fork { + $stderr.reopen(@err) + @err.close + exec(*cmd) + } + @client = get_client + end + + def test_persist_toggle + { + "off" => "on", + "false" => "true", + "0" => "1", + "no" => "yes", + }.each do |f,t| + @client.write "SET mogstored.persist_client = #{f}\r\n" + assert_equal "\r\n", @client.gets + Net::HTTP.start(@host, @httpport) do |http| + resp = http.request(Net::HTTP::Head.new('/')) + assert_kind_of Net::HTTPOK, resp + assert_equal "close", resp["Connection"] + end + + @client.write "SET mogstored.persist_client = #{t}\r\n" + assert_equal "\r\n", @client.gets + Net::HTTP.start(@host, @httpport) do |http| + resp = http.request(Net::HTTP::Head.new('/')) + assert_kind_of Net::HTTPOK, resp + assert_equal "keep-alive", resp["Connection"] + end + end + end + + def teardown + @to_close.each { |io| io.close unless io.closed? } + FileUtils.rm_rf(@tmpdir) + end +end diff --git a/test/ruby.mk b/test/ruby.mk index 5e1a1ca..9280414 100644 --- a/test/ruby.mk +++ b/test/ruby.mk @@ -1,6 +1,6 @@ RB_TESTS_FAST = test/cmogstored-cfg.rb test/http_dav.rb test/http_range.rb \ test/http_put.rb test/http_getonly.rb test/inherit.rb test/upgrade.rb \ - test/http_put6_fail.rb test/epoll_enospc.rb + test/http_put6_fail.rb test/epoll_enospc.rb test/mgmt_persist_client.rb RB_TESTS_SLOW = test/mgmt-usage.rb test/mgmt.rb test/mgmt-iostat.rb \ test/http.rb test/http_put_slow.rb test/http_chunked_put.rb \ test/graceful_quit.rb test/http_idle_expire.rb \ |