From 883825d7c6d66bc49ed140482453aad3e98edc8a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 17 Oct 2014 15:27:16 +0300 Subject: Add scenario for automatically removing old jobs --- yarns.webapp/040-running-jobs.yarn | 56 +++++++++++++++++++++++++++++++++++ yarns.webapp/900-implementations.yarn | 13 ++++++++ 2 files changed, 69 insertions(+) (limited to 'yarns.webapp') diff --git a/yarns.webapp/040-running-jobs.yarn b/yarns.webapp/040-running-jobs.yarn index 571afd6..cbc8f75 100644 --- a/yarns.webapp/040-running-jobs.yarn +++ b/yarns.webapp/040-running-jobs.yarn @@ -359,3 +359,59 @@ Remove it. Cleanup. FINALLY WEBAPP terminates + + +Remove old terminated jobs with helper program +-------------------------- + +There is a helper program to remove old jobs automatically. + + SCENARIO remove old terminated jobs + +Setup. + + GIVEN a new git repository in CONFGIT + AND an empty lorry-controller.conf in CONFGIT + AND lorry-controller.conf in CONFGIT adds lorries *.lorry using prefix upstream + AND WEBAPP uses CONFGIT as its configuration directory + AND a running WEBAPP + GIVEN Lorry file CONFGIT/foo.lorry with {"foo":{"type":"git","url":"git://foo"}} + WHEN admin makes request POST /1.0/read-configuration + +Start job 1. We start it a known time of 100, so that we can control +when jobs become old. + + WHEN admin makes request POST /1.0/pretend-time with now=100 + AND admin makes request POST /1.0/give-me-job with host=testhost&pid=123 + THEN response has job_id set to 1 + +Remove old jobs while job 1 is running, still pretending time is 100 +seconds since epoch. This should leave job 1 running. + + WHEN admin removes old jobs at 100 + AND admin makes request GET /1.0/list-jobs + THEN response has job_ids set to [1] + +Finish the job. + + WHEN MINION makes request POST /1.0/job-update with job_id=1&exit=0 + WHEN admin makes request GET /1.0/list-jobs + THEN response has job_ids set to [1] + +Remove old jobs, still at 100 seconds. Job 1 should still remain, as +it just finished. + + WHEN admin removes old jobs at 100 + AND admin makes request GET /1.0/list-jobs + THEN response has job_ids set to [1] + +Let a long time pass, and remove old jobs again. Job 1 should now go +away. + + WHEN admin removes old jobs at 100000000000 + AND admin makes request GET /1.0/list-jobs + THEN response has job_ids set to [] + +Cleanup. + + FINALLY WEBAPP terminates diff --git a/yarns.webapp/900-implementations.yarn b/yarns.webapp/900-implementations.yarn index 54a82a4..455a993 100644 --- a/yarns.webapp/900-implementations.yarn +++ b/yarns.webapp/900-implementations.yarn @@ -406,6 +406,19 @@ Some responses are just plain text, so we match them with a regexp. grep "$MATCH_1" "$DATADIR/response.body" +Running the "remove old jobs" helper program +-------------------------------------------- + +Lorry Controller comes with a helper program to remove old jobs from +STATEDB. Tests need to be able to run it. + + IMPLEMENTS WHEN admin removes old jobs at (\d+) + "$SRCDIR/lorry-controller-remove-old-jobs" \ + --log "$DATADIR/remove-old-jobs.log" \ + --webapp-host=127.0.0.1 \ + --webapp-port="$(cat "$DATADIR/webapp.port")" \ + --debug-now="$MATCH_1" + Status web page --------------- -- cgit v1.2.1