summaryrefslogtreecommitdiff
path: root/yarns.webapp
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-04-22 15:17:41 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-04-22 15:17:41 +0000
commit5639de7571bc1807e6486c9d05cc455a74346922 (patch)
tree4505405a1e179ce29f01e6af0ea576fac36decc0 /yarns.webapp
parent3cecab7699a921524d954e761ee6614c6289625d (diff)
downloadlorry-controller-5639de7571bc1807e6486c9d05cc455a74346922.tar.gz
Add a "WHEN" variant of "GIVEN a running WEBAPP"
Diffstat (limited to 'yarns.webapp')
-rw-r--r--yarns.webapp/030-queue-management.yarn2
-rw-r--r--yarns.webapp/900-implementations.yarn37
-rw-r--r--yarns.webapp/yarn.sh42
3 files changed, 46 insertions, 35 deletions
diff --git a/yarns.webapp/030-queue-management.yarn b/yarns.webapp/030-queue-management.yarn
index 91a8511..427bc72 100644
--- a/yarns.webapp/030-queue-management.yarn
+++ b/yarns.webapp/030-queue-management.yarn
@@ -26,7 +26,7 @@ new one, and verify that the `running-queue` status is still `true`.
WHEN WEBAPP is terminated
THEN WEBAPP isn't running
- GIVEN a running WEBAPP
+ WHEN WEBAPP is started
WHEN admin makes request GET /1.0/status
THEN response has running_queue set to false
diff --git a/yarns.webapp/900-implementations.yarn b/yarns.webapp/900-implementations.yarn
index 4f87be9..859bb40 100644
--- a/yarns.webapp/900-implementations.yarn
+++ b/yarns.webapp/900-implementations.yarn
@@ -24,41 +24,10 @@ but the shell doesn't wait for it to terminate. This way, WEBAPP will
be running until it crashes or is explicitly killed.
IMPLEMENTS GIVEN a running WEBAPP
- rm -f "$DATADIR/webapp.pid"
- rm -f "$DATADIR/webapp.port"
- mkfifo "$DATADIR/webapp.port"
+ start_webapp
- add_to_config_file "$DATADIR/webapp.conf" \
- statedb "$DATADIR/webapp.db"
- add_to_config_file "$DATADIR/webapp.conf" \
- status-html "$DATADIR/lc-status.html"
- add_to_config_file "$DATADIR/webapp.conf" \
- log "$DATADIR/webapp.log"
- add_to_config_file "$DATADIR/webapp.conf" \
- log-level debug
- add_to_config_file "$DATADIR/webapp.conf" \
- debug-host 127.0.0.1
- add_to_config_file "$DATADIR/webapp.conf" \
- debug-port-file "$DATADIR/webapp.port"
- add_to_config_file "$DATADIR/webapp.conf" \
- static-files "$SRCDIR/static"
- add_to_config_file "$DATADIR/webapp.conf" \
- templates "$SRCDIR/templates"
- add_to_config_file "$DATADIR/webapp.conf" \
- debug-real-confgit no
-
- start-stop-daemon -S -x "$SRCDIR/lorry-controller-webapp" \
- -b -p "$DATADIR/webapp.pid" -m --verbose \
- -- \
- --config "$DATADIR/webapp.conf"
-
- port=$(cat "$DATADIR/webapp.port")
- rm -f "$DATADIR/webapp.port"
- echo "$port" >"$DATADIR/webapp.port"
-
- # Wait for the WEBAPP to actually be ready, i.e., that it's
- # listening on its assigned port.
- "$SRCDIR/test-wait-for-port" 127.0.0.1 "$port"
+ IMPLEMENTS WHEN WEBAPP is started
+ start_webapp
Kill the running WEBAPP, using the recorded PID. We need to do this
both as a WHEN and a FINALLY step.
diff --git a/yarns.webapp/yarn.sh b/yarns.webapp/yarn.sh
index 3c617e3..6f93a5f 100644
--- a/yarns.webapp/yarn.sh
+++ b/yarns.webapp/yarn.sh
@@ -54,3 +54,45 @@ stdin_is_empty()
exit 1
fi
}
+
+
+# Configure (unless already configured) and start a WEBAPP.
+
+start_webapp()
+{
+ rm -f "$DATADIR/webapp.pid"
+ rm -f "$DATADIR/webapp.port"
+ mkfifo "$DATADIR/webapp.port"
+
+ add_to_config_file "$DATADIR/webapp.conf" \
+ statedb "$DATADIR/webapp.db"
+ add_to_config_file "$DATADIR/webapp.conf" \
+ status-html "$DATADIR/lc-status.html"
+ add_to_config_file "$DATADIR/webapp.conf" \
+ log "$DATADIR/webapp.log"
+ add_to_config_file "$DATADIR/webapp.conf" \
+ log-level debug
+ add_to_config_file "$DATADIR/webapp.conf" \
+ debug-host 127.0.0.1
+ add_to_config_file "$DATADIR/webapp.conf" \
+ debug-port-file "$DATADIR/webapp.port"
+ add_to_config_file "$DATADIR/webapp.conf" \
+ static-files "$SRCDIR/static"
+ add_to_config_file "$DATADIR/webapp.conf" \
+ templates "$SRCDIR/templates"
+ add_to_config_file "$DATADIR/webapp.conf" \
+ debug-real-confgit no
+
+ start-stop-daemon -S -x "$SRCDIR/lorry-controller-webapp" \
+ -b -p "$DATADIR/webapp.pid" -m --verbose \
+ -- \
+ --config "$DATADIR/webapp.conf"
+
+ port=$(cat "$DATADIR/webapp.port")
+ rm -f "$DATADIR/webapp.port"
+ echo "$port" >"$DATADIR/webapp.port"
+
+ # Wait for the WEBAPP to actually be ready, i.e., that it's
+ # listening on its assigned port.
+ "$SRCDIR/test-wait-for-port" 127.0.0.1 "$port"
+}