Skip to content

Commit 941b1d4

Browse files
committed
Add ARM platform detection and skip incompatible test suites
- Detect ARM/Apple Silicon platform using runtime.GOARCH - Skip MySQL 5.6, 5.7 and Percona 5.7, 8.0 on ARM (no ARM64 builds) - Display skipped suites in test output with reason - Add testcontainers build tag to all test files using getSharedMySQLContainer - Update test summary to show skipped count and total suites - Fixes vet errors for undefined getSharedMySQLContainer
1 parent d78981d commit 941b1d4

10 files changed

+113
-9
lines changed

mysql/data_source_tables_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build testcontainers
2+
// +build testcontainers
3+
14
package mysql
25

36
import (

mysql/resource_database_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build testcontainers
2+
// +build testcontainers
3+
14
package mysql
25

36
import (

mysql/resource_default_roles_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build testcontainers
2+
// +build testcontainers
3+
14
package mysql
25

36
import (

mysql/resource_global_variable_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build testcontainers
2+
// +build testcontainers
3+
14
package mysql
25

36
import (

mysql/resource_grant_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build testcontainers
2+
// +build testcontainers
3+
14
package mysql
25

36
import (

mysql/resource_role_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build testcontainers
2+
// +build testcontainers
3+
14
package mysql
25

36
import (

mysql/resource_user_password_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build testcontainers
2+
// +build testcontainers
3+
14
package mysql
25

36
import (

mysql/resource_user_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build testcontainers
2+
// +build testcontainers
3+
14
package mysql
25

36
import (

scripts/test-runner.go

Lines changed: 89 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ type testResult struct {
5151
image string
5252
dbType string
5353
passed bool
54+
skipped bool
55+
skipReason string
5456
logFile string
5557
duration time.Duration
5658
totalTests int
@@ -102,16 +104,36 @@ func main() {
102104
// Get parallelism from environment variable
103105
parallel := getParallelism()
104106

107+
// Detect platform architecture
108+
isARM := isARMPlatform()
109+
105110
fmt.Printf("Testcontainers Matrix Test Suite\n")
106-
fmt.Printf("Test pattern: %s | Parallelism: %d\n\n", testPattern, parallel)
111+
fmt.Printf("Test pattern: %s | Parallelism: %d", testPattern, parallel)
112+
if isARM {
113+
fmt.Printf(" | Platform: ARM (Apple Silicon)")
114+
}
115+
fmt.Printf("\n\n")
107116

108-
// Build all test jobs
117+
// Build all test jobs and track skipped ones
109118
var jobs []testJob
119+
var skippedResults []testResult
110120
testNum := 0
111121

112122
// MySQL tests
113123
for _, version := range mysqlVersions {
114124
testNum++
125+
// Skip MySQL 5.6 and 5.7 on ARM (no ARM64 builds available)
126+
if isARM && (version == "mysql:5.6" || version == "mysql:5.7") {
127+
skippedResults = append(skippedResults, testResult{
128+
image: version,
129+
dbType: "MySQL",
130+
passed: true, // Skipped tests don't fail the suite
131+
skipped: true,
132+
skipReason: "No ARM64 builds available",
133+
duration: 0,
134+
})
135+
continue
136+
}
115137
jobs = append(jobs, testJob{
116138
image: version,
117139
dbType: "MySQL",
@@ -123,6 +145,18 @@ func main() {
123145
// Percona tests
124146
for _, version := range perconaVersions {
125147
testNum++
148+
// Skip Percona 5.7 and 8.0 on ARM (no ARM64 builds available)
149+
if isARM && (version == "percona:5.7" || version == "percona:8.0") {
150+
skippedResults = append(skippedResults, testResult{
151+
image: version,
152+
dbType: "Percona",
153+
passed: true, // Skipped tests don't fail the suite
154+
skipped: true,
155+
skipReason: "No ARM64 builds available",
156+
duration: 0,
157+
})
158+
continue
159+
}
126160
jobs = append(jobs, testJob{
127161
image: version,
128162
dbType: "Percona",
@@ -165,17 +199,27 @@ func main() {
165199
results = runTestsSequential(jobs)
166200
}
167201

202+
// Add skipped results to the results list
203+
results = append(results, skippedResults...)
204+
168205
// Print summary
169206
printSummary(results)
170207

171-
// Exit with error code if any tests failed
208+
// Exit with error code if any tests failed (skipped tests don't count as failures)
172209
for _, result := range results {
173-
if !result.passed {
210+
if !result.passed && !result.skipped {
174211
os.Exit(1)
175212
}
176213
}
177214
}
178215

216+
// isARMPlatform detects if we're running on ARM architecture (including Apple Silicon)
217+
func isARMPlatform() bool {
218+
arch := runtime.GOARCH
219+
// Check for ARM architectures
220+
return arch == "arm64" || arch == "arm"
221+
}
222+
179223
func getParallelism() int {
180224
parallelStr := os.Getenv("PARALLEL")
181225
if parallelStr == "" {
@@ -251,6 +295,30 @@ func runTestsParallel(jobs []testJob, parallel int) []testResult {
251295
func runTest(job testJob) testResult {
252296
key := fmt.Sprintf("%s-%s", job.dbType, job.image)
253297

298+
// Check if this test should be skipped on ARM
299+
isARM := isARMPlatform()
300+
shouldSkip := false
301+
skipReason := ""
302+
if isARM {
303+
if (job.dbType == "MySQL" && (job.image == "mysql:5.6" || job.image == "mysql:5.7")) ||
304+
(job.dbType == "Percona" && (job.image == "percona:5.7" || job.image == "percona:8.0")) {
305+
shouldSkip = true
306+
skipReason = "No ARM64 builds available"
307+
}
308+
}
309+
310+
if shouldSkip {
311+
// Return skipped result immediately
312+
return testResult{
313+
image: job.image,
314+
dbType: job.dbType,
315+
passed: true, // Skipped tests don't fail the suite
316+
skipped: true,
317+
skipReason: skipReason,
318+
duration: 0,
319+
}
320+
}
321+
254322
// Initialize progress tracker
255323
progress.mu.Lock()
256324
progress.trackers[key] = &versionProgress{
@@ -630,21 +698,26 @@ func printSummary(results []testResult) {
630698
)
631699

632700
// Add rows
701+
skippedCount := 0
633702
for _, result := range sortedResults {
634-
status := "PASS"
635-
if !result.passed {
703+
var status string
704+
if result.skipped {
705+
status = fmt.Sprintf("SKIP (%s)", result.skipReason)
706+
skippedCount++
707+
} else if !result.passed {
636708
status = "FAIL"
637709
failed++
638710
} else {
711+
status = "PASS"
639712
passed++
640713
}
641714

642715
// Extract version from image (e.g., "mysql:8.0" -> "8.0")
643716
version := extractVersion(result.image)
644717
duration := formatDuration(result.duration)
645718

646-
// Add test counts to status
647-
if result.totalTests > 0 {
719+
// Add test counts to status (only for non-skipped tests)
720+
if !result.skipped && result.totalTests > 0 {
648721
if result.failedTests > 0 {
649722
status = fmt.Sprintf("%s (%d/%d, %d failed)", status, result.passedTests, result.totalTests, result.failedTests)
650723
} else {
@@ -663,10 +736,17 @@ func printSummary(results []testResult) {
663736

664737
table.Render()
665738

666-
fmt.Printf("\nSummary: %d/%d passed", passed, total)
739+
totalRun := passed + failed
740+
fmt.Printf("\nSummary: %d/%d passed", passed, totalRun)
741+
if skippedCount > 0 {
742+
fmt.Printf(", %d skipped", skippedCount)
743+
}
667744
if failed > 0 {
668745
fmt.Printf(", %d failed", failed)
669746
}
747+
if skippedCount > 0 {
748+
fmt.Printf(" (%d total test suites)", total)
749+
}
670750
fmt.Println()
671751

672752
if failed > 0 {

test-runner

4.35 MB
Binary file not shown.

0 commit comments

Comments
 (0)