-
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
Conversation
|
We discussed and decided to keep CI simple as long as possible. |
|
The integration test of SQL Server failed several times. We discussed and decided to update CI to resolve the issue and further debugging. So, I re-open this PR. |
| MSSQL_PID: "Express" | ||
| SA_PASSWORD: "SqlServer17" | ||
| ACCEPT_EULA: "Y" | ||
| MSSQL_COLLATION: "Japanese_BIN2" |
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 DATABASE in the script. So, we can remove this configuration from here.
| run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver17 SqlServer17 10 3 | ||
| timeout-minutes: 1 |
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 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 1 min. In the case of succeeded CI, this step takes about 10 seconds.
| @@ -1,23 +1,79 @@ | |||
| #!/bin/bash | |||
| set -eu | |||
| set -u | |||
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.
To continue the script (to run retry) even after SELECT 1 failed, I removed the set -e option.
| 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." |
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.
First, this script checks whether it can access SQL Server or not by using SELECT 1.
| # 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" |
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.
This script set collation Japanese_BIN2 explicitly in the CREATE DATABASE command.
|
|
||
| # Check the collation of test_db (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 name, collation_name FROM sys.databases" -W |
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.
For debugging purposes, I added the SQL command to see the database collation settings.
komamitsu
left a comment
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.
LGTM! Thank you!
brfrn169
left a comment
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.
LGTM! Thank you!
Description
This PR updates the script
create-no-superuser-sqlserver.shthat createsno superuserfor the SQL Server integration test.The CI failed for some reason as follows.
sqlcmdfailed with the errorLogin timeout expired..Create no superuserstep hung and failed by the GitHub Actions timeout (360min by default).garbled characters.However, these errors are fixed by retrying without any code changes... (i.e., it looks like a
flaky test...)To address (debug) these issues, we discussed and decided to update CI as follows.
sqlcmdfailed with the errorLogin timeout expired..sqlcmdcommand right after the SQL Server container starts. So, we guess that the SQL Server process does not start in the container.sleepand check if we can run theSELECT 1as a first step of the script.SELECT 1several times, and if theSELECT 1command succeeds, we continue to the next steps.Create no superuserstep hung and failed by the GitHub Actions timeout (360min by default).1 mininstead of the default value3600 minto theCreate no superuserstep.Create no superusertakes about 10 seconds. And, I set30 sec (3sec * 10 times)as a retry configuration in this update. So, I think the1 minis appropriate as a timeout.garbled characters.test_dbfor some reason.test_dbby the SQLCREATE DATABASE test_db COLLATE Japanese_BIN2.Please take a look!
Related issues and/or PRs
Changes made
SELECT 1) and retry feature increate-no-superuser-sqlserver.sh.echocommand to debug the issue.test_dbthat we use for integration test.Checklist
Additional notes (optional)
I checked this script works in my local environment as follows.
Also, I tried to run the CI (SQL Server integration test) 25 times. However, the issue is not reproduced. So, I guess we might be able to fix the issue with the updates of this PR.
https://github.com/scalar-labs/scalardb/actions/runs/8182728411
Note: The
attempt 3failed. But, as a discussion result, we found the root cause. It depends on the specification of SQL Server (how it treat byte data). This error is not related to this PR. This is a very rare case, so we will consider this issue in another chance.https://github.com/scalar-labs/scalardb/actions/runs/8182728411/attempts/3
Release notes
N/A