test_cluster_pool.go ×8

Frontier kind: Joint frontier

unlabeled · c_c6916f6a0c88

3 tests · 2994 LOC · 153 files · introduces 2 tests · 37 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges37 lines · 1 files
Tests
2 tests

Contains — complete concept membership

All code (extent)
441 ranges2994 lines · 153 files · Browse complete extent
All tests (intent)
3 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

2 tests introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 37 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/tests/testcore/test_cluster_pool.go 37 introduced LOC · 8 ranges

Open complete file

98 // For exclusive pools, blocks until a slot is available and registers cleanup.
99 // For shared pools, uses round-robin.
100 > func (p *clusterPool) get(t *testing.T, createCluster func() *FunctionalTestBase) *FunctionalTestBase { test_cluster_pool.go
101 > slot := p.reserveSlot(t)
102 > cluster := slot.acquire(t, createCluster)
103 > t.Cleanup(slot.release)
104 > return cluster
105 > }
106
107 func (p *clusterPool) reserveSlot(t *testing.T) *clusterPoolSlot {
111 return slot
112 }
113 > return p.nextSlot() test_cluster_pool.go
114 }
115
116 > func (p *clusterPool) nextSlot() *clusterPoolSlot { test_cluster_pool.go
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)
144
145 // Recreate idle clusters after the lease limit is reached.
146 > if s.maxLeases > 0 && s.leaseCount >= s.maxLeases && s.activeLeases == 0 { test_cluster_pool.go
147 s.tearDownLocked(t)
148 s.cluster = createCluster()
150 }
151
152 > s.leaseCount++ test_cluster_pool.go
153 > s.activeLeases++
154 > cluster.SetT(t)
155 > return cluster
156 }
157
158 > func (s *clusterPoolSlot) release() { test_cluster_pool.go
159 > s.Lock()
160 > defer s.Unlock()
161 > if s.activeLeases == 0 {
162 panic("release called without matching acquire")
163 }
164 > s.activeLeases-- test_cluster_pool.go
165 }
166