summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2015-03-03 11:01:32 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2015-03-03 18:41:49 +0000
commit5f2a35da8c4c69e510eb96aa2c7cbfeeca923cfd (patch)
treec7d5530a988a61eebdaf66f4db34515d2a704d87
parent4d7f515ae08e0c7916525f40d119fa8bd31696b8 (diff)
downloadmorph-5f2a35da8c4c69e510eb96aa2c7cbfeeca923cfd.tar.gz
yarns: Make the distbuild yarn expose the worker's artifact cache over HTTP
OSTree can easily pull over HTTP. All that is necessary is to expose the repo directory. This commit adds a simple HTTP server to do this in the test suite. Actual implementations should use something better, like lighttpd. Also add some logging of the cache servers in this yarn to help debug.
-rwxr-xr-xostree-repo-server15
-rw-r--r--yarns/implementations.yarn16
-rw-r--r--yarns/morph.shell-lib3
3 files changed, 30 insertions, 4 deletions
diff --git a/ostree-repo-server b/ostree-repo-server
new file mode 100755
index 00000000..e6dc4a56
--- /dev/null
+++ b/ostree-repo-server
@@ -0,0 +1,15 @@
+#!/usr/bin/python
+
+from BaseHTTPServer import HTTPServer
+from SimpleHTTPServer import SimpleHTTPRequestHandler
+from SocketServer import ThreadingMixIn
+
+class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
+ """Handle requests in a separate thread"""
+
+handler = SimpleHTTPRequestHandler
+handler.protocol_version="HTTP/1.0"
+server_address = ('', 12324)
+
+httpd = ThreadedHTTPServer(server_address, handler)
+httpd.serve_forever()
diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn
index 2557e2e5..7575fb2a 100644
--- a/yarns/implementations.yarn
+++ b/yarns/implementations.yarn
@@ -1065,13 +1065,14 @@ Distbuild
read_cache_server_pid_file="$DATADIR/read-cache-server-pid"
start_cache_server "$read_cache_server_port_file" \
"$read_cache_server_pid_file" \
- "$artifact_dir"
+ "$artifact_dir" "$DATADIR/communal-cache.log"
write_cache_server_port_file="$DATADIR/write-cache-server-port"
write_cache_server_pid_file="$DATADIR/write-cache-server-pid"
start_cache_server "$write_cache_server_port_file" \
"$write_cache_server_pid_file" \
- "$artifact_dir" --enable-writes
+ "$artifact_dir" "$DATADIR/writeable-cache.log" \
+ --enable-writes
IMPLEMENTS FINALLY the communal cache server is terminated
stop_daemon "$DATADIR/read-cache-server-pid"
@@ -1086,7 +1087,7 @@ Distbuild
worker_cache_pid_file="$DATADIR/worker-cache-server-pid"
start_cache_server "$worker_cache_port_file" \
"$worker_cache_pid_file" \
- "$worker_artifacts"
+ "$worker_artifacts" "$DATADIR/worker-cache.log"
# start worker daemon
worker_daemon_port_file="$DATADIR/worker-daemon-port"
@@ -1108,6 +1109,14 @@ Distbuild
rm "$worker_daemon_port_file"
echo "$worker_daemon_port" >"$worker_daemon_port_file"
+ # serve artifact cache over http
+ worker_repo_pid_file="$DATADIR/worker-repo-pid"
+ mkdir "$worker_artifacts/repo"
+ cd "$worker_artifacts/repo"
+ start-stop-daemon --start --pidfile="$worker_repo_pid_file" \
+ --background --make-pidfile --verbose \
+ --startas="$SRCDIR/ostree-repo-server"
+
# start worker helper
helper_pid_file="$DATADIR/worker-daemon-helper-pid"
start-stop-daemon --start --pidfile="$helper_pid_file" \
@@ -1129,6 +1138,7 @@ Distbuild
stop_daemon "$DATADIR/worker-cache-server-pid"
stop_daemon "$DATADIR/worker-daemon-pid"
stop_daemon "$DATADIR/worker-daemon-helper-pid"
+ stop_daemon "$DATADIR/worker-repo-pid"
IMPLEMENTS GIVEN a distbuild controller
worker_cache_port_file="$DATADIR/worker-cache-server-port"
diff --git a/yarns/morph.shell-lib b/yarns/morph.shell-lib
index d9c9eff6..381a9d08 100644
--- a/yarns/morph.shell-lib
+++ b/yarns/morph.shell-lib
@@ -3,7 +3,7 @@
# The shell functions in this library are meant to make writing IMPLEMENTS
# sections for yarn scenario tests easier.
-# Copyright (C) 2013-2014 Codethink Limited
+# Copyright (C) 2013-2015 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -195,6 +195,7 @@ start_cache_server(){
--background --make-pidfile --verbose \
--startas="$SRCDIR/morph-cache-server" -- \
--port-file="$1" --no-fcgi \
+ --log="$4" \
--repo-dir="$DATADIR/gits" --direct-mode \
--bundle-dir="$DATADIR/bundles" \
--artifact-dir="$3" "$@"