-
Notifications
You must be signed in to change notification settings - Fork 40
Update CI to fix issues of SQL Server integration test #1567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d824f0d
ca51e98
bb91bd0
bbbf222
ab91abc
3254d95
e8371e1
d6670cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -595,7 +595,6 @@ jobs: | |
| MSSQL_PID: "Express" | ||
| SA_PASSWORD: "SqlServer17" | ||
| ACCEPT_EULA: "Y" | ||
| MSSQL_COLLATION: "Japanese_BIN2" | ||
| ports: | ||
| - 1433:1433 | ||
| options: --name sqlserver17 | ||
|
|
@@ -610,7 +609,8 @@ jobs: | |
| distribution: 'temurin' | ||
|
|
||
| - name: Create no superuser | ||
| run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver17 SqlServer17 | ||
| run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver17 SqlServer17 10 3 | ||
| timeout-minutes: 1 | ||
|
Comment on lines
+612
to
+613
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I set the retry count to 10 times and the retry interval to 3 sec. We can reconsider these values in the future if CI error occurs frequently. Also, I set the timeout of this step as |
||
|
|
||
| - name: Setup and execute Gradle 'integrationTestJdbc' task | ||
| uses: gradle/gradle-build-action@v3 | ||
|
|
@@ -635,7 +635,6 @@ jobs: | |
| MSSQL_PID: "Express" | ||
| SA_PASSWORD: "SqlServer19" | ||
| ACCEPT_EULA: "Y" | ||
| MSSQL_COLLATION: "Japanese_BIN2" | ||
| ports: | ||
| - 1433:1433 | ||
| options: --name sqlserver19 | ||
|
|
@@ -650,7 +649,8 @@ jobs: | |
| distribution: 'temurin' | ||
|
|
||
| - name: Create no superuser | ||
| run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver19 SqlServer19 | ||
| run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver19 SqlServer19 10 3 | ||
| timeout-minutes: 1 | ||
|
|
||
| - name: Setup and execute Gradle 'integrationTestJdbc' task | ||
| uses: gradle/gradle-build-action@v3 | ||
|
|
@@ -675,7 +675,6 @@ jobs: | |
| MSSQL_PID: "Express" | ||
| SA_PASSWORD: "SqlServer22" | ||
| ACCEPT_EULA: "Y" | ||
| MSSQL_COLLATION: "Japanese_BIN2" | ||
| ports: | ||
| - 1433:1433 | ||
| options: --name sqlserver22 | ||
|
|
@@ -690,7 +689,8 @@ jobs: | |
| distribution: 'temurin' | ||
|
|
||
| - name: Create no superuser | ||
| run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver22 SqlServer22 | ||
| run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver22 SqlServer22 10 3 | ||
| timeout-minutes: 1 | ||
|
|
||
| - name: Setup and execute Gradle 'integrationTestJdbc' task | ||
| uses: gradle/gradle-build-action@v3 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,79 @@ | ||
| #!/bin/bash | ||
| set -eu | ||
| set -u | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To continue the script (to run retry) even after |
||
|
|
||
| # Get container name and password from arguments | ||
| SQL_SERVER_CONTAINER_NAME=$1 | ||
| SQL_SERVER_PASSWORD=$2 | ||
| MAX_RETRY_COUNT=$3 | ||
| RETRY_INTERVAL=$4 | ||
| COUNT=0 | ||
|
|
||
| echo "INFO: Creating no superuser start." | ||
|
|
||
| # A SQL Server container takes a few seconds to start SQL Server process | ||
| # in the container. So, first, we wait ${RETRY_INTERVAL} seconds before | ||
| # we run the `sqlcmd` command in the container. | ||
| echo "INFO: Sleep ${RETRY_INTERVAL} seconds to wait for SQL Server start." | ||
|
|
||
| while [[ ${COUNT} -lt ${MAX_RETRY_COUNT} ]] | ||
| do | ||
| sleep ${RETRY_INTERVAL} | ||
|
|
||
| echo "INFO: Retry count: ${COUNT}" | ||
|
|
||
| docker exec -t ${SQL_SERVER_CONTAINER_NAME} /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SQL_SERVER_PASSWORD} -d master -Q "SELECT 1" | ||
| if [[ $? -eq 0 ]]; then | ||
| break | ||
| else | ||
| echo "INFO: sqlcmd command failed. Will retry after ${RETRY_INTERVAL} seconds." | ||
| fi | ||
|
|
||
| COUNT=$((COUNT + 1)) | ||
|
|
||
| if [[ ${COUNT} -eq ${MAX_RETRY_COUNT} ]]; then | ||
| echo "ERROR: sqlcmd command failed ${MAX_RETRY_COUNT} times. Please check your configuration." >&2 | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| echo "INFO: sqlcmd command succeeded. Continue creating no superuser." | ||
|
Comment on lines
+18
to
+39
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First, this script checks whether it can access SQL Server or not by using |
||
|
|
||
| # Create login | ||
| echo "INFO: Create login start" | ||
| docker exec -t ${SQL_SERVER_CONTAINER_NAME} /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SQL_SERVER_PASSWORD} -d master -Q "CREATE LOGIN no_superuser WITH PASSWORD = 'no_superuser_password', DEFAULT_DATABASE = master , CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF" | ||
| echo "INFO: Create login end" | ||
|
|
||
| # Create database | ||
| docker exec -t ${SQL_SERVER_CONTAINER_NAME} /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SQL_SERVER_PASSWORD} -d master -Q "CREATE DATABASE test_db" | ||
| echo "INFO: Create database start" | ||
| docker exec -t ${SQL_SERVER_CONTAINER_NAME} /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SQL_SERVER_PASSWORD} -d master -Q "CREATE DATABASE test_db COLLATE Japanese_BIN2" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This script set collation |
||
| echo "INFO: Create database end" | ||
|
|
||
| # Create no_superuser | ||
| echo "INFO: Create no_superuser start" | ||
| docker exec -t ${SQL_SERVER_CONTAINER_NAME} /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SQL_SERVER_PASSWORD} -d test_db -Q "CREATE USER no_superuser FOR LOGIN no_superuser" | ||
| echo "INFO: Create no_superuser end" | ||
|
|
||
| # Add roles | ||
| echo "INFO: Add role db_ddladmin start" | ||
| docker exec -t ${SQL_SERVER_CONTAINER_NAME} /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SQL_SERVER_PASSWORD} -d test_db -Q "EXEC sp_addrolemember @rolename = 'db_ddladmin', @membername = 'no_superuser'" | ||
| echo "INFO: Add role db_ddladmin end" | ||
|
|
||
| echo "INFO: Add role db_datawriter start" | ||
| docker exec -t ${SQL_SERVER_CONTAINER_NAME} /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SQL_SERVER_PASSWORD} -d test_db -Q "EXEC sp_addrolemember @rolename = 'db_datawriter', @membername = 'no_superuser'" | ||
| echo "INFO: Add role db_datawriter end" | ||
|
|
||
| echo "INFO: Add role db_datareader start" | ||
| docker exec -t ${SQL_SERVER_CONTAINER_NAME} /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SQL_SERVER_PASSWORD} -d test_db -Q "EXEC sp_addrolemember @rolename = 'db_datareader', @membername = 'no_superuser'" | ||
| echo "INFO: Add role db_datareader end" | ||
|
|
||
| # Check the collation of test_db (for debugging purposes) | ||
| echo "INFO: Check collation start" | ||
| docker exec -t ${SQL_SERVER_CONTAINER_NAME} /opt/mssql-tools/bin/sqlcmd -S localhost -U no_superuser -P no_superuser_password -d test_db -Q "SELECT name, collation_name FROM sys.databases" -W | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For debugging purposes, I added the SQL command to see the database collation settings. |
||
| echo "INFO: Check collation end" | ||
|
|
||
| # Check if no_superuser can access SQL Server (for debugging purposes) | ||
| echo "INFO: SELECT @@version start" | ||
| docker exec -t ${SQL_SERVER_CONTAINER_NAME} /opt/mssql-tools/bin/sqlcmd -S localhost -U no_superuser -P no_superuser_password -d test_db -Q "SELECT @@version" | ||
| echo "INFO: SELECT @@version end" | ||
|
|
||
| echo "INFO: Creating no superuser succeeded." | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set the collation by the
CREATE DATABASEin the script. So, we can remove this configuration from here.