Skip to content

Commit 7b62c79

Browse files
committed
Test connecting to a Unix domain socket.
This avoids needing to run a full integration test suite when just testing the code that opens a connection is necessary.
1 parent 3298279 commit 7b62c79

14 files changed

+73
-57
lines changed

.ci/config/config.compression+ssl.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"Data": {
33
"ConnectionString": "server=127.0.0.1;user id=ssltest;password=test;port=3306;database=mysqltest;ssl mode=required;use compression=true;DefaultCommandTimeout=3600",
4+
"SocketPath": "./../../../../../.ci/run/mysql/mysqld.sock",
45
"PasswordlessUser": "no_password",
56
"SecondaryDatabase": "testdb2",
67
"UnsupportedFeatures": "RsaEncryption,CachingSha2Password,Tls12,UuidToBin",

.ci/config/config.compression.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"Data": {
33
"ConnectionString": "server=127.0.0.1;user id=mysqltest;password=test;port=3306;database=mysqltest;ssl mode=none;UseCompression=true;DefaultCommandTimeout=3600",
4+
"SocketPath": "./../../../../../.ci/run/mysql/mysqld.sock",
45
"PasswordlessUser": "no_password",
56
"SecondaryDatabase": "testdb2",
6-
"UnsupportedFeatures": "Ed25519,RsaEncryption,CachingSha2Password,Tls12,UuidToBin",
7+
"UnsupportedFeatures": "Ed25519,RsaEncryption,CachingSha2Password,Tls12,UnixDomainSocket,UuidToBin",
78
"MySqlBulkLoaderLocalCsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.CSV",
89
"MySqlBulkLoaderLocalTsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.TSV"
910
}

.ci/config/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"Data": {
33
"ConnectionString": "server=127.0.0.1;user id=mysqltest;password=test;port=3306;database=mysqltest;ssl mode=none;DefaultCommandTimeout=3600",
4+
"SocketPath": "./../../../../../.ci/run/mysql/mysqld.sock",
45
"PasswordlessUser": "no_password",
56
"SecondaryDatabase": "testdb2",
6-
"UnsupportedFeatures": "Ed25519,RsaEncryption,CachingSha2Password,Tls12,UuidToBin",
7+
"UnsupportedFeatures": "Ed25519,RsaEncryption,CachingSha2Password,Tls12,UnixDomainSocket,UuidToBin",
78
"MySqlBulkLoaderLocalCsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.CSV",
89
"MySqlBulkLoaderLocalTsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.TSV"
910
}

.ci/config/config.ssl.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"Data": {
33
"ConnectionString": "server=127.0.0.1;user id=ssltest;password=test;port=3306;database=mysqltest;ssl mode=required;certificate file=../../../../../.ci/server/certs/ssl-client.pfx;DefaultCommandTimeout=3600",
4+
"SocketPath": "./../../../../../.ci/run/mysql/mysqld.sock",
45
"PasswordlessUser": "no_password",
56
"SecondaryDatabase": "testdb2",
67
"UnsupportedFeatures": "RsaEncryption,CachingSha2Password,Tls12,UuidToBin",

.ci/docker-run.sh

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,29 @@ then
1313
fi
1414

1515
# check number of arguments
16-
if [ $# -ne 4 ]
16+
if [ $# -ne 3 ]
1717
then
1818
display_usage
1919
exit 1
2020
fi
2121

2222
IMAGE=$1
23-
NAME=$2
24-
PORT=$3
25-
OMIT_FEATURES=$4
23+
PORT=$2
24+
OMIT_FEATURES=$3
2625
MYSQL_EXTRA=
2726

2827
if [ "$IMAGE" == "mysql:8.0" ]; then
2928
MYSQL_EXTRA='--default-authentication-plugin=mysql_native_password'
3029
fi
3130

32-
sudo mkdir -p run/$NAME
33-
sudo chmod 777 run/$NAME
31+
sudo mkdir -p run/mysql
32+
sudo chmod 777 run/mysql
3433

3534
docker run -d \
36-
-v $(pwd)/run/$NAME:/var/run/mysqld:rw \
35+
-v $(pwd)/run/mysql:/var/run/mysqld:rw \
3736
-v $(pwd)/server:/etc/mysql/conf.d:ro \
3837
-p $PORT:3306 \
39-
--name $NAME \
38+
--name mysql \
4039
-e MYSQL_ROOT_PASSWORD='test' \
4140
$IMAGE \
4241
--log-bin-trust-function-creators=1 \
@@ -48,38 +47,38 @@ for i in `seq 1 120`; do
4847
# wait for mysql to come up
4948
sleep 1
5049
echo "Testing if container is responding"
51-
docker exec $NAME mysql -uroot -ptest -e "SELECT 1" >/dev/null 2>&1
50+
docker exec mysql mysql -uroot -ptest -e "SELECT 1" >/dev/null 2>&1
5251
if [ $? -ne 0 ]; then continue; fi
5352

5453
# try running the init script
5554
echo "Creating mysqltest user"
56-
docker exec $NAME bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init.sql'
55+
docker exec mysql bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init.sql'
5756
if [ $? -ne 0 ]; then continue; fi
5857
if [[ $OMIT_FEATURES != *"Sha256Password"* ]]; then
59-
docker exec $NAME bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init_sha256.sql'
58+
docker exec mysql bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init_sha256.sql'
6059
if [ $? -ne 0 ]; then continue; fi
6160
fi
6261

6362
if [[ $OMIT_FEATURES != *"CachingSha2Password"* ]]; then
64-
docker exec $NAME bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init_caching_sha2.sql'
63+
docker exec mysql bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init_caching_sha2.sql'
6564
if [ $? -ne 0 ]; then continue; fi
6665
fi
6766

6867
if [[ $OMIT_FEATURES != *"Ed25519"* ]]; then
69-
docker exec $NAME bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init_ed25519.sql'
68+
docker exec mysql bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init_ed25519.sql'
7069
if [ $? -ne 0 ]; then continue; fi
7170
fi
7271

7372
# exit if successful
74-
docker exec $NAME mysql -ussltest -ptest \
73+
docker exec mysql mysql -ussltest -ptest \
7574
--ssl-mode=REQUIRED \
7675
--ssl-ca=/etc/mysql/conf.d/certs/ssl-ca-cert.pem \
7776
--ssl-cert=/etc/mysql/conf.d/certs/ssl-client-cert.pem \
7877
--ssl-key=/etc/mysql/conf.d/certs/ssl-client-key.pem \
7978
-e "SELECT 1"
8079
if [ $? -ne 0 ]; then
8180
# mariadb uses --ssl=TRUE instead of --ssl-mode=REQUIRED
82-
docker exec $NAME mysql -ussltest -ptest \
81+
docker exec mysql mysql -ussltest -ptest \
8382
--ssl=TRUE \
8483
--ssl-ca=/etc/mysql/conf.d/certs/ssl-ca-cert.pem \
8584
--ssl-cert=/etc/mysql/conf.d/certs/ssl-client-cert.pem \

.ci/integration-tests-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ parameters:
44
DotNetCoreSdkVersion: ''
55

66
steps:
7-
- bash: ${{ format('.ci/docker-run.sh {0} mysql 3300 {1}', parameters.image, parameters.unsupportedFeatures) }}
7+
- bash: ${{ format('.ci/docker-run.sh {0} 3300 {1}', parameters.image, parameters.unsupportedFeatures) }}
88
displayName: 'Start Docker container'
99
- template: 'sidebyside-test-steps.yml'
1010
parameters:

.ci/sidebyside-test-steps.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ steps:
2727
DATA__CERTIFICATESPATH: '$(Build.Repository.LocalPath)/.ci/server/certs/'
2828
DATA__MYSQLBULKLOADERLOCALCSVFILE: '$(Build.Repository.LocalPath)/tests/TestData/LoadData_UTF8_BOM_Unix.CSV'
2929
DATA__MYSQLBULKLOADERLOCALTSVFILE: '$(Build.Repository.LocalPath)/tests/TestData/LoadData_UTF8_BOM_Unix.TSV'
30+
DATA__SOCKETPATH: '$(Build.Repository.LocalPath)/.ci/run/mysql/mysqld.sock'
3031
TF_BUILD: $(TF_BUILD)
3132
- task: PublishTestResults@2
3233
condition: always()

.ci/use-config.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
cd $(dirname $0)/config
33

44
display_usage() {
5-
echo -e "\nUsage:\n$0 [config.json script] [host] [port] [name] [features]\n"
5+
echo -e "\nUsage:\n$0 [config.json script] [host] [port] [features]\n"
66
}
77

88
# check whether user had supplied -h or --help . If yes display usage
@@ -40,10 +40,5 @@ fi
4040

4141
if [ $# -ge 4 ]
4242
then
43-
sed -i "s/run\/mysql/run\/$4/g" ../../tests/SideBySide/config.json
44-
fi
45-
46-
if [ $# -ge 5 ]
47-
then
48-
sed -i "s/\"UnsupportedFeatures\": \".*\"/\"UnsupportedFeatures\": \"$5\"/g" ../../tests/SideBySide/config.json
43+
sed -i "s/\"UnsupportedFeatures\": \".*\"/\"UnsupportedFeatures\": \"$4\"/g" ../../tests/SideBySide/config.json
4944
fi

.travis.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,22 @@ services: docker
44

55
env:
66
- IMAGE=mysql:5.6
7-
NAME=mysql
87
OMIT_FEATURES=Ed25519,Json,Sha256Password,RsaEncryption,LargePackets,CachingSha2Password,SessionTrack,Tls11,Tls12,UuidToBin
98
- IMAGE=mysql:5.7
10-
NAME=mysql
119
OMIT_FEATURES=Ed25519,RsaEncryption,CachingSha2Password,Tls12,UuidToBin
1210
- IMAGE=mysql:8.0
13-
NAME=mysql
1411
OMIT_FEATURES=Ed25519
1512
- IMAGE=percona:5.7.22
16-
NAME=percona
1713
OMIT_FEATURES=CachingSha2Password,Ed25519,UuidToBin
1814
- IMAGE=mariadb:10.2
19-
NAME=mariadb
2015
OMIT_FEATURES=Ed25519,Json,Sha256Password,CachingSha2Password,RoundDateTime,UuidToBin
2116
- IMAGE=mariadb:10.3
22-
NAME=mariadb
2317
OMIT_FEATURES=Ed25519,Json,Sha256Password,CachingSha2Password,RoundDateTime,UuidToBin
2418
- IMAGE=mariadb:10.4
25-
NAME=mariadb
2619
OMIT_FEATURES=Json,Sha256Password,CachingSha2Password,RoundDateTime,UuidToBin
2720

2821
before_install:
29-
- .ci/docker-run.sh $IMAGE $NAME 3307 $OMIT_FEATURES
22+
- .ci/docker-run.sh $IMAGE 3307 $OMIT_FEATURES
3023
- sudo apt-get install -y libunwind8
3124
- mkdir -p $HOME/dotnet
3225
- wget -q https://download.visualstudio.microsoft.com/download/pr/14b65ed5-f508-49c4-b429-1b22085895cf/a6820dabd3a0303135fe11217405bfd1/dotnet-ubuntu.16.04-x64.1.1.13.tar.gz
@@ -47,14 +40,13 @@ script:
4740
- pushd tests/Conformance.Tests && CONNECTION_STRING="Server=localhost;Port=3307;User Id=mysqltest;Password=test;SSL Mode=None" dotnet test -c Release && popd
4841
- pushd tests/SideBySide
4942
- dotnet build SideBySide.csproj -c Release -f netcoreapp2.0
50-
- echo 'Executing netcoreapp1.1.2 tests with No Compression, No SSL' && ../../.ci/use-config.sh config.json 172.17.0.1 3307 $NAME $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp1.1.2
51-
- echo 'Executing netcoreapp2.0 tests with No Compression, No SSL' && ../../.ci/use-config.sh config.json 172.17.0.1 3307 $NAME $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp2.0
52-
- echo 'Executing netcoreapp2.1 tests with No Compression, No SSL' && ../../.ci/use-config.sh config.json 172.17.0.1 3307 $NAME $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp2.1
53-
- echo 'Executing netcoreapp2.1 tests with Compression, No SSL' && ../../.ci/use-config.sh config.compression.json 172.17.0.1 3307 $NAME $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp2.1
54-
- echo 'Executing netcoreapp1.1.2 tests with No Compression, SSL' && ../../.ci/use-config.sh config.ssl.json 172.17.0.1 3307 $NAME $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp1.1.2
55-
- echo 'Executing netcoreapp2.1 tests with No Compression, SSL' && ../../.ci/use-config.sh config.ssl.json 172.17.0.1 3307 $NAME $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp2.1
56-
- echo 'Executing netcoreapp2.0 tests with Compression, SSL' && ../../.ci/use-config.sh config.compression+ssl.json 172.17.0.1 3307 $NAME $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp2.0
57-
- echo 'Executing netcoreapp2.0 tests with Unix Domain Socket, No Compression, No SSL' && ../../.ci/use-config.sh config.uds.json 172.17.0.1 3307 $NAME $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp2.0
43+
- echo 'Executing netcoreapp1.1.2 tests with No Compression, No SSL' && ../../.ci/use-config.sh config.json 172.17.0.1 3307 $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp1.1.2
44+
- echo 'Executing netcoreapp2.0 tests with No Compression, No SSL' && ../../.ci/use-config.sh config.json 172.17.0.1 3307 $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp2.0
45+
- echo 'Executing netcoreapp2.1 tests with No Compression, No SSL' && ../../.ci/use-config.sh config.json 172.17.0.1 3307 $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp2.1
46+
- echo 'Executing netcoreapp2.1 tests with Compression, No SSL' && ../../.ci/use-config.sh config.compression.json 172.17.0.1 3307 $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp2.1
47+
- echo 'Executing netcoreapp1.1.2 tests with No Compression, SSL' && ../../.ci/use-config.sh config.ssl.json 172.17.0.1 3307 $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp1.1.2
48+
- echo 'Executing netcoreapp2.1 tests with No Compression, SSL' && ../../.ci/use-config.sh config.ssl.json 172.17.0.1 3307 $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp2.1
49+
- echo 'Executing netcoreapp2.0 tests with Compression, SSL' && ../../.ci/use-config.sh config.compression+ssl.json 172.17.0.1 3307 $OMIT_FEATURES && time dotnet test -c Release -f netcoreapp2.0
5850
- popd
5951

6052
notifications:

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
command: 'test'
9696
arguments: 'tests\SideBySide\SideBySide.csproj -c Baseline --logger'
9797
env:
98-
DATA__UNSUPPORTEDFEATURES: 'Ed25519'
98+
DATA__UNSUPPORTEDFEATURES: 'Ed25519,UnixDomainSocket'
9999
DATA__CONNECTIONSTRING: 'server=localhost;port=3306;user id=root;password=test;database=mysqltest;ssl mode=none;DefaultCommandTimeout=3600'
100100
DATA__CERTIFICATESPATH: '$(Build.Repository.LocalPath)\.ci\server\certs\'
101101
DATA__MYSQLBULKLOADERLOCALCSVFILE: '$(Build.Repository.LocalPath)\tests\TestData\LoadData_UTF8_BOM_Unix.CSV'

0 commit comments

Comments
 (0)