From ec5beb70102f2726daecc76cdb918bb36057abb3 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 5 Jun 2016 09:29:15 +2100 Subject: [PATCH] [PATCH 3/4] test: initial tests for locking retry --- 91/e5e2626d867232fae833d74be5c3abb5e35265 | 140 ++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 91/e5e2626d867232fae833d74be5c3abb5e35265 diff --git a/91/e5e2626d867232fae833d74be5c3abb5e35265 b/91/e5e2626d867232fae833d74be5c3abb5e35265 new file mode 100644 index 000000000..1f753772a --- /dev/null +++ b/91/e5e2626d867232fae833d74be5c3abb5e35265 @@ -0,0 +1,140 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 292706DE091C + for ; Sat, 4 Jun 2016 05:29:59 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.012 +X-Spam-Level: +X-Spam-Status: No, score=-0.012 tagged_above=-999 required=5 + tests=[AWL=-0.001, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id A5hDbifBI6dc for ; + Sat, 4 Jun 2016 05:29:51 -0700 (PDT) +Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) + by arlo.cworth.org (Postfix) with ESMTPS id 8A5886DE0261 + for ; Sat, 4 Jun 2016 05:29:34 -0700 (PDT) +Received: from remotemail by fethera.tethera.net with local (Exim 4.84) + (envelope-from ) + id 1b9Ahc-0004z6-SF; Sat, 04 Jun 2016 08:29:20 -0400 +Received: (nullmailer pid 23495 invoked by uid 1000); + Sat, 04 Jun 2016 12:29:27 -0000 +From: David Bremner +To: Istvan Marko , Jani Nikula , + notmuch@notmuchmail.org +Subject: [PATCH 3/4] test: initial tests for locking retry +Date: Sat, 4 Jun 2016 09:29:15 -0300 +Message-Id: <1465043356-23420-4-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.8.1 +In-Reply-To: <1465043356-23420-1-git-send-email-david@tethera.net> +References: + <1465043356-23420-1-git-send-email-david@tethera.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 04 Jun 2016 12:29:59 -0000 + +Currently there's not much to test, so we simulate contention, and check +that the modifications to the database are serialized. +--- + test/T620-lock.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 75 insertions(+) + create mode 100755 test/T620-lock.sh + +diff --git a/test/T620-lock.sh b/test/T620-lock.sh +new file mode 100755 +index 0000000..f46475e +--- /dev/null ++++ b/test/T620-lock.sh +@@ -0,0 +1,75 @@ ++#!/usr/bin/env bash ++test_description="locking" ++. ./test-lib.sh || exit 1 ++ ++if [ "${NOTMUCH_HAVE_XAPIAN_DB_RETRY_LOCK}" = "0" ]; then ++ test_subtest_missing_external_prereq_["lock retry support"]=t ++fi ++ ++add_email_corpus ++ ++test_begin_subtest "blocking open" ++test_C ${MAIL_DIR} <<'EOF' ++#include ++#include ++#include ++#include ++ ++void ++taggit (notmuch_database_t *db, const char *tag) ++{ ++ notmuch_message_t *message; ++ ++ EXPECT0 (notmuch_database_find_message (db, "4EFC743A.3060609@april.org", &message)); ++ if (message == NULL) { ++ fprintf (stderr, "unable to find message"); ++ exit (1); ++ } ++ ++ EXPECT0 (notmuch_message_add_tag (message, tag)); ++ notmuch_message_destroy (message); ++} ++ ++int ++main (int argc, char **argv) ++{ ++ pid_t child; ++ const char *path = argv[1]; ++ ++ child = fork (); ++ if (child == -1) { ++ fprintf (stderr, "fork failed\n"); ++ exit (1); ++ } ++ ++ if (child == 0) { ++ notmuch_database_t *db2; ++ ++ sleep (1); ++ EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &db2)); ++ taggit (db2, "child"); ++ EXPECT0 (notmuch_database_close (db2)); ++ } else { ++ notmuch_database_t *db; ++ ++ EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &db)); ++ taggit (db, "parent"); ++ sleep (2); ++ EXPECT0 (notmuch_database_close (db)); ++ wait (NULL); ++ } ++} ++ ++EOF ++notmuch search --output=tags id:4EFC743A.3060609@april.org >> OUTPUT ++cat <<'EOF' >EXPECTED ++== stdout == ++== stderr == ++child ++inbox ++parent ++unread ++EOF ++test_expect_equal_file EXPECTED OUTPUT ++ ++test_done +-- +2.8.1 + -- 2.26.2