chiark / gitweb /
Test suite: Test dgit-repos-policy-debian database retry
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 13 Jun 2015 19:29:04 +0000 (20:29 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 13 Jun 2015 19:29:04 +0000 (20:29 +0100)
infra/dgit-repos-policy-debian
tests/tests/debpolicy-dbretry [new file with mode: 0755]
tests/tests/debpolicy-newreject

index 5d843a0..a770c55 100755 (executable)
@@ -462,6 +462,10 @@ for (;;) {
        poldb_setup(poldb_path($repos));
        $stderr = '';
 
+       eval ($ENV{'DGIT_DRS_RPD_TEST_DBLOOP_HOOK'}//'');
+       die $@ if length $@;
+       # used by tests/tests/debpolicy-dbretry
+
        $poldbh->{HandleError} = sub {
            return 0 unless $poldbh->err == 5; # SQLITE_BUSY, not in .pm :-(
            die bless { }, $db_busy_exception;
diff --git a/tests/tests/debpolicy-dbretry b/tests/tests/debpolicy-dbretry
new file mode 100755 (executable)
index 0000000..e24175e
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+t-tstunt-parsechangelog
+
+t-debpolicy
+t-prep-newpackage example 1.0
+
+cd $p
+revision=1
+git tag start
+
+echo DUMMY >some-file
+git add some-file
+git commit -m some-file
+taint=`git rev-parse HEAD`
+t-policy-admin taint --global $taint dummy
+git reset --hard HEAD~
+
+t-commit 'Make something to autotaint'
+t-dgit build
+t-dgit push --new
+
+autotaint=`t-git-get-ref "refs/tags/debian/$v"`
+
+git reset --hard start
+t-commit 'Thing which will autotaint'
+t-dgit build
+
+fifo=$tmp/sqlite-cmds
+mkfifo $fifo
+exec 3<>$fifo
+sqlite3 -interactive $tmp/git/policy.sqlite3 0<$fifo 3>&- &
+sqlite3_pid=$!
+
+taintsout=$tmp/sqlite3.taints-out
+echo >&3 'begin;';
+echo >&3 ".output $taintsout"
+echo >&3 'select * from taints;';
+echo >&3 'create table dummy (x text);'
+
+while ! grep $taint $taintsout; do sleep 0.1; done
+
+t-dgit build
+
+DGIT_DRS_RPD_TEST_DBLOOP_HOOK='
+       print STDERR "DBLOOP HOOK $sleepy\n";
+       $poldbh->sqlite_busy_timeout(500);
+       if ($sleepy > 2) {
+               system '\''
+                       set -ex
+                       echo >'"$fifo"' "rollback;"
+                       touch '"$tmp/sqlite3.rolled-back"'
+               '\'' and die "$? $!";
+       }
+' \
+t-dgit push --deliberately-not-fast-forward
+
+exec 3>&-
+wait $sqlite3_pid
+
+ls $tmp/sqlite3.rolled-back
+
+t-policy-admin list-taints | tee $tmp/taints-list | grep $autotaint
+
+echo ok.
index 2e1bf88..c238a5a 100755 (executable)
@@ -117,4 +117,4 @@ t-expect-push-fail \
     'Reason: rewound suite sid; --deliberately-not-fast-forward specified' \
 t-dgit push
 
-echo xxx want to test database lock retry thing on push-and-taint
+echo ok.