MCPcopy
hub / github.com/cloudflare/cloudflared / TestRegisterServerLocation

Function TestRegisterServerLocation

connection/observer_test.go:31–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29}
30
31func TestRegisterServerLocation(t *testing.T) {
32 m := newTunnelMetrics()
33 tunnels := 20
34 var wg sync.WaitGroup
35 wg.Add(tunnels)
36 for i := 0; i < tunnels; i++ {
37 go func(i int) {
38 id := strconv.Itoa(i)
39 m.registerServerLocation(id, "LHR")
40 wg.Done()
41 }(i)
42 }
43 wg.Wait()
44 for i := 0; i < tunnels; i++ {
45 id := strconv.Itoa(i)
46 assert.Equal(t, "LHR", m.oldServerLocations[id])
47 }
48
49 wg.Add(tunnels)
50 for i := 0; i < tunnels; i++ {
51 go func(i int) {
52 id := strconv.Itoa(i)
53 m.registerServerLocation(id, "AUS")
54 wg.Done()
55 }(i)
56 }
57 wg.Wait()
58 for i := 0; i < tunnels; i++ {
59 id := strconv.Itoa(i)
60 assert.Equal(t, "AUS", m.oldServerLocations[id])
61 }
62
63}
64
65func TestObserverEventsDontBlock(t *testing.T) {
66 observer := NewObserver(&log, &log)

Callers

nothing calls this directly

Calls 5

newTunnelMetricsFunction · 0.85
WaitMethod · 0.80
AddMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected