MCPcopy Create free account
hub / github.com/cortexproject/cortex / addInstanceAfterSomeTime

Function addInstanceAfterSomeTime

pkg/ring/util_test.go:75–90  ·  view source on GitHub ↗
(ring *Ring, addInstanceAfter time.Duration)

Source from the content-addressed store, hash-verified

73}
74
75func addInstanceAfterSomeTime(ring *Ring, addInstanceAfter time.Duration) {
76 go func() {
77 time.Sleep(addInstanceAfter)
78
79 ring.mtx.Lock()
80 defer ring.mtx.Unlock()
81 ringDesc := ring.ringDesc
82 instanceID := fmt.Sprintf("127.0.0.%d", len(ringDesc.Ingesters)+1)
83 ringDesc.Ingesters[instanceID] = InstanceDesc{Addr: instanceID, State: ACTIVE, Timestamp: time.Now().Unix()}
84 ring.ringDesc = ringDesc
85 ring.ringTokens = ringDesc.GetTokens()
86 ring.ringTokensByZone = ringDesc.getTokensByZone()
87 ring.ringInstanceByToken = ringDesc.getTokensInfo()
88 ring.ringZones = getZones(ringDesc.getTokensByZone())
89 }()
90}
91
92func TestWaitRingStability_ShouldReturnOnceMinStabilityOfInstancesHasBeenReached(t *testing.T) {
93 t.Parallel()

Calls 4

getZonesFunction · 0.85
getTokensByZoneMethod · 0.80
getTokensInfoMethod · 0.80
GetTokensMethod · 0.45

Tested by

no test coverage detected