From d2087fa98b237b8ee8e12536f17d72ebed710c9b Mon Sep 17 00:00:00 2001 From: Alisdair McDiarmid Date: Fri, 17 Jun 2022 10:49:34 -0400 Subject: [PATCH] states/remote: Check for LockError error type When attempting to lock a remote state backend, failure due to an existing lock should return an instance of LockError. This allows the wrapping code to retry until the specified timeout, instead of immediately exiting. This commit adds a test for this in the TestRemoteLocks test helper, which is used in many of the remote state backend test suites. --- internal/states/remote/testing.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/states/remote/testing.go b/internal/states/remote/testing.go index e14da1cbde..197f87ac8c 100644 --- a/internal/states/remote/testing.go +++ b/internal/states/remote/testing.go @@ -77,6 +77,9 @@ func TestRemoteLocks(t *testing.T, a, b Client) { lockerA.Unlock(lockIDA) t.Fatal("client B obtained lock while held by client A") } + if _, ok := err.(*statemgr.LockError); !ok { + t.Errorf("expected a LockError, but was %t: %s", err, err) + } if err := lockerA.Unlock(lockIDA); err != nil { t.Fatal("error unlocking client A", err)