aboutsummaryrefslogtreecommitdiff
path: root/keyserver
diff options
context:
space:
mode:
authorBrian Meek <brian@hntlabs.com>2022-08-05 01:19:33 -0700
committerGitHub <noreply@github.com>2022-08-05 09:19:33 +0100
commitde78eab63a99653edf68f783e263688ad4b701d8 (patch)
treedbc9170d76689f97bb684745e253c01248630d1e /keyserver
parent9a655cb5e7f8b96a0b02203e69d866dfb1a184e2 (diff)
Add race testing to tests, and fix a few small race conditions in the tests (#2587)
* Add race testing to tests, and fix a few small race conditions in the tests * Enable run-sytest on MacOS * Remove deadlock detecting mutex, per code review feedback * Remove autoformatting related changes and a closure that is not needed * Adjust to importing nats client as 'natsclient' Signed-off-by: Brian Meek <brian@hntlabs.com> * Clarify the use of gooseMutex to proect goose internal state Signed-off-by: Brian Meek <brian@hntlabs.com> * Remove no longer needed mutex for guarding goose Signed-off-by: Brian Meek <brian@hntlabs.com>
Diffstat (limited to 'keyserver')
-rw-r--r--keyserver/storage/storage_test.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/keyserver/storage/storage_test.go b/keyserver/storage/storage_test.go
index 44cfb5f2..e7a2af7c 100644
--- a/keyserver/storage/storage_test.go
+++ b/keyserver/storage/storage_test.go
@@ -3,6 +3,7 @@ package storage_test
import (
"context"
"reflect"
+ "sync"
"testing"
"github.com/matrix-org/dendrite/keyserver/api"
@@ -103,6 +104,9 @@ func TestKeyChangesUpperLimit(t *testing.T) {
})
}
+var dbLock sync.Mutex
+var deviceArray = []string{"AAA", "another_device"}
+
// The purpose of this test is to make sure that the storage layer is generating sequential stream IDs per user,
// and that they are returned correctly when querying for device keys.
func TestDeviceKeysStreamIDGeneration(t *testing.T) {
@@ -169,8 +173,11 @@ func TestDeviceKeysStreamIDGeneration(t *testing.T) {
t.Fatalf("Expected StoreLocalDeviceKeys to set StreamID=3 (new key same device) but got %d", msgs[0].StreamID)
}
+ dbLock.Lock()
+ defer dbLock.Unlock()
// Querying for device keys returns the latest stream IDs
- msgs, err = db.DeviceKeysForUser(ctx, alice, []string{"AAA", "another_device"}, false)
+ msgs, err = db.DeviceKeysForUser(ctx, alice, deviceArray, false)
+
if err != nil {
t.Fatalf("DeviceKeysForUser returned error: %s", err)
}