mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
filer: make the stub-backed remote storage tests re-runnable (#12852)
filer: drop cached remote clients when a test registers a stub maker The remote client cache is keyed by the configuration, so rerunning a stub-backed test (go test -count>1) got the previous run's stub from the cache and its counters never moved. Nineteen tests failed on a rerun. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
228ccd9eb6
commit
0de9a82dd9
1 file changed
+4
@@ -340,8 +340,11 @@ func newTestFiler(t *testing.T, store *stubFilerStore, rs *FilerRemoteStorage) *
|
||||
|
||||
// registerStubMaker registers a stub RemoteStorageClientMaker for the given
|
||||
// type string and returns a cleanup function that restores the previous maker.
|
||||
// Both empty the client cache, so a rerun with the same configuration builds
|
||||
// a client from this stub instead of reusing the previous run's.
|
||||
func registerStubMaker(t *testing.T, storageType string, client remote_storage.RemoteStorageClient) func() {
|
||||
t.Helper()
|
||||
remote_storage.ResetRemoteStorageClients()
|
||||
prev := remote_storage.RemoteStorageClientMakers[storageType]
|
||||
remote_storage.RemoteStorageClientMakers[storageType] = &stubClientMaker{client: client}
|
||||
return func() {
|
||||
@@ -350,6 +353,7 @@ func registerStubMaker(t *testing.T, storageType string, client remote_storage.R
|
||||
} else {
|
||||
delete(remote_storage.RemoteStorageClientMakers, storageType)
|
||||
}
|
||||
remote_storage.ResetRemoteStorageClients()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user