Skip to content

Commit 8b61fab

Browse files
committed
Parallelize unit and integration tests
1 parent e44ad98 commit 8b61fab

File tree

20 files changed

+461
-34
lines changed

20 files changed

+461
-34
lines changed

.github/workflows/linters.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,31 @@ jobs:
122122
- name: check yaml formatting
123123
run: make lint-yaml
124124

125+
parallelize-tests:
126+
runs-on: ubuntu-latest
127+
steps:
128+
- uses: actions/checkout@v6
129+
with:
130+
fetch-depth: 0
131+
132+
- uses: actions/setup-go@v6
133+
with:
134+
go-version-file: "go.mod"
135+
check-latest: true
136+
137+
- name: check test parallelization
138+
run: make parallelize-tests
139+
140+
- name: check-is-dirty
141+
run: |
142+
if [[ -n $(git status --porcelain) ]]; then
143+
echo "Detected uncommitted changes after running parallelize-tests."
144+
echo "Run 'make parallelize-tests' locally and commit the changes."
145+
git status
146+
git diff
147+
exit 1
148+
fi
149+
125150
golangci:
126151
runs-on: ubuntu-latest
127152
steps:
@@ -156,6 +181,7 @@ jobs:
156181
- fmt-imports
157182
- lint-yaml
158183
- golangci
184+
- parallelize-tests
159185
runs-on: ubuntu-latest
160186
if: always()
161187
env:

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,10 @@ fmt-imports: $(GCI) # Don't get confused, there is a single linter called gci, w
408408
@printf $(COLOR) "Formatting imports..."
409409
@$(GCI) write --skip-generated -s standard -s default ./*
410410

411+
parallelize-tests:
412+
@printf $(COLOR) "Add t.Parallel() to tests..."
413+
@go run ./cmd/tools/parallelize $(INTEGRATION_TEST_DIRS)
414+
411415
fmt-yaml: $(YAMLFMT)
412416
@printf $(COLOR) "Formatting YAML files..."
413417
@$(YAMLFMT) -conf .github/.yamlfmt .

cmd/tools/parallelize/main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"go.temporal.io/server/tools/parallelize"
8+
)
9+
10+
func main() {
11+
if err := parallelize.Main(); err != nil {
12+
fmt.Fprintln(os.Stderr, err)
13+
os.Exit(1)
14+
}
15+
}

common/persistence/tests/cassandra_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ func (s *recordingSession) Query(query string, args ...interface{}) gocql.Query
120120
}
121121

122122
func TestCassandraShardStoreSuite(t *testing.T) {
123+
t.Parallel()
123124
testData, tearDown := setUpCassandraTest(t)
124125
defer tearDown()
125126

@@ -138,6 +139,7 @@ func TestCassandraShardStoreSuite(t *testing.T) {
138139
}
139140

140141
func TestCassandraExecutionMutableStateStoreSuite(t *testing.T) {
142+
t.Parallel()
141143
testData, tearDown := setUpCassandraTest(t)
142144
defer tearDown()
143145

@@ -161,6 +163,7 @@ func TestCassandraExecutionMutableStateStoreSuite(t *testing.T) {
161163
}
162164

163165
func TestCassandraExecutionMutableStateTaskStoreSuite(t *testing.T) {
166+
t.Parallel()
164167
testData, tearDown := setUpCassandraTest(t)
165168
defer tearDown()
166169

@@ -186,6 +189,7 @@ func TestCassandraExecutionMutableStateTaskStoreSuite(t *testing.T) {
186189
// TODO: Merge persistence-tests into the tests directory.
187190

188191
func TestCassandraHistoryStoreSuite(t *testing.T) {
192+
t.Parallel()
189193
testData, tearDown := setUpCassandraTest(t)
190194
defer tearDown()
191195

@@ -199,6 +203,7 @@ func TestCassandraHistoryStoreSuite(t *testing.T) {
199203
}
200204

201205
func TestCassandraTaskQueueSuite(t *testing.T) {
206+
t.Parallel()
202207
testData, tearDown := setUpCassandraTest(t)
203208
defer tearDown()
204209

@@ -212,6 +217,7 @@ func TestCassandraTaskQueueSuite(t *testing.T) {
212217
}
213218

214219
func TestCassandraFairTaskQueueSuite(t *testing.T) {
220+
t.Parallel()
215221
testData, tearDown := setUpCassandraTest(t)
216222
defer tearDown()
217223

@@ -225,6 +231,7 @@ func TestCassandraFairTaskQueueSuite(t *testing.T) {
225231
}
226232

227233
func TestCassandraTaskQueueTaskSuite(t *testing.T) {
234+
t.Parallel()
228235
testData, tearDown := setUpCassandraTest(t)
229236
defer tearDown()
230237

@@ -238,6 +245,7 @@ func TestCassandraTaskQueueTaskSuite(t *testing.T) {
238245
}
239246

240247
func TestCassandraTaskQueueFairTaskSuite(t *testing.T) {
248+
t.Parallel()
241249
testData, tearDown := setUpCassandraTest(t)
242250
defer tearDown()
243251

@@ -251,6 +259,7 @@ func TestCassandraTaskQueueFairTaskSuite(t *testing.T) {
251259
}
252260

253261
func TestCassandraTaskQueueUserDataSuite(t *testing.T) {
262+
t.Parallel()
254263
testData, tearDown := setUpCassandraTest(t)
255264
defer tearDown()
256265

@@ -264,27 +273,31 @@ func TestCassandraTaskQueueUserDataSuite(t *testing.T) {
264273
}
265274

266275
func TestCassandraHistoryV2Persistence(t *testing.T) {
276+
t.Parallel()
267277
s := new(persistencetests.HistoryV2PersistenceSuite)
268278
s.TestBase = persistencetests.NewTestBaseWithCassandra(&persistencetests.TestBaseOptions{})
269279
s.TestBase.Setup(nil)
270280
suite.Run(t, s)
271281
}
272282

273283
func TestCassandraMetadataPersistenceV2(t *testing.T) {
284+
t.Parallel()
274285
s := new(persistencetests.MetadataPersistenceSuiteV2)
275286
s.TestBase = persistencetests.NewTestBaseWithCassandra(&persistencetests.TestBaseOptions{})
276287
s.TestBase.Setup(nil)
277288
suite.Run(t, s)
278289
}
279290

280291
func TestCassandraClusterMetadataPersistence(t *testing.T) {
292+
t.Parallel()
281293
s := new(persistencetests.ClusterMetadataManagerSuite)
282294
s.TestBase = persistencetests.NewTestBaseWithCassandra(&persistencetests.TestBaseOptions{})
283295
s.TestBase.Setup(nil)
284296
suite.Run(t, s)
285297
}
286298

287299
func TestCassandraQueuePersistence(t *testing.T) {
300+
t.Parallel()
288301
s := new(persistencetests.QueuePersistenceSuite)
289302
s.TestBase = persistencetests.NewTestBaseWithCassandra(&persistencetests.TestBaseOptions{})
290303
s.TestBase.Setup(nil)
@@ -315,6 +328,7 @@ func TestCassandraQueueV2Persistence(t *testing.T) {
315328
}
316329

317330
func TestCassandraNexusEndpointPersistence(t *testing.T) {
331+
t.Parallel()
318332
cluster := persistencetests.NewTestClusterForCassandra(&persistencetests.TestBaseOptions{}, log.NewNoopLogger())
319333
cluster.SetupTestDatabase()
320334
t.Cleanup(cluster.TearDownTestDatabase)

0 commit comments

Comments
 (0)