Skip to content

Commit 7e78b12

Browse files
committed
Fix mssql containers setup
Failures could be seen both on the developer machine and on CI. Microsoft has changed the path to the sqlcmd utility in the latest releases of the image. Besides, they have made connecting on an encrypted connection with sqlcmd mandatory by default. Therefore, we must configure the utility to make this optional (-No). Also, when now certificate are always validated but test servers use self-signed certificates. For this reason, the utility must not try to validate the server certificate (-C). Lastly, unlike the mcr.microsoft.com/mssql/server image, the mcr.microsoft.com/mssql-tools image has not been updated. So the latest image release still uses the old sqlcmd utility path and options. To avoid discrepancies in our setup, we'll use the mcr.microsoft.com/mssql/server image everywhere from now on. We don't care too much about the size, because we need this image to run the server anyway. Signed-off-by: Thomas Segismont <[email protected]>
1 parent bbc049e commit 7e78b12

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

vertx-mssql-client/docker/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ services:
1010
TZ: UTC
1111
SA_PASSWORD: A_Str0ng_Required_Password
1212
test-mssql-initdb:
13-
image: mcr.microsoft.com/mssql-tools
13+
image: mcr.microsoft.com/mssql/server:${MSSQL_VERSION:-2019-latest}
1414
depends_on:
1515
- "test-mssql"
16-
command: [ "sh", "/opt/mssql-tools/bin/initdb.sh","test-mssql,1433","A_Str0ng_Required_Password","/opt/data/init.sql" ]
16+
command: [ "sh", "/opt/mssql-tools18/bin/initdb.sh","test-mssql,1433","A_Str0ng_Required_Password","/opt/data/init.sql" ]
1717
volumes:
1818
- type: bind
1919
source: ./initdb.sh
20-
target: /opt/mssql-tools/bin/initdb.sh
20+
target: /opt/mssql-tools18/bin/initdb.sh
2121
read_only: true
2222
- type: bind
2323
source: ../src/test/resources/init.sql

vertx-mssql-client/docker/initdb.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ SERVER="$1"
66
PASSWORD="$2"
77
SQL_FILE="$3"
88

9-
until /opt/mssql-tools/bin/sqlcmd -l 1 -S $SERVER -U SA -P $PASSWORD -q "SELECT 1"; do
9+
until /opt/mssql-tools18/bin/sqlcmd -l 1 -S $SERVER -U SA -P $PASSWORD -C -No -q "SELECT 1"; do
1010
>&2 echo "MSSQL is unavailable - sleeping"
1111
sleep 1
1212
done
1313

1414
>&2 echo "MSSQL is up - executing command"
15-
/opt/mssql-tools/bin/sqlcmd -S $SERVER -U SA -P $PASSWORD -i $SQL_FILE
15+
/opt/mssql-tools18/bin/sqlcmd -S $SERVER -U SA -P $PASSWORD -i $SQL_FILE -C -No

vertx-mssql-client/src/test/java/io/vertx/mssqlclient/junit/MSSQLRule.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ private MSSQLConnectOptions startMSSQL() throws IOException {
115115
private void initDb() throws IOException {
116116
try {
117117
ExecResult execResult = server.execInContainer(
118-
"/opt/mssql-tools/bin/sqlcmd",
118+
"/opt/mssql-tools18/bin/sqlcmd",
119119
"-S", "localhost",
120120
"-U", USER,
121121
"-P", PASSWORD,
122-
"-i", INIT_SQL
122+
"-i", INIT_SQL,
123+
"-C", "-No"
123124
);
124125
if (execResult.getExitCode() != 0) {
125126
throw new RuntimeException(String.format("Failure while initializing database%nstdout:%s%nstderr:%s%n", execResult.getStdout(), execResult.getStderr()));

0 commit comments

Comments
 (0)