c5dca52
From b326b63fbe43f5353fd9e7b66db952bfb7d8d605 Mon Sep 17 00:00:00 2001
c5dca52
From: "brian m. carlson" <bk2204@github.com>
c5dca52
Date: Thu, 11 Jan 2024 18:58:25 +0000
c5dca52
Subject: [PATCH 1/2] t/testhelpers: move credential setup into a function
c5dca52
c5dca52
Right now, we do the default credential setup once for each run of the
c5dca52
gitserver.  However, in the future, we'll want to be able to perform it
c5dca52
again in a different directory so we can have test-specific credential
c5dca52
directories if needed.  To do that, let's move the setup into a
c5dca52
function, which we can reuse elsewhere.
c5dca52
---
c5dca52
 t/testhelpers.sh | 12 ++++++++----
c5dca52
 1 file changed, 8 insertions(+), 4 deletions(-)
c5dca52
c5dca52
diff --git a/t/testhelpers.sh b/t/testhelpers.sh
c5dca52
index 7a7245f8ca..220960a729 100644
c5dca52
--- a/t/testhelpers.sh
c5dca52
+++ b/t/testhelpers.sh
c5dca52
@@ -557,6 +557,13 @@ write_creds_file() {
c5dca52
   fi
c5dca52
 }
c5dca52
 
c5dca52
+setup_creds() {
c5dca52
+  mkdir -p "$CREDSDIR"
c5dca52
+  write_creds_file "user:pass" "$CREDSDIR/127.0.0.1"
c5dca52
+  write_creds_file ":pass" "$CREDSDIR/--$certpath"
c5dca52
+  write_creds_file ":pass" "$CREDSDIR/--$keypath"
c5dca52
+}
c5dca52
+
c5dca52
 # setup initializes the clean, isolated environment for integration tests.
c5dca52
 setup() {
c5dca52
   cd "$ROOTDIR"
c5dca52
@@ -613,10 +620,7 @@ setup() {
c5dca52
   # setup the git credential password storage
c5dca52
   local certpath="$(echo "$LFS_CLIENT_CERT_FILE" | tr / -)"
c5dca52
   local keypath="$(echo "$LFS_CLIENT_KEY_FILE_ENCRYPTED" | tr / -)"
c5dca52
-  mkdir -p "$CREDSDIR"
c5dca52
-  write_creds_file "user:pass" "$CREDSDIR/127.0.0.1"
c5dca52
-  write_creds_file ":pass" "$CREDSDIR/--$certpath"
c5dca52
-  write_creds_file ":pass" "$CREDSDIR/--$keypath"
c5dca52
+  setup_creds
c5dca52
 
c5dca52
   echo "#"
c5dca52
   echo "# HOME: $HOME"
c5dca52
c5dca52
From b9602f3f3a95cd2b0ece154430025b6fd7eab89c Mon Sep 17 00:00:00 2001
c5dca52
From: "brian m. carlson" <bk2204@github.com>
c5dca52
Date: Thu, 11 Jan 2024 19:00:31 +0000
c5dca52
Subject: [PATCH 2/2] t/t-credentials: avoid failing flakily when run in
c5dca52
 parallel
c5dca52
c5dca52
We've noticed that this test has become flaky sometimes and fails in CI.
c5dca52
More recently, a distributor noticed that this test fails consistently
c5dca52
when run with 4 jobs at a time with `prove`.  Not all of the tests fail
c5dca52
every time, but at least one of them does.
c5dca52
c5dca52
Part of the relevant difference is that our netrc tests use `localhost`
c5dca52
as the machine name instead of the default 127.0.0.1.  This is helpful,
c5dca52
because it means we don't call the credential helper, when we really
c5dca52
want to fall back to the askpass code.  That's because we use different
c5dca52
credentials for the `netrctest` remote, so if there were credentials
c5dca52
available for `localhost`, we'll fail since we'll provide the wrong
c5dca52
ones.
c5dca52
c5dca52
The reason, therefore, that this test is flaky is that the clone code
c5dca52
creates an entry for the credential helper for `localhost`, and the
c5dca52
credential directory is shared among tests.  Thus, `t-credentials.sh`
c5dca52
fails whenever these tests run concurrently.
c5dca52
c5dca52
The obvious solution is to simply create a per-test credentials
c5dca52
directory so that we aren't affected by what other tests are doing.
c5dca52
Let's do that, which makes this test pass consistently.
c5dca52
---
c5dca52
 t/t-credentials.sh | 3 +++
c5dca52
 1 file changed, 3 insertions(+)
c5dca52
c5dca52
diff --git a/t/t-credentials.sh b/t/t-credentials.sh
c5dca52
index 823cff9a6f..1e657d88e3 100755
c5dca52
--- a/t/t-credentials.sh
c5dca52
+++ b/t/t-credentials.sh
c5dca52
@@ -4,6 +4,9 @@
c5dca52
 
c5dca52
 ensure_git_version_isnt $VERSION_LOWER "2.3.0"
c5dca52
 
c5dca52
+export CREDSDIR="$REMOTEDIR/creds-credentials"
c5dca52
+setup_creds
c5dca52
+
c5dca52
 begin_test "credentials with url-specific helper skips askpass"
c5dca52
 (
c5dca52
   set -e