From 1edbc9f5c08daafb3e13131dfc8df656b2a02edc Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 27 Aug 2014 16:39:53 +0100 Subject: yarns: Use a more realistic simulation of a git server Previously we would use file: URIs to point to the git repositories. This was fast and simple, but had the drawback that it bypassed all the git cache logic, so changes to the git cache weren't adequately covered by the test suite. Now we spool up a simulated git server per scenario, and shut it down at the end. --- yarns/implementations.yarn | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'yarns/implementations.yarn') diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn index 477849eb..422c2eea 100644 --- a/yarns/implementations.yarn +++ b/yarns/implementations.yarn @@ -258,12 +258,25 @@ another to hold a chunk. run_in "$DATADIR/gits/morphs" git commit -m Initial. run_in "$DATADIR/gits/morphs" git tag -a "test-tag" -m "Tagging test-tag" + # Start a git daemon to serve our git repositories + port_file="$DATADIR/git-daemon-port" + pid_file="$DATADIR/git-daemon-pid" + mkfifo "$port_file" + # git-daemon needs --foo=bar style arguments so we do that for consistency + start-stop-daemon --start --pidfile="$pid_file" --background \ + --make-pidfile --verbose \ + --startas="$SRCDIR/scripts/git-daemon-wrap" -- \ + --port-file="$port_file" \ + --export-all --verbose --base-path="$DATADIR/gits" \ + --enable=receive-pack #allow push + GIT_DAEMON_PORT="$(cat "$port_file")" + # Create the Morph configuration file so we can access the repos # using test:foo URL aliases. cat << EOF > "$DATADIR/morph.conf" [config] - repo-alias = test=file://$DATADIR/gits/%s#file://$DATADIR/gits/%s + repo-alias = test=git://127.0.0.1:$GIT_DAEMON_PORT/%s#git://127.0.0.1:$GIT_DAEMON_PORT/%s cachedir = $DATADIR/cache tempdir = $DATADIR/tmp trove-host= [] @@ -272,6 +285,15 @@ another to hold a chunk. mkdir "$DATADIR/cache" mkdir "$DATADIR/tmp" +Some resources are cleaned up by yarn, forked processes aren't one of +these, so need to shut down the git daemon after we finish. + + IMPLEMENTS FINALLY the git server is shut down + pid_file="$DATADIR/git-daemon-pid" + if [ -e "$pid_file" ]; then + start-stop-daemon --stop --pidfile "$pid_file" --oknodo + fi + We need a consistent value for the architecture in some tests, so we have a morphology using the test architecture. -- cgit v1.2.1