diff --git a/services/rest/websocket/connection/table_race_test.go b/services/rest/websocket/connection/table_race_test.go new file mode 100644 index 00000000..e3ad25df --- /dev/null +++ b/services/rest/websocket/connection/table_race_test.go @@ -0,0 +1,45 @@ +package connection + +import ( + "github.com/goto/raccoon/identification" + "testing" + "time" +) + +func TestRaceInTable(t *testing.T) { + table := NewTable(100) + done := make(chan bool) + id := identification.Identifier{ + ID: "connection-id-1", + Group: "group-i-1", + } + + //store the ids + go func() { + for { + select { + case <-done: + return + default: + table.Store(id) + } + } + }() + + go func() { + for { + select { + case <-done: + return + default: + for k, v := range table.TotalConnectionPerGroup() { + _ = k + _ = v + } + } + } + }() + + time.Sleep(2 * time.Second) + close(done) +}