Skip to content

Commit f715120

Browse files
feat(Spanner): Add workflow dispatch options to run specific test suites or individual tests within Spanner PR
1 parent 18949a0 commit f715120

File tree

9 files changed

+51
-6
lines changed

9 files changed

+51
-6
lines changed

.github/workflows/spanner-load-tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ on:
2121
# at 02:00 weekly on every Tuesday.
2222
- cron: '0 2 * * 2'
2323
workflow_dispatch:
24+
inputs:
25+
specific_test:
26+
description: 'Specific Integration Test (passed to -Dtest=)'
27+
required: false
28+
type: string
2429

2530
permissions: write-all
2631

@@ -102,7 +107,8 @@ jobs:
102107
--it-artifact-bucket="cloud-teleport-testing-it-gitactions" \
103108
--lt-export-project="cloud-teleport-testing" \
104109
--lt-export-dataset="performance_tests" \
105-
--lt-export-table="template_performance_metrics"
110+
--lt-export-table="template_performance_metrics" \
111+
--test="${{ github.event.inputs.specific_test }}"
106112
- name: Upload Load Test Observer Report
107113
uses: actions/upload-artifact@v6
108114
if: always() # always run even if the previous step fails

.github/workflows/spanner-pr.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ on:
4343
schedule:
4444
- cron: "3 */12 * * *"
4545
workflow_dispatch:
46+
inputs:
47+
specific_test:
48+
description: 'Specific Integration Test (passed to -Dtest=)'
49+
required: false
50+
type: string
4651

4752
concurrency:
4853
group: ${{ github.workflow }}-${{ github.ref }}
@@ -184,7 +189,8 @@ jobs:
184189
--it-project="span-cloud-teleport-testing" \
185190
--it-artifact-bucket="span-cloud-teleport-testing-it-gitactions" \
186191
--it-private-connectivity="datastream-connect-2" \
187-
--it-cloud-proxy-host="10.128.0.16"
192+
--it-cloud-proxy-host="10.128.0.16" \
193+
--test="${{ github.event.inputs.specific_test }}"
188194
- name: Upload Integration Tests Report
189195
uses: actions/upload-artifact@v6
190196
if: always() # always run even if the previous step fails

cicd/cmd/run-it-smoke-tests/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ func main() {
7272
flags.CloudProxyHost(),
7373
flags.CloudProxyMySqlPort(),
7474
flags.CloudProxyPostgresPort(),
75-
flags.CloudProxyPassword())
75+
flags.CloudProxyPassword(),
76+
mvnFlags.SpecificTest(flags.TestToRun()),
77+
mvnFlags.FailIfNoTests(flags.TestToRun() != ""))
7678
if err != nil {
7779
log.Fatalf("%v\n", err)
7880
}

cicd/cmd/run-it-tests/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ func main() {
7575
flags.CloudProxyPostgresPort(),
7676
flags.CloudProxyPassword(),
7777
flags.UnifiedWorkerHarnessContainerImage(),
78-
flags.CloudProxyPassword())
78+
flags.CloudProxyPassword(),
79+
mvnFlags.SpecificTest(flags.TestToRun()),
80+
mvnFlags.FailIfNoTests(flags.TestToRun() != ""))
7981
if err != nil {
8082
log.Fatalf("%v\n", err)
8183
}

cicd/cmd/run-load-test-observer/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ func main() {
7474
flags.CloudProxyHost(),
7575
flags.CloudProxyMySqlPort(),
7676
flags.CloudProxyPostgresPort(),
77-
flags.CloudProxyPassword())
77+
flags.CloudProxyPassword(),
78+
mvnFlags.SpecificTest(flags.TestToRun()),
79+
mvnFlags.FailIfNoTests(flags.TestToRun() != ""))
7880
if err != nil {
7981
log.Fatalf("%v\n", err)
8082
}

cicd/cmd/run-load-tests/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ func main() {
7474
flags.CloudProxyHost(),
7575
flags.CloudProxyMySqlPort(),
7676
flags.CloudProxyPostgresPort(),
77-
flags.CloudProxyPassword())
77+
flags.CloudProxyPassword(),
78+
mvnFlags.SpecificTest(flags.TestToRun()),
79+
mvnFlags.FailIfNoTests(flags.TestToRun() != ""))
7880
if err != nil {
7981
log.Fatalf("%v\n", err)
8082
}

cicd/cmd/run-unit-tests/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ func main() {
3939
mvnFlags.SkipIntegrationTests(),
4040
mvnFlags.FailAtTheEnd(),
4141
mvnFlags.ThreadCount(8),
42+
mvnFlags.SpecificTest(flags.TestToRun()),
43+
mvnFlags.FailIfNoTests(flags.TestToRun() != ""),
4244
mvnFlags.InternalMaven())
4345
if err != nil {
4446
log.Fatalf("%v\n", err)

cicd/internal/flags/common-flags.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const (
3434
// Avoid making these vars public.
3535
var (
3636
modulesToBuild string
37+
testToRun string
3738
moduleMap = map[string][]string{
3839
ALL: {},
3940
DEFAULT: {},
@@ -76,6 +77,7 @@ var (
7677
// Registers all common flags. Must be called before flag.Parse().
7778
func RegisterCommonFlags() {
7879
flag.StringVar(&modulesToBuild, "modules-to-build", ALL, "List of modules to build/run commands against")
80+
flag.StringVar(&testToRun, "test", "", "Specific test to run")
7981
}
8082

8183
// Returns all modules to build.
@@ -102,3 +104,8 @@ func ModulesToBuild() []string {
102104
}
103105
return strings.Split(m, ",")
104106
}
107+
108+
// Returns the specific test to run.
109+
func TestToRun() string {
110+
return testToRun
111+
}

cicd/internal/workflows/maven-workflows.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ type MavenFlags interface {
6161
StaticSpannerInstance(string) string
6262
SpannerHost(string) string
6363
InternalMaven() string
64+
SpecificTest(string) string
65+
FailIfNoTests(bool) string
6466
}
6567

6668
type mvnFlags struct{}
@@ -163,6 +165,20 @@ func (*mvnFlags) InternalMaven() string {
163165
return "--settings=.mvn/settings.xml"
164166
}
165167

168+
func (*mvnFlags) SpecificTest(test string) string {
169+
if test == "" {
170+
return ""
171+
}
172+
return "-Dtest=" + test
173+
}
174+
175+
func (*mvnFlags) FailIfNoTests(skip bool) string {
176+
if skip {
177+
return "-Dsurefire.failIfNoSpecifiedTests=false"
178+
}
179+
return ""
180+
}
181+
166182
func NewMavenFlags() MavenFlags {
167183
return &mvnFlags{}
168184
}

0 commit comments

Comments
 (0)