From 7b9cb4e9538f13522131f4412077ff45a6834413 Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Tue, 24 Sep 2024 23:38:11 +0530 Subject: [PATCH 01/11] Use official SQL Server docker image for tests --- .github/workflows/tests.yml | 13 ++++++------- tests/compose.yml | 8 +++----- tests/tests_all.sh | 2 +- tests/tests_test.go | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0601f00639..b24443385c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -176,17 +176,16 @@ jobs: services: mssql: - image: mcmoe/mssqldocker:latest + image: mcr.microsoft.com/mssql/server:latest env: + TZ: Asia/Shanghai ACCEPT_EULA: Y - SA_PASSWORD: LoremIpsum86 - MSSQL_DB: gorm - MSSQL_USER: gorm - MSSQL_PASSWORD: LoremIpsum86 + MSSQL_SA_PASSWORD: LoremIpsum86 + MSSQL_DB: master ports: - 9930:1433 options: >- - --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1" + --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1" --health-start-period 10s --health-interval 10s --health-timeout 5s @@ -208,7 +207,7 @@ jobs: key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('tests/go.mod') }} - name: Tests - run: GITHUB_ACTION=true GORM_DIALECT=sqlserver GORM_DSN="sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm" ./tests/tests_all.sh + run: GITHUB_ACTION=true GORM_DIALECT=sqlserver GORM_DSN="sqlserver://sa:LoremIpsum86@localhost:9930?database=master" ./tests/tests_all.sh tidb: strategy: diff --git a/tests/compose.yml b/tests/compose.yml index 666b1fb0fe..4d3c9efea5 100644 --- a/tests/compose.yml +++ b/tests/compose.yml @@ -18,16 +18,14 @@ services: - POSTGRES_USER=gorm - POSTGRES_PASSWORD=gorm mssql: - image: '${MSSQL_IMAGE:-mcmoe/mssqldocker}:latest' + image: '${MSSQL_IMAGE}:latest' ports: - "127.0.0.1:9930:1433" environment: - TZ=Asia/Shanghai - ACCEPT_EULA=Y - - SA_PASSWORD=LoremIpsum86 - - MSSQL_DB=gorm - - MSSQL_USER=gorm - - MSSQL_PASSWORD=LoremIpsum86 + - MSSQL_SA_PASSWORD=LoremIpsum86 + - MSSQL_DB=master tidb: image: 'pingcap/tidb:v6.5.0' ports: diff --git a/tests/tests_all.sh b/tests/tests_all.sh index 0622f934e8..67c6938eaf 100755 --- a/tests/tests_all.sh +++ b/tests/tests_all.sh @@ -27,7 +27,7 @@ if [[ -z $GITHUB_ACTION ]]; then SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "IF SUSER_ID (N'gorm') IS NULL CREATE LOGIN gorm WITH PASSWORD = 'LoremIpsum86';" > /dev/null || true SQLCMDPASSWORD=LoremIpsum86 sqlcmd -U sa -S localhost:9930 -Q "IF USER_ID (N'gorm') IS NULL CREATE USER gorm FROM LOGIN gorm; ALTER SERVER ROLE sysadmin ADD MEMBER [gorm];" > /dev/null || true else - docker compose up -d + MSSQL_IMAGE=mcr.microsoft.com/mssql/server docker compose up -d fi cd .. fi diff --git a/tests/tests_test.go b/tests/tests_test.go index a127734edc..e84162cd3d 100644 --- a/tests/tests_test.go +++ b/tests/tests_test.go @@ -20,7 +20,7 @@ var DB *gorm.DB var ( mysqlDSN = "gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True&loc=Local" postgresDSN = "user=gorm password=gorm dbname=gorm host=localhost port=9920 sslmode=disable TimeZone=Asia/Shanghai" - sqlserverDSN = "sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm" + sqlserverDSN = "sqlserver://sa:LoremIpsum86@localhost:9930?database=master" tidbDSN = "root:@tcp(localhost:9940)/test?charset=utf8&parseTime=True&loc=Local" ) From 135b126df8eec69de53e364f2caddac38b6f3f25 Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Wed, 25 Sep 2024 00:06:55 +0530 Subject: [PATCH 02/11] Try with tag 2019-latest instead of latest --- .github/workflows/tests.yml | 2 +- tests/compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b24443385c..ca00526419 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -176,7 +176,7 @@ jobs: services: mssql: - image: mcr.microsoft.com/mssql/server:latest + image: mcr.microsoft.com/mssql/server:2019-latest env: TZ: Asia/Shanghai ACCEPT_EULA: Y diff --git a/tests/compose.yml b/tests/compose.yml index 4d3c9efea5..5422facc48 100644 --- a/tests/compose.yml +++ b/tests/compose.yml @@ -18,7 +18,7 @@ services: - POSTGRES_USER=gorm - POSTGRES_PASSWORD=gorm mssql: - image: '${MSSQL_IMAGE}:latest' + image: '${MSSQL_IMAGE}:2019-latest' ports: - "127.0.0.1:9930:1433" environment: From 86fb75dcd5c1ba2e447d23d151c332c1046b64fb Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Wed, 25 Sep 2024 00:11:17 +0530 Subject: [PATCH 03/11] Use platform ubuntu-20.04 for SQL Server --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ca00526419..173112ad08 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -171,7 +171,7 @@ jobs: strategy: matrix: go: ['1.22', '1.21', '1.20'] - platform: [ubuntu-latest] # can not run test in macOS and windows + platform: [ubuntu-20.04] # can not run test in macOS and windows runs-on: ${{ matrix.platform }} services: From 8ab8e5866c50ad9a5e573b5b86803240751fcd80 Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Wed, 25 Sep 2024 00:22:16 +0530 Subject: [PATCH 04/11] Switch to 2019-CU18-ubuntu-20.04 --- .github/workflows/tests.yml | 3 ++- tests/compose.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 173112ad08..800b9d6e32 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -176,10 +176,11 @@ jobs: services: mssql: - image: mcr.microsoft.com/mssql/server:2019-latest + image: mcr.microsoft.com/mssql/server:2019-CU18-ubuntu-20.04 env: TZ: Asia/Shanghai ACCEPT_EULA: Y + SA_PASSWORD: LoremIpsum86 MSSQL_SA_PASSWORD: LoremIpsum86 MSSQL_DB: master ports: diff --git a/tests/compose.yml b/tests/compose.yml index 5422facc48..d1c4761c60 100644 --- a/tests/compose.yml +++ b/tests/compose.yml @@ -18,12 +18,13 @@ services: - POSTGRES_USER=gorm - POSTGRES_PASSWORD=gorm mssql: - image: '${MSSQL_IMAGE}:2019-latest' + image: '${MSSQL_IMAGE}:2019-CU18-ubuntu-20.04' ports: - "127.0.0.1:9930:1433" environment: - TZ=Asia/Shanghai - ACCEPT_EULA=Y + - SA_PASSWORD=LoremIpsum86 - MSSQL_SA_PASSWORD=LoremIpsum86 - MSSQL_DB=master tidb: From af233e4d3bfc1707b136a172ead8e66e3abe0d0b Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:11:10 +0530 Subject: [PATCH 05/11] Check with 2022-latest image tag and ubuntu-latest platform --- .github/workflows/tests.yml | 4 ++-- tests/compose.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 800b9d6e32..8763d8817a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -171,12 +171,12 @@ jobs: strategy: matrix: go: ['1.22', '1.21', '1.20'] - platform: [ubuntu-20.04] # can not run test in macOS and windows + platform: [ubuntu-latest] # can not run test in macOS and windows runs-on: ${{ matrix.platform }} services: mssql: - image: mcr.microsoft.com/mssql/server:2019-CU18-ubuntu-20.04 + image: mcr.microsoft.com/mssql/server:2022-latest env: TZ: Asia/Shanghai ACCEPT_EULA: Y diff --git a/tests/compose.yml b/tests/compose.yml index d1c4761c60..e481f815df 100644 --- a/tests/compose.yml +++ b/tests/compose.yml @@ -18,7 +18,7 @@ services: - POSTGRES_USER=gorm - POSTGRES_PASSWORD=gorm mssql: - image: '${MSSQL_IMAGE}:2019-CU18-ubuntu-20.04' + image: '${MSSQL_IMAGE}:2022-latest' ports: - "127.0.0.1:9930:1433" environment: From 9727d78170ab6e1b8e3098942eff0a66e58239d6 Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:20:13 +0530 Subject: [PATCH 06/11] Update health-cmd --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8763d8817a..9b66b12bd6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -186,7 +186,7 @@ jobs: ports: - 9930:1433 options: >- - --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1" + --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -N -C -l 30 -Q \"SELECT 1\" || exit 1" --health-start-period 10s --health-interval 10s --health-timeout 5s From 7ab81a704068330d60d088a617967751b9e9c0d0 Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:32:46 +0530 Subject: [PATCH 07/11] Try sqlcmd without -N -C --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9b66b12bd6..8763d8817a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -186,7 +186,7 @@ jobs: ports: - 9930:1433 options: >- - --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -N -C -l 30 -Q \"SELECT 1\" || exit 1" + --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1" --health-start-period 10s --health-interval 10s --health-timeout 5s From 0130a1832aef9fa974445527b7c52f2661a440f2 Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:39:08 +0530 Subject: [PATCH 08/11] Re-include -N -C, try with ubuntu-20.04 --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8763d8817a..432f875639 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -171,7 +171,7 @@ jobs: strategy: matrix: go: ['1.22', '1.21', '1.20'] - platform: [ubuntu-latest] # can not run test in macOS and windows + platform: [ubuntu-20.04] # can not run test in macOS and windows runs-on: ${{ matrix.platform }} services: @@ -186,7 +186,7 @@ jobs: ports: - 9930:1433 options: >- - --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1" + --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -N -C -l 30 -Q \"SELECT 1\" || exit 1" --health-start-period 10s --health-interval 10s --health-timeout 5s From c7745675842ab3e5b1922b16e79c174450e2be14 Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:48:16 +0530 Subject: [PATCH 09/11] Try ubuntu-20.04 without -N -C (last trial) --- .github/workflows/tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 432f875639..246b856f6a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -180,13 +180,12 @@ jobs: env: TZ: Asia/Shanghai ACCEPT_EULA: Y - SA_PASSWORD: LoremIpsum86 MSSQL_SA_PASSWORD: LoremIpsum86 MSSQL_DB: master ports: - 9930:1433 options: >- - --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -N -C -l 30 -Q \"SELECT 1\" || exit 1" + --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1" --health-start-period 10s --health-interval 10s --health-timeout 5s From 4b28dbe1bae703b28502525066c125cc39a2adff Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:07:19 +0530 Subject: [PATCH 10/11] Finalize working config --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 246b856f6a..f6bc0da1b6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -171,7 +171,7 @@ jobs: strategy: matrix: go: ['1.22', '1.21', '1.20'] - platform: [ubuntu-20.04] # can not run test in macOS and windows + platform: [ubuntu-latest] # can not run test in macOS and windows runs-on: ${{ matrix.platform }} services: @@ -185,7 +185,7 @@ jobs: ports: - 9930:1433 options: >- - --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1" + --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P ${MSSQL_SA_PASSWORD} -N -C -l 30 -Q \"SELECT 1\" || exit 1" --health-start-period 10s --health-interval 10s --health-timeout 5s From 37df3199c231adc1bbf87d62f16d609a14283576 Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:18:27 +0530 Subject: [PATCH 11/11] Remove unused env variables --- .github/workflows/tests.yml | 1 - tests/compose.yml | 2 -- 2 files changed, 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f6bc0da1b6..24eab55abc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -181,7 +181,6 @@ jobs: TZ: Asia/Shanghai ACCEPT_EULA: Y MSSQL_SA_PASSWORD: LoremIpsum86 - MSSQL_DB: master ports: - 9930:1433 options: >- diff --git a/tests/compose.yml b/tests/compose.yml index e481f815df..66f2daee7f 100644 --- a/tests/compose.yml +++ b/tests/compose.yml @@ -24,9 +24,7 @@ services: environment: - TZ=Asia/Shanghai - ACCEPT_EULA=Y - - SA_PASSWORD=LoremIpsum86 - MSSQL_SA_PASSWORD=LoremIpsum86 - - MSSQL_DB=master tidb: image: 'pingcap/tidb:v6.5.0' ports: