diff options
author | Richard Maw <richard.maw@gmail.com> | 2016-12-18 16:53:07 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@gmail.com> | 2016-12-18 16:53:07 +0000 |
commit | 3d0a66f439f849fe5e6e3a20b6197145a45d9b9f (patch) | |
tree | 3cfd0615de90d296fc04de0a4b3c923e934dd7e9 /testing | |
parent | 54da504203734e7ee4f1acb7d1da98a70fed8e86 (diff) | |
download | gitano-3d0a66f439f849fe5e6e3a20b6197145a45d9b9f.tar.gz |
testing: Run lighttpd during http tests
Diffstat (limited to 'testing')
-rw-r--r-- | testing/gitano-test-tool.in | 39 | ||||
-rw-r--r-- | testing/library.yarn | 2 |
2 files changed, 40 insertions, 1 deletions
diff --git a/testing/gitano-test-tool.in b/testing/gitano-test-tool.in index 4056935..a5154b9 100644 --- a/testing/gitano-test-tool.in +++ b/testing/gitano-test-tool.in @@ -189,9 +189,48 @@ function cmd_setupstandard(owning_user, master_key, bypass_key) exe = gitano.config.lib_bin_path() .. "/gitano-setup", env = { HOME = user_home(owning_user) } } + if os.getenv("GTT_PROTO") == "http" then + -- setup lighttpd + local pid_file = basedir .. "lighttpd.pid" + local port_file = basedir .. "lighttpd.port" + local docroot = basedir .. "docroot" + local lighttpd_conf = basedir .. "lighttpd.conf" + local port = tonumber(os.getenv("HTTP_FIRST_TEST_PORT")) or 8080 + local how, why + for repetition=1, 10 do + local fh = io.open(lighttpd_conf, "w+") + fh:write(('server.modules = ( "mod_cgi" )\n')) + fh:write(('server.pid-file = %q\n'):format(pid_file)) + fh:write(('server.document-root = %q\n'):format(docroot)) + fh:write(('server.port = %d\n'):format(port)) + fh:close() + local proc = sp.spawn_simple { + "lighttpd", "-f", lighttpd_conf, + } + how, why = proc:wait() + port = port + 1 + if how == "exit" and why == 0 then + break + end + end + if how == -1 then + unix_assert(how, why) + end + if how ~= "exit" or why ~= 0 then + io.stderr:write("Failed to spawn lighttpd server after 10 retries: " + .. how .. ":" .. tostring(why) .. "\n") + os.exit(1) + end + end end function cmd_teardownstandard() + if os.getenv("GTT_PROTO") == "http" then + local pid_file = basedir .. "lighttpd.pid" + run_program { + "pkill", "-9", "-F", pid_file, + } + end end function cmd_cloneviassh(user, key, repo, localname, ...) diff --git a/testing/library.yarn b/testing/library.yarn index 5a812fa..53bd267 100644 --- a/testing/library.yarn +++ b/testing/library.yarn @@ -36,7 +36,7 @@ General instance management $GTT setupstandard testinstance adminkey bypasskey IMPLEMENTS FINALLY the instance is torn down - $GTT teardownstandard testinstance adminkey bypasskey + $GTT teardownstandard Repository access ----------------- |