MCPcopy
hub / github.com/tailscale/tailscale / TestUpdateRace

Function TestUpdateRace

wgengine/netlog/netlog_test.go:149–187  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

147}
148
149func TestUpdateRace(t *testing.T) {
150 var logger Logger
151 logger.recordsChan = make(chan record, 1)
152 go func(recordsChan chan record) {
153 for range recordsChan {
154 }
155 }(logger.recordsChan)
156
157 var group sync.WaitGroup
158 defer group.Wait()
159 for i := range 1000 {
160 group.Go(func() {
161 src, dst := randAddrPort(), randAddrPort()
162 for j := range 1000 {
163 if i%2 == 0 {
164 logger.updateVirtConn(0x1, src, dst, rand.IntN(10), rand.IntN(1000), j%2 == 0)
165 } else {
166 logger.updatePhysConn(0x1, src, dst, rand.IntN(10), rand.IntN(1000), j%2 == 0)
167 }
168 }
169 })
170 group.Go(func() {
171 for range 1000 {
172 logger.ReconfigNetworkMap(new(netmap.NetworkMap))
173 }
174 })
175 group.Go(func() {
176 for range 1000 {
177 logger.ReconfigRoutes(new(router.Config))
178 }
179 })
180 }
181
182 group.Wait()
183 logger.mu.Lock()
184 close(logger.recordsChan)
185 logger.recordsChan = nil
186 logger.mu.Unlock()
187}
188
189func randAddrPort() netip.AddrPort {
190 var b [4]uint8

Callers

nothing calls this directly

Calls 9

updateVirtConnMethod · 0.95
updatePhysConnMethod · 0.95
ReconfigNetworkMapMethod · 0.95
ReconfigRoutesMethod · 0.95
randAddrPortFunction · 0.85
GoMethod · 0.80
WaitMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…