Blob Blame History Raw
From b326b63fbe43f5353fd9e7b66db952bfb7d8d605 Mon Sep 17 00:00:00 2001
From: "brian m. carlson" <bk2204@github.com>
Date: Thu, 11 Jan 2024 18:58:25 +0000
Subject: [PATCH 1/2] t/testhelpers: move credential setup into a function

Right now, we do the default credential setup once for each run of the
gitserver.  However, in the future, we'll want to be able to perform it
again in a different directory so we can have test-specific credential
directories if needed.  To do that, let's move the setup into a
function, which we can reuse elsewhere.
---
 t/testhelpers.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/t/testhelpers.sh b/t/testhelpers.sh
index 7a7245f8ca..220960a729 100644
--- a/t/testhelpers.sh
+++ b/t/testhelpers.sh
@@ -557,6 +557,13 @@ write_creds_file() {
   fi
 }
 
+setup_creds() {
+  mkdir -p "$CREDSDIR"
+  write_creds_file "user:pass" "$CREDSDIR/127.0.0.1"
+  write_creds_file ":pass" "$CREDSDIR/--$certpath"
+  write_creds_file ":pass" "$CREDSDIR/--$keypath"
+}
+
 # setup initializes the clean, isolated environment for integration tests.
 setup() {
   cd "$ROOTDIR"
@@ -613,10 +620,7 @@ setup() {
   # setup the git credential password storage
   local certpath="$(echo "$LFS_CLIENT_CERT_FILE" | tr / -)"
   local keypath="$(echo "$LFS_CLIENT_KEY_FILE_ENCRYPTED" | tr / -)"
-  mkdir -p "$CREDSDIR"
-  write_creds_file "user:pass" "$CREDSDIR/127.0.0.1"
-  write_creds_file ":pass" "$CREDSDIR/--$certpath"
-  write_creds_file ":pass" "$CREDSDIR/--$keypath"
+  setup_creds
 
   echo "#"
   echo "# HOME: $HOME"

From b9602f3f3a95cd2b0ece154430025b6fd7eab89c Mon Sep 17 00:00:00 2001
From: "brian m. carlson" <bk2204@github.com>
Date: Thu, 11 Jan 2024 19:00:31 +0000
Subject: [PATCH 2/2] t/t-credentials: avoid failing flakily when run in
 parallel

We've noticed that this test has become flaky sometimes and fails in CI.
More recently, a distributor noticed that this test fails consistently
when run with 4 jobs at a time with `prove`.  Not all of the tests fail
every time, but at least one of them does.

Part of the relevant difference is that our netrc tests use `localhost`
as the machine name instead of the default 127.0.0.1.  This is helpful,
because it means we don't call the credential helper, when we really
want to fall back to the askpass code.  That's because we use different
credentials for the `netrctest` remote, so if there were credentials
available for `localhost`, we'll fail since we'll provide the wrong
ones.

The reason, therefore, that this test is flaky is that the clone code
creates an entry for the credential helper for `localhost`, and the
credential directory is shared among tests.  Thus, `t-credentials.sh`
fails whenever these tests run concurrently.

The obvious solution is to simply create a per-test credentials
directory so that we aren't affected by what other tests are doing.
Let's do that, which makes this test pass consistently.
---
 t/t-credentials.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/t/t-credentials.sh b/t/t-credentials.sh
index 823cff9a6f..1e657d88e3 100755
--- a/t/t-credentials.sh
+++ b/t/t-credentials.sh
@@ -4,6 +4,9 @@
 
 ensure_git_version_isnt $VERSION_LOWER "2.3.0"
 
+export CREDSDIR="$REMOTEDIR/creds-credentials"
+setup_creds
+
 begin_test "credentials with url-specific helper skips askpass"
 (
   set -e