summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2016-12-18 16:53:07 +0000
committerRichard Maw <richard.maw@gmail.com>2016-12-18 16:53:07 +0000
commit3d0a66f439f849fe5e6e3a20b6197145a45d9b9f (patch)
tree3cfd0615de90d296fc04de0a4b3c923e934dd7e9
parent54da504203734e7ee4f1acb7d1da98a70fed8e86 (diff)
downloadgitano-3d0a66f439f849fe5e6e3a20b6197145a45d9b9f.tar.gz
testing: Run lighttpd during http tests
-rw-r--r--Makefile7
-rw-r--r--testing/gitano-test-tool.in39
-rw-r--r--testing/library.yarn2
3 files changed, 47 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 279d590..1dff13e 100644
--- a/Makefile
+++ b/Makefile
@@ -192,6 +192,10 @@ ifeq ($(filter $(TEST_PROTO),ssh http),)
$(error TEST_PROTO should be ssh or http)
endif
+ifeq ($(HTTP_FIRST_TEST_PORT),)
+HTTP_FIRST_TEST_PORT = 8080
+endif
+
plugin-check:
$(LUAC) -p $(patsubst %,plugins/%,$(PLUGINS))
for PLUGIN in $(patsubst %,plugins/%,$(PLUGINS)); do \
@@ -204,6 +208,7 @@ basictest: local plugin-check $(TEST_BINS)
@$(YARN) \
--env GTT="$$(pwd)/testing/gitano-test-tool" \
--env GTT_PROTO=$(TEST_PROTO) \
+ --env HTTP_FIRST_TEST_PORT=$(HTTP_FIRST_TEST_PORT) \
$(YARN_ARGS) \
testing/library.yarn testing/01*.yarn
@@ -212,12 +217,14 @@ test: local plugin-check $(TEST_BINS)
@$(YARN) \
--env GTT="$$(pwd)/testing/gitano-test-tool" \
--env GTT_PROTO=ssh \
+ --env HTTP_FIRST_TEST_PORT=$(HTTP_FIRST_TEST_PORT) \
$(YARN_ARGS) \
testing/library.yarn $(TESTS)
@echo "Running full yarns in 'http' mode"
@$(YARN) \
--env GTT="$$(pwd)/testing/gitano-test-tool" \
--env GTT_PROTO=http \
+ --env HTTP_FIRST_TEST_PORT=$(HTTP_FIRST_TEST_PORT) \
$(YARN_ARGS) \
testing/library.yarn $(TESTS)
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
-----------------