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.
This commit is contained in:
Alisdair McDiarmid 2022-06-17 10:49:34 -04:00
parent b0b69d3fad
commit d2087fa98b

View File

@ -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)