Skip to content

Commit 9dca20a

Browse files
committed
feat: Migrate CI and test infrastructure to testcontainers
This commit migrates the test infrastructure from Makefile-based Docker management to testcontainers, providing a more maintainable and portable testing solution. Key changes: - Add TiDB testcontainers support with multi-container cluster setup - Implement startTiDBCluster() for PD, TiKV, and TiDB coordination - Add shared TiDB cluster management in TestMain - Support all TiDB versions: 6.1.7, 6.5.12, 7.1.6, 7.5.7, 8.1.2, 8.5.3 - Convert CI workflow to use testcontainers - Replace Makefile targets with direct go test commands - Simplify workflow by removing Docker Buildx caching and mysql-client - Use matrix strategy with db_type and db_version for all database types - Reduce workflow complexity by ~100 lines - Create Go-based test runner (scripts/test-runner.go) - Replace bash script with Go implementation for better maintainability - Add parallelism support via PARALLEL environment variable - Add formatted table output using tablewriter library - Support MySQL, Percona, MariaDB, and TiDB test matrices - Improve test infrastructure - Rename TESTCONTAINERS_MYSQL_IMAGE to DOCKER_IMAGE for clarity - Add shared container pattern with TestMain for efficiency - Suppress MySQL driver "unexpected EOF" log messages - Add mysql_no_login plugin installation attempt with graceful fallback - Fix TestAccUser_auth to skip when plugin unavailable - Update dependencies - Upgrade testcontainers-go to v0.40.0 - Add tablewriter library for formatted output - Add testcontainers-go/network for TiDB multi-container support Benefits: - Simpler CI/CD: No complex Makefile coordination needed - Better isolation: Testcontainers handles container lifecycle - Faster execution: Shared containers reduce startup overhead - Easier maintenance: Pure Go implementation, no shell scripts - Consistent approach: All database types use same testcontainers pattern Test coverage: - MySQL: 5.6, 5.7, 8.0 - Percona: 5.7, 8.0 - MariaDB: 10.3, 10.8, 10.10 - TiDB: 6.1.7, 6.5.12, 7.1.6, 7.5.7, 8.1.2, 8.5.3
1 parent 98fc205 commit 9dca20a

19 files changed

+2089
-178
lines changed

.github/workflows/main.yml

Lines changed: 64 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ jobs:
4040
run: |
4141
# Extract TiDB versions from test matrix and compare with env.TIDB_VERSIONS
4242
EXPECTED_VERSIONS="${{ env.TIDB_VERSIONS }}"
43-
MATRIX_VERSIONS=$(grep -E "testtidb[0-9]" .github/workflows/main.yml | sed 's/.*testtidb\([0-9.]*\).*/\1/' | tr '\n' ' ' | xargs)
43+
MATRIX_VERSIONS=$(grep -A 20 "db_type: tidb" .github/workflows/main.yml | grep "db_version:" | sed 's/.*db_version: "\([0-9.]*\)".*/\1/' | tr '\n' ' ' | xargs)
4444
4545
echo "Expected versions (from env): $EXPECTED_VERSIONS"
46-
echo "Matrix versions (from test targets): $MATRIX_VERSIONS"
46+
echo "Matrix versions (from workflow): $MATRIX_VERSIONS"
4747
4848
# Check if versions match (simple check - both should contain same versions)
4949
MISSING=""
@@ -55,7 +55,7 @@ jobs:
5555
5656
if [ -n "$MISSING" ]; then
5757
echo "ERROR: TiDB versions in env.TIDB_VERSIONS not found in test matrix: $MISSING"
58-
echo "Please ensure test matrix includes testtidb* entries for all versions in env.TIDB_VERSIONS"
58+
echo "Please ensure test matrix includes tidb entries for all versions in env.TIDB_VERSIONS"
5959
exit 1
6060
fi
6161
@@ -75,22 +75,8 @@ jobs:
7575
- name: Vendor Go dependencies
7676
run: go mod vendor
7777

78-
# Note: TiDB tests now use Docker images with Buildx caching instead of TiUP
79-
# Docker images are cached per version in individual test jobs using Buildx with GHA cache backend
80-
# Each test job pulls and caches its own images - no pre-pull needed since Docker layer cache is ephemeral per job
81-
82-
- name: Cache apt packages
83-
uses: actions/cache@v4
84-
with:
85-
path: /var/cache/apt/archives
86-
key: ${{ runner.os }}-apt-${{ hashFiles('**/.github/workflows/main.yml') }}
87-
restore-keys: |
88-
${{ runner.os }}-apt-
89-
90-
- name: Install mysql client (populates cache for test jobs)
91-
run: |
92-
sudo apt-get update -qq
93-
sudo apt-get install -y --no-install-recommends mysql-client
78+
# Note: Tests now use testcontainers - no mysql-client or Docker Buildx caching needed
79+
# Testcontainers handles container lifecycle and image pulling automatically
9480

9581
- name: Upload Terraform binary
9682
uses: actions/upload-artifact@v4
@@ -113,24 +99,47 @@ jobs:
11399
strategy:
114100
fail-fast: false
115101
matrix:
116-
target:
117-
- testversion5.6
118-
- testversion5.7
119-
- testversion8.0
120-
- testpercona5.7
121-
- testpercona8.0
122-
- testmariadb10.3
123-
- testmariadb10.8
124-
- testmariadb10.10
125-
# Track https://github.com/pingcap/tidb/tags
126-
# TiDB versions must match env.TIDB_VERSIONS: 6.1.7 6.5.12 7.1.6 7.5.7 8.1.2 8.5.3
127-
# Latest version of each minor series
128-
- testtidb6.1.7
129-
- testtidb6.5.12
130-
- testtidb7.1.6
131-
- testtidb7.5.7
132-
- testtidb8.1.2
133-
- testtidb8.5.3
102+
include:
103+
# MySQL versions
104+
- db_type: mysql
105+
db_version: "5.6"
106+
docker_image: "mysql:5.6"
107+
- db_type: mysql
108+
db_version: "5.7"
109+
docker_image: "mysql:5.7"
110+
- db_type: mysql
111+
db_version: "8.0"
112+
docker_image: "mysql:8.0"
113+
# Percona versions
114+
- db_type: percona
115+
db_version: "5.7"
116+
docker_image: "percona:5.7"
117+
- db_type: percona
118+
db_version: "8.0"
119+
docker_image: "percona:8.0"
120+
# MariaDB versions
121+
- db_type: mariadb
122+
db_version: "10.3"
123+
docker_image: "mariadb:10.3"
124+
- db_type: mariadb
125+
db_version: "10.8"
126+
docker_image: "mariadb:10.8"
127+
- db_type: mariadb
128+
db_version: "10.10"
129+
docker_image: "mariadb:10.10"
130+
# TiDB versions - must match env.TIDB_VERSIONS: 6.1.7 6.5.12 7.1.6 7.5.7 8.1.2 8.5.3
131+
- db_type: tidb
132+
db_version: "6.1.7"
133+
- db_type: tidb
134+
db_version: "6.5.12"
135+
- db_type: tidb
136+
db_version: "7.1.6"
137+
- db_type: tidb
138+
db_version: "7.5.7"
139+
- db_type: tidb
140+
db_version: "8.1.2"
141+
- db_type: tidb
142+
db_version: "8.5.3"
134143
steps:
135144
- name: Checkout Git repo
136145
uses: actions/checkout@v4
@@ -157,136 +166,33 @@ jobs:
157166
- name: Make Terraform executable
158167
run: chmod +x bin/terraform
159168

160-
- name: Cache apt packages
161-
uses: actions/cache@v4
162-
with:
163-
path: /var/cache/apt/archives
164-
key: ${{ runner.os }}-apt-${{ hashFiles('**/.github/workflows/main.yml') }}
165-
restore-keys: |
166-
${{ runner.os }}-apt-
167-
168-
- name: Install mysql client
169-
run: |
170-
sudo apt-get update -qq
171-
sudo apt-get install -y --no-install-recommends mysql-client
172-
173169
- name: Set up Docker Buildx
174-
if: contains(matrix.target, 'testversion') || contains(matrix.target, 'testpercona') || contains(matrix.target, 'testmariadb')
175170
uses: docker/setup-buildx-action@v3
176171

177-
- name: Determine Docker image for this test
178-
if: contains(matrix.target, 'testversion') || contains(matrix.target, 'testpercona') || contains(matrix.target, 'testmariadb')
179-
id: docker-image
180-
run: |
181-
if [[ "${{ matrix.target }}" == testversion5.6 ]]; then
182-
echo "image=mysql:5.6" >> $GITHUB_OUTPUT
183-
elif [[ "${{ matrix.target }}" == testversion5.7 ]]; then
184-
echo "image=mysql:5.7" >> $GITHUB_OUTPUT
185-
elif [[ "${{ matrix.target }}" == testversion8.0 ]]; then
186-
echo "image=mysql:8.0" >> $GITHUB_OUTPUT
187-
elif [[ "${{ matrix.target }}" == testpercona5.7 ]]; then
188-
echo "image=percona:5.7" >> $GITHUB_OUTPUT
189-
elif [[ "${{ matrix.target }}" == testpercona8.0 ]]; then
190-
echo "image=percona:8.0" >> $GITHUB_OUTPUT
191-
elif [[ "${{ matrix.target }}" == testmariadb10.3 ]]; then
192-
echo "image=mariadb:10.3" >> $GITHUB_OUTPUT
193-
elif [[ "${{ matrix.target }}" == testmariadb10.8 ]]; then
194-
echo "image=mariadb:10.8" >> $GITHUB_OUTPUT
195-
elif [[ "${{ matrix.target }}" == testmariadb10.10 ]]; then
196-
echo "image=mariadb:10.10" >> $GITHUB_OUTPUT
197-
fi
198-
199-
- name: Pull and cache Docker image using Buildx
200-
if: contains(matrix.target, 'testversion') || contains(matrix.target, 'testpercona') || contains(matrix.target, 'testmariadb')
201-
uses: docker/build-push-action@v5
202-
with:
203-
context: .
204-
file: Dockerfile.mysql
205-
push: false
206-
tags: ${{ steps.docker-image.outputs.image }}
207-
build-args: |
208-
MYSQL_IMAGE=${{ steps.docker-image.outputs.image }}
209-
cache-from: type=gha,scope=${{ steps.docker-image.outputs.image }}
210-
cache-to: type=gha,mode=max,scope=${{ steps.docker-image.outputs.image }}
211-
212-
- name: Extract TiDB version from test target
213-
id: extract-tidb-version
214-
if: contains(matrix.target, 'tidb')
172+
- name: Pre-pull Docker images for caching
173+
if: matrix.db_type != 'tidb'
215174
run: |
216-
# Extract version from testtidb6.1.7 -> 6.1.7
217-
VERSION=$(echo "${{ matrix.target }}" | sed 's/testtidb//')
218-
echo "version=${VERSION}" >> $GITHUB_OUTPUT
219-
echo "TiDB version for this test: ${VERSION}"
175+
docker pull ${{ matrix.docker_image }} || true
220176
221-
- name: Set up Docker Buildx for TiDB
222-
if: contains(matrix.target, 'tidb')
223-
uses: docker/setup-buildx-action@v3
224-
225-
- name: Pull TiDB Docker images in parallel
226-
if: contains(matrix.target, 'tidb')
177+
- name: Pre-pull TiDB images for caching
178+
if: matrix.db_type == 'tidb'
227179
run: |
228-
VERSION="${{ steps.extract-tidb-version.outputs.version }}"
229-
echo "Pulling TiDB component images for v${VERSION} in parallel..."
230-
231-
# Pull all three images in parallel
232-
docker pull pingcap/tidb:v${VERSION} &
233-
docker pull pingcap/pd:v${VERSION} &
234-
docker pull pingcap/tikv:v${VERSION} &
235-
236-
# Wait for all pulls to complete
237-
wait
238-
239-
echo "All TiDB component images pulled successfully"
240-
241-
- name: Cache TiDB Docker images using Buildx
242-
if: contains(matrix.target, 'tidb')
243-
uses: docker/build-push-action@v5
244-
continue-on-error: false
245-
with:
246-
context: .
247-
file: Dockerfile.tidb
248-
push: false
249-
tags: pingcap/tidb:v${{ steps.extract-tidb-version.outputs.version }}
250-
build-args: |
251-
TIDB_COMPONENT=pingcap/tidb
252-
TIDB_VERSION=v${{ steps.extract-tidb-version.outputs.version }}
253-
cache-from: type=gha,scope=tidb-v${{ steps.extract-tidb-version.outputs.version }}
254-
cache-to: type=gha,mode=max,scope=tidb-v${{ steps.extract-tidb-version.outputs.version }}
180+
docker pull pingcap/tidb:v${{ matrix.db_version }} || true
181+
docker pull pingcap/pd:v${{ matrix.db_version }} || true
182+
docker pull pingcap/tikv:v${{ matrix.db_version }} || true
255183
256-
- name: Pull and cache PD Docker image using Buildx
257-
if: contains(matrix.target, 'tidb')
258-
uses: docker/build-push-action@v5
259-
continue-on-error: false
260-
with:
261-
context: .
262-
file: Dockerfile.tidb
263-
push: false
264-
tags: pingcap/pd:v${{ steps.extract-tidb-version.outputs.version }}
265-
build-args: |
266-
TIDB_COMPONENT=pingcap/pd
267-
TIDB_VERSION=v${{ steps.extract-tidb-version.outputs.version }}
268-
cache-from: type=gha,scope=pd-v${{ steps.extract-tidb-version.outputs.version }}
269-
cache-to: type=gha,mode=max,scope=pd-v${{ steps.extract-tidb-version.outputs.version }}
270-
271-
- name: Pull and cache TiKV Docker image using Buildx
272-
if: contains(matrix.target, 'tidb')
273-
uses: docker/build-push-action@v5
274-
continue-on-error: false
275-
with:
276-
context: .
277-
file: Dockerfile.tidb
278-
push: false
279-
tags: pingcap/tikv:v${{ steps.extract-tidb-version.outputs.version }}
280-
build-args: |
281-
TIDB_COMPONENT=pingcap/tikv
282-
TIDB_VERSION=v${{ steps.extract-tidb-version.outputs.version }}
283-
cache-from: type=gha,scope=tikv-v${{ steps.extract-tidb-version.outputs.version }}
284-
cache-to: type=gha,mode=max,scope=tikv-v${{ steps.extract-tidb-version.outputs.version }}
285-
286-
- name: Run tests {{ matrix.target }}
184+
- name: Run testcontainers tests
287185
env:
288186
GOFLAGS: -mod=vendor
289-
run: make ${{ matrix.target }}
187+
TF_ACC: 1
188+
GOTOOLCHAIN: auto
189+
run: |
190+
export PATH="${{ github.workspace }}/bin:$PATH"
191+
if [ "${{ matrix.db_type }}" == "tidb" ]; then
192+
TIDB_VERSION=${{ matrix.db_version }} go test -tags=testcontainers -v ./mysql/... -run WithTestcontainers -timeout=30m
193+
else
194+
DOCKER_IMAGE=${{ matrix.docker_image }} go test -tags=testcontainers -v ./mysql/... -run WithTestcontainers -timeout=30m
195+
fi
290196
# DISABLED to figure out GPG signing issue on Github Actions
291197
# possibly due to lack of TTY inside docker?
292198
# release:

GNUmakefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ build: fmtcheck
4141

4242
test: acceptance
4343

44+
# Run testcontainers tests with a matrix of MySQL versions
45+
# Usage: make testcontainers-matrix TESTARGS="TestAccUser"
46+
testcontainers-matrix: fmtcheck
47+
@cd $(CURDIR) && go run scripts/test-runner.go $(if $(TESTARGS),$(TESTARGS),WithTestcontainers)
48+
49+
# Run testcontainers tests for a specific MySQL image
50+
# Usage: make testcontainers-image DOCKER_IMAGE=mysql:8.0
51+
testcontainers-image: fmtcheck bin/terraform
52+
DOCKER_IMAGE=$(DOCKER_IMAGE) TF_ACC=1 GOTOOLCHAIN=auto go test -tags=testcontainers $(TEST) -v $(TESTARGS) -timeout=15m
53+
4454
bin/terraform:
4555
mkdir -p "$(CURDIR)/bin"
4656
curl -sfL https://releases.hashicorp.com/terraform/$(TERRAFORM_VERSION)/terraform_$(TERRAFORM_VERSION)_$(TERRAFORM_OS)_$(ARCH).zip > $(CURDIR)/bin/terraform.zip

go.mod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ require (
3232
github.com/agext/levenshtein v1.2.3 // indirect
3333
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
3434
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
35+
github.com/clipperhouse/displaywidth v0.3.1 // indirect
36+
github.com/clipperhouse/stringish v0.1.1 // indirect
37+
github.com/clipperhouse/uax29/v2 v2.2.0 // indirect
3538
github.com/cloudflare/circl v1.3.8 // indirect
3639
github.com/containerd/errdefs v1.0.0 // indirect
3740
github.com/containerd/errdefs/pkg v0.3.0 // indirect
@@ -81,6 +84,7 @@ require (
8184
github.com/magiconair/properties v1.8.10 // indirect
8285
github.com/mattn/go-colorable v0.1.13 // indirect
8386
github.com/mattn/go-isatty v0.0.20 // indirect
87+
github.com/mattn/go-runewidth v0.0.19 // indirect
8488
github.com/mitchellh/copystructure v1.2.0 // indirect
8589
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
8690
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
@@ -95,6 +99,10 @@ require (
9599
github.com/moby/term v0.5.0 // indirect
96100
github.com/morikuni/aec v1.0.0 // indirect
97101
github.com/oklog/run v1.1.0 // indirect
102+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
103+
github.com/olekukonko/errors v1.1.0 // indirect
104+
github.com/olekukonko/ll v0.1.2 // indirect
105+
github.com/olekukonko/tablewriter v1.1.1 // indirect
98106
github.com/opencontainers/go-digest v1.0.0 // indirect
99107
github.com/opencontainers/image-spec v1.1.1 // indirect
100108
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect

go.sum

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3
3939
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
4040
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
4141
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
42+
github.com/clipperhouse/displaywidth v0.3.1 h1:k07iN9gD32177o1y4O1jQMzbLdCrsGJh+blirVYybsk=
43+
github.com/clipperhouse/displaywidth v0.3.1/go.mod h1:tgLJKKyaDOCadywag3agw4snxS5kYEuYR6Y9+qWDDYM=
44+
github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
45+
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
46+
github.com/clipperhouse/uax29/v2 v2.2.0 h1:ChwIKnQN3kcZteTXMgb1wztSgaU+ZemkgWdohwgs8tY=
47+
github.com/clipperhouse/uax29/v2 v2.2.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
4248
github.com/cloudflare/circl v1.3.8 h1:j+V8jJt09PoeMFIu2uh5JUyEaIHTXVOHslFoLNAKqwI=
4349
github.com/cloudflare/circl v1.3.8/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU=
4450
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
@@ -240,6 +246,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
240246
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
241247
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
242248
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
249+
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
250+
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
243251
github.com/microsoft/go-mssqldb v1.7.2 h1:CHkFJiObW7ItKTJfHo1QX7QBBD1iV+mn1eOyRP3b/PA=
244252
github.com/microsoft/go-mssqldb v1.7.2/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA=
245253
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
@@ -272,6 +280,14 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
272280
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
273281
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
274282
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
283+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 h1:zrbMGy9YXpIeTnGj4EljqMiZsIcE09mmF8XsD5AYOJc=
284+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6/go.mod h1:rEKTHC9roVVicUIfZK7DYrdIoM0EOr8mK1Hj5s3JjH0=
285+
github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM=
286+
github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
287+
github.com/olekukonko/ll v0.1.2 h1:lkg/k/9mlsy0SxO5aC+WEpbdT5K83ddnNhAepz7TQc0=
288+
github.com/olekukonko/ll v0.1.2/go.mod h1:b52bVQRRPObe+yyBl0TxNfhesL0nedD4Cht0/zx55Ew=
289+
github.com/olekukonko/tablewriter v1.1.1 h1:b3reP6GCfrHwmKkYwNRFh2rxidGHcT6cgxj/sHiDDx0=
290+
github.com/olekukonko/tablewriter v1.1.1/go.mod h1:De/bIcTF+gpBDB3Alv3fEsZA+9unTsSzAg/ZGADCtn4=
275291
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
276292
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
277293
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=

mysql/data_source_databases_testcontainers_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
//go:build testcontainers
12
// +build testcontainers
23

34
package mysql
45

56
import (
6-
"context"
77
"fmt"
88
"testing"
99

@@ -12,12 +12,10 @@ import (
1212

1313
// TestAccDataSourceDatabases_WithTestcontainers is a proof of concept test
1414
// using Testcontainers instead of Makefile + Docker
15+
// Uses shared container set up in TestMain
1516
func TestAccDataSourceDatabases_WithTestcontainers(t *testing.T) {
16-
ctx := context.Background()
17-
18-
// Start MySQL container using Testcontainers
19-
container := startMySQLContainer(ctx, t, "mysql:8.0")
20-
defer container.SetupTestEnv(t)()
17+
// Use shared container set up in TestMain
18+
_ = getSharedMySQLContainer(t, "mysql:8.0")
2119

2220
// Run the same test logic as the original test
2321
resource.Test(t, resource.TestCase{

0 commit comments

Comments
 (0)