MCPcopy
hub / github.com/syncthing/syncthing / TestIssue5063

Function TestIssue5063

lib/model/model_test.go:976–1016  ·  view source on GitHub ↗

TestIssue5063 is about a panic in connection with modifying config in quick succession, related with auto accepted folders. It's unclear what exactly, a relevant bit seems to be here: PR-comments: https://github.com/syncthing/syncthing/pull/5069/files#r203146546 Issue: https://github.com/syncthing/s

(t *testing.T)

Source from the content-addressed store, hash-verified

974// PR-comments: https://github.com/syncthing/syncthing/pull/5069/files#r203146546
975// Issue: https://github.com/syncthing/syncthing/pull/5509
976func TestIssue5063(t *testing.T) {
977 m, cancel := newState(t, defaultAutoAcceptCfg)
978 defer cleanupModel(m)
979 defer cancel()
980
981 m.mut.Lock()
982 for _, c := range m.connections {
983 conn := c.(*fakeConnection)
984 conn.CloseCalls(func(_ error) {})
985 defer m.Closed(c, errStopped) // to unblock deferred m.Stop()
986 }
987 m.mut.Unlock()
988
989 wg := sync.WaitGroup{}
990
991 addAndVerify := func(id string) {
992 m.ClusterConfig(device1Conn, createClusterConfig(device1, id))
993 if fcfg, ok := m.cfg.Folder(id); !ok || !fcfg.SharedWith(device1) {
994 t.Error("expected shared", id)
995 }
996 }
997
998 reps := 10
999 ids := make([]string, reps)
1000 for i := 0; i < reps; i++ {
1001 ids[i] = srand.String(8)
1002 wg.Go(func() { addAndVerify(ids[i]) })
1003 }
1004
1005 finished := make(chan struct{})
1006 go func() {
1007 wg.Wait()
1008 close(finished)
1009 }()
1010 select {
1011 case <-finished:
1012 case <-time.After(10 * time.Second):
1013 pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
1014 t.Fatal("Timed out before all devices were added")
1015 }
1016}
1017
1018func TestAutoAcceptRejected(t *testing.T) {
1019 // Nothing happens if AutoAcceptFolders not set

Callers

nothing calls this directly

Calls 15

newStateFunction · 0.85
cleanupModelFunction · 0.85
createClusterConfigFunction · 0.85
CloseCallsMethod · 0.80
UnlockMethod · 0.80
SharedWithMethod · 0.80
FatalMethod · 0.80
ClosedMethod · 0.65
ClusterConfigMethod · 0.65
FolderMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected