v0.19.0 use updated config and toml packages, dep update, minor fixes
Test / test (push) Canceled after 0s

This commit is contained in:
lixen committed 2026-09-29 00:20:53 -04:00
1 parent b8982e4e44
commit cb0da23070
22 files changed
+692 -232

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
package session
import (
"sync"
"testing"
"time"
)
func TestSessionSnapshotsDoNotRaceActivityUpdates(t *testing.T) {
m := NewManager(time.Minute)
defer m.Stop()
proxy := NewProxy(m, "source")
stored := proxy.CreateSession("remote", map[string]any{"label": "original"})
readers := []func() []*Session{
m.GetActiveSessions,
func() []*Session { return m.GetSessionsBySource("source") },
func() []*Session { return m.GetActiveSessionsBySource("source") },
}
var wg sync.WaitGroup
wg.Go(func() {
for range 1000 {
proxy.UpdateActivity(stored.ID)
}
})
for _, read := range readers {
for range 100 {
snapshots := read()
if len(snapshots) != 1 || snapshots[0] == stored || snapshots[0].InstanceID != "source" {
t.Errorf("invalid snapshot: %+v", snapshots)
break
}
snapshot := snapshots[0]
before := snapshot.LastActivity
proxy.UpdateActivity(stored.ID)
if !snapshot.LastActivity.Equal(before) {
t.Error("activity update changed an earlier snapshot")
}
snapshot.Metadata["label"] = "changed"
}
}
wg.Wait()
if stored.Metadata["label"] != "original" {
t.Fatal("snapshot metadata aliases the stored map")
}
}