111
return slot
112
}
114
}
115
117
>
p.Lock()
118
>
defer p.Unlock()
119
>
slot := p.allSlots[p.nextSlotIdx]
120
>
p.nextSlotIdx = (p.nextSlotIdx + 1) % len(p.allSlots)
121
>
return slot
122
>
}
123
124
>
func (s *clusterPoolSlot) acquire(t *testing.T, createCluster func() *FunctionalTestBase) *FunctionalTestBase {
test_cluster_pool.go
125
>
s.Lock()
126
>
defer s.Unlock()
127
>
128
>
// Lazy initialization for first use
129
>
if s.cluster == nil {
130
>
s.cluster = createCluster()
131
>
}
132
>
cluster := s.cluster
133
>
134
>
// Swap out poisoned clusters. An active poisoned cluster will tear itself down during its
135
>
// last test run's cleanup; an idle poisoned cluster can be torn down here.
136
>
if cluster.Poisoned() {
137
if s.activeLeases == 0 {
138
s.tearDownLocked(t)