Skip to content

Commit 4a2e88a

Browse files
authored
Parallelize integration tests (#9292)
## What changed? Made integration tests run in parallel. ## Why? Before: ~8min [[run](https://github.com/temporalio/temporal/actions/runs/21930252400/job/63333789136#step:7:1)] 🐢 After: ~3m [[run](https://github.com/temporalio/temporal/actions/runs/22114061618/job/63917852614?pr=9292)] 🐰 ## How did you test it? - [ ] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) ## Potential risks They are not known to be flaky; and anecdotally all passed on the first run.
1 parent d404081 commit 4a2e88a

File tree

22 files changed

+644
-37
lines changed

22 files changed

+644
-37
lines changed

.github/workflows/linters.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,32 @@ jobs:
128128
- name: check yaml formatting
129129
run: make lint-yaml
130130

131+
parallelize-tests:
132+
runs-on: ubuntu-24.04-arm
133+
steps:
134+
- uses: actions/checkout@v6
135+
with:
136+
fetch-depth: 0
137+
138+
- uses: actions/setup-go@v6
139+
with:
140+
go-version-file: "go.mod"
141+
check-latest: true
142+
cache: true
143+
144+
- name: check test parallelization
145+
run: make parallelize-tests
146+
147+
- name: check-is-dirty
148+
run: |
149+
if [[ -n $(git status --porcelain) ]]; then
150+
echo "Detected uncommitted changes after running parallelize-tests."
151+
echo "Run 'make parallelize-tests' locally and commit the changes."
152+
git status
153+
git diff
154+
exit 1
155+
fi
156+
131157
golangci:
132158
runs-on: ubuntu-24.04-arm
133159
steps:
@@ -163,6 +189,7 @@ jobs:
163189
- fmt-imports
164190
- lint-yaml
165191
- golangci
192+
- parallelize-tests
166193
runs-on: ubuntu-24.04-arm
167194
if: always()
168195
env:

Makefile

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

420+
parallelize-tests:
421+
@printf $(COLOR) "Add t.Parallel() to tests..."
422+
@go run ./cmd/tools/parallelize $(INTEGRATION_TEST_DIRS)
423+
420424
fmt-yaml: $(YAMLFMT)
421425
@printf $(COLOR) "Formatting YAML files..."
422426
@$(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 ...any) 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)