MCPcopy
hub / github.com/grpc/grpc-go / TestSwap

Method TestSwap

internal/xds/balancer/outlierdetection/callcounter_test.go:74–92  ·  view source on GitHub ↗

TestSwap tests that swap() on the callCounter successfully has the desired end result of inactive bucket containing the previous active buckets data, and the active bucket being cleared.

(t *testing.T)

Source from the content-addressed store, hash-verified

72// end result of inactive bucket containing the previous active buckets data,
73// and the active bucket being cleared.
74func (s) TestSwap(t *testing.T) {
75 cc := newCallCounter()
76 ab := cc.activeBucket.Load()
77 ab.numSuccesses = 1
78 ab.numFailures = 2
79 cc.inactiveBucket.numSuccesses = 4
80 cc.inactiveBucket.numFailures = 5
81 ib := cc.inactiveBucket
82 cc.swap()
83 // Inactive should pick up active's data, active should be swapped to zeroed
84 // inactive.
85 ccWant := newCallCounter()
86 ccWant.inactiveBucket.numSuccesses = 1
87 ccWant.inactiveBucket.numFailures = 2
88 ccWant.activeBucket.Store(ib)
89 if diff := cmp.Diff(cc, ccWant); diff != "" {
90 t.Fatalf("callCounter is different than expected, diff (-got +want): %v", diff)
91 }
92}

Callers

nothing calls this directly

Calls 4

newCallCounterFunction · 0.85
FatalfMethod · 0.65
LoadMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected