diff --git a/.ci/config/config.compression+ssl.json b/.ci/config/config.compression+ssl.json index 1d8904700..9f96bc581 100644 --- a/.ci/config/config.compression+ssl.json +++ b/.ci/config/config.compression+ssl.json @@ -1,6 +1,7 @@ { "Data": { "ConnectionString": "server=127.0.0.1;user id=ssltest;password=test;port=3306;database=mysqltest;ssl mode=required;use compression=true;DefaultCommandTimeout=3600", + "SocketPath": "./../../../../../.ci/run/mysql/mysqld.sock", "PasswordlessUser": "no_password", "SecondaryDatabase": "testdb2", "UnsupportedFeatures": "RsaEncryption,CachingSha2Password,Tls12,UuidToBin", diff --git a/.ci/config/config.compression.json b/.ci/config/config.compression.json index c986da8e4..a2503f171 100644 --- a/.ci/config/config.compression.json +++ b/.ci/config/config.compression.json @@ -1,9 +1,10 @@ { "Data": { "ConnectionString": "server=127.0.0.1;user id=mysqltest;password=test;port=3306;database=mysqltest;ssl mode=none;UseCompression=true;DefaultCommandTimeout=3600", + "SocketPath": "./../../../../../.ci/run/mysql/mysqld.sock", "PasswordlessUser": "no_password", "SecondaryDatabase": "testdb2", - "UnsupportedFeatures": "Ed25519,RsaEncryption,CachingSha2Password,Tls12,UuidToBin", + "UnsupportedFeatures": "Ed25519,RsaEncryption,CachingSha2Password,Tls12,UnixDomainSocket,UuidToBin", "MySqlBulkLoaderLocalCsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.CSV", "MySqlBulkLoaderLocalTsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.TSV" } diff --git a/.ci/config/config.json b/.ci/config/config.json index ba9bc2e27..9081da871 100644 --- a/.ci/config/config.json +++ b/.ci/config/config.json @@ -1,9 +1,10 @@ { "Data": { "ConnectionString": "server=127.0.0.1;user id=mysqltest;password=test;port=3306;database=mysqltest;ssl mode=none;DefaultCommandTimeout=3600", + "SocketPath": "./../../../../../.ci/run/mysql/mysqld.sock", "PasswordlessUser": "no_password", "SecondaryDatabase": "testdb2", - "UnsupportedFeatures": "Ed25519,RsaEncryption,CachingSha2Password,Tls12,UuidToBin", + "UnsupportedFeatures": "Ed25519,RsaEncryption,CachingSha2Password,Tls12,UnixDomainSocket,UuidToBin", "MySqlBulkLoaderLocalCsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.CSV", "MySqlBulkLoaderLocalTsvFile": "../../../../TestData/LoadData_UTF8_BOM_Unix.TSV" } diff --git a/.ci/config/config.ssl.json b/.ci/config/config.ssl.json index 3c8ef7388..6cdc27574 100644 --- a/.ci/config/config.ssl.json +++ b/.ci/config/config.ssl.json @@ -1,6 +1,7 @@ { "Data": { "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", + "SocketPath": "./../../../../../.ci/run/mysql/mysqld.sock", "PasswordlessUser": "no_password", "SecondaryDatabase": "testdb2", "UnsupportedFeatures": "RsaEncryption,CachingSha2Password,Tls12,UuidToBin", diff --git a/.ci/docker-run.sh b/.ci/docker-run.sh index 200daf330..7d77d8681 100755 --- a/.ci/docker-run.sh +++ b/.ci/docker-run.sh @@ -13,30 +13,29 @@ then fi # check number of arguments -if [ $# -ne 4 ] +if [ $# -ne 3 ] then display_usage exit 1 fi IMAGE=$1 -NAME=$2 -PORT=$3 -OMIT_FEATURES=$4 +PORT=$2 +OMIT_FEATURES=$3 MYSQL_EXTRA= if [ "$IMAGE" == "mysql:8.0" ]; then MYSQL_EXTRA='--default-authentication-plugin=mysql_native_password' fi -sudo mkdir -p run/$NAME -sudo chmod 777 run/$NAME +sudo mkdir -p run/mysql +sudo chmod 777 run/mysql docker run -d \ - -v $(pwd)/run/$NAME:/var/run/mysqld:rw \ + -v $(pwd)/run/mysql:/var/run/mysqld:rw \ -v $(pwd)/server:/etc/mysql/conf.d:ro \ -p $PORT:3306 \ - --name $NAME \ + --name mysql \ -e MYSQL_ROOT_PASSWORD='test' \ $IMAGE \ --log-bin-trust-function-creators=1 \ @@ -48,30 +47,30 @@ for i in `seq 1 120`; do # wait for mysql to come up sleep 1 echo "Testing if container is responding" - docker exec $NAME mysql -uroot -ptest -e "SELECT 1" >/dev/null 2>&1 + docker exec mysql mysql -uroot -ptest -e "SELECT 1" >/dev/null 2>&1 if [ $? -ne 0 ]; then continue; fi # try running the init script echo "Creating mysqltest user" - docker exec $NAME bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init.sql' + docker exec mysql bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init.sql' if [ $? -ne 0 ]; then continue; fi if [[ $OMIT_FEATURES != *"Sha256Password"* ]]; then - docker exec $NAME bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init_sha256.sql' + docker exec mysql bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init_sha256.sql' if [ $? -ne 0 ]; then continue; fi fi if [[ $OMIT_FEATURES != *"CachingSha2Password"* ]]; then - docker exec $NAME bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init_caching_sha2.sql' + docker exec mysql bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init_caching_sha2.sql' if [ $? -ne 0 ]; then continue; fi fi if [[ $OMIT_FEATURES != *"Ed25519"* ]]; then - docker exec $NAME bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init_ed25519.sql' + docker exec mysql bash -c 'mysql -uroot -ptest < /etc/mysql/conf.d/init_ed25519.sql' if [ $? -ne 0 ]; then continue; fi fi # exit if successful - docker exec $NAME mysql -ussltest -ptest \ + docker exec mysql mysql -ussltest -ptest \ --ssl-mode=REQUIRED \ --ssl-ca=/etc/mysql/conf.d/certs/ssl-ca-cert.pem \ --ssl-cert=/etc/mysql/conf.d/certs/ssl-client-cert.pem \ @@ -79,7 +78,7 @@ for i in `seq 1 120`; do -e "SELECT 1" if [ $? -ne 0 ]; then # mariadb uses --ssl=TRUE instead of --ssl-mode=REQUIRED - docker exec $NAME mysql -ussltest -ptest \ + docker exec mysql mysql -ussltest -ptest \ --ssl=TRUE \ --ssl-ca=/etc/mysql/conf.d/certs/ssl-ca-cert.pem \ --ssl-cert=/etc/mysql/conf.d/certs/ssl-client-cert.pem \ diff --git a/.ci/integration-tests-steps.yml b/.ci/integration-tests-steps.yml index ccc155127..c780bb2e7 100644 --- a/.ci/integration-tests-steps.yml +++ b/.ci/integration-tests-steps.yml @@ -4,7 +4,7 @@ parameters: DotNetCoreSdkVersion: '' steps: -- bash: ${{ format('.ci/docker-run.sh {0} mysql 3300 {1}', parameters.image, parameters.unsupportedFeatures) }} +- bash: ${{ format('.ci/docker-run.sh {0} 3300 {1}', parameters.image, parameters.unsupportedFeatures) }} displayName: 'Start Docker container' - template: 'sidebyside-test-steps.yml' parameters: diff --git a/.ci/sidebyside-test-steps.yml b/.ci/sidebyside-test-steps.yml index 44e665a9b..499ecb398 100644 --- a/.ci/sidebyside-test-steps.yml +++ b/.ci/sidebyside-test-steps.yml @@ -27,6 +27,7 @@ steps: DATA__CERTIFICATESPATH: '$(Build.Repository.LocalPath)/.ci/server/certs/' DATA__MYSQLBULKLOADERLOCALCSVFILE: '$(Build.Repository.LocalPath)/tests/TestData/LoadData_UTF8_BOM_Unix.CSV' DATA__MYSQLBULKLOADERLOCALTSVFILE: '$(Build.Repository.LocalPath)/tests/TestData/LoadData_UTF8_BOM_Unix.TSV' + DATA__SOCKETPATH: '$(Build.Repository.LocalPath)/.ci/run/mysql/mysqld.sock' TF_BUILD: $(TF_BUILD) - task: PublishTestResults@2 condition: always() diff --git a/.ci/use-config.sh b/.ci/use-config.sh index 51bf22b53..9b42c15ba 100755 --- a/.ci/use-config.sh +++ b/.ci/use-config.sh @@ -2,7 +2,7 @@ cd $(dirname $0)/config display_usage() { - echo -e "\nUsage:\n$0 [config.json script] [host] [port] [name] [features]\n" + echo -e "\nUsage:\n$0 [config.json script] [host] [port] [features]\n" } # check whether user had supplied -h or --help . If yes display usage @@ -40,10 +40,5 @@ fi if [ $# -ge 4 ] then - sed -i "s/run\/mysql/run\/$4/g" ../../tests/SideBySide/config.json -fi - -if [ $# -ge 5 ] -then - sed -i "s/\"UnsupportedFeatures\": \".*\"/\"UnsupportedFeatures\": \"$5\"/g" ../../tests/SideBySide/config.json + sed -i "s/\"UnsupportedFeatures\": \".*\"/\"UnsupportedFeatures\": \"$4\"/g" ../../tests/SideBySide/config.json fi diff --git a/.travis.yml b/.travis.yml index 5701a3b5a..af0222843 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,29 +4,22 @@ services: docker env: - IMAGE=mysql:5.6 - NAME=mysql OMIT_FEATURES=Ed25519,Json,Sha256Password,RsaEncryption,LargePackets,CachingSha2Password,SessionTrack,Tls11,Tls12,UuidToBin - IMAGE=mysql:5.7 - NAME=mysql OMIT_FEATURES=Ed25519,RsaEncryption,CachingSha2Password,Tls12,UuidToBin - IMAGE=mysql:8.0 - NAME=mysql OMIT_FEATURES=Ed25519 - IMAGE=percona:5.7.22 - NAME=percona OMIT_FEATURES=CachingSha2Password,Ed25519,UuidToBin - IMAGE=mariadb:10.2 - NAME=mariadb OMIT_FEATURES=Ed25519,Json,Sha256Password,CachingSha2Password,RoundDateTime,UuidToBin - IMAGE=mariadb:10.3 - NAME=mariadb OMIT_FEATURES=Ed25519,Json,Sha256Password,CachingSha2Password,RoundDateTime,UuidToBin - IMAGE=mariadb:10.4 - NAME=mariadb OMIT_FEATURES=Json,Sha256Password,CachingSha2Password,RoundDateTime,UuidToBin before_install: -- .ci/docker-run.sh $IMAGE $NAME 3307 $OMIT_FEATURES +- .ci/docker-run.sh $IMAGE 3307 $OMIT_FEATURES - sudo apt-get install -y libunwind8 - mkdir -p $HOME/dotnet - 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: - pushd tests/Conformance.Tests && CONNECTION_STRING="Server=localhost;Port=3307;User Id=mysqltest;Password=test;SSL Mode=None" dotnet test -c Release && popd - pushd tests/SideBySide - dotnet build SideBySide.csproj -c Release -f netcoreapp2.0 -- 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 -- 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 -- 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 -- 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 -- 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 -- 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 -- 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 -- 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 +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 +- 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 - popd notifications: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 29b5cd3e0..b6d5ca1a8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -95,7 +95,7 @@ jobs: command: 'test' arguments: 'tests\SideBySide\SideBySide.csproj -c Baseline --logger' env: - DATA__UNSUPPORTEDFEATURES: 'Ed25519' + DATA__UNSUPPORTEDFEATURES: 'Ed25519,UnixDomainSocket' DATA__CONNECTIONSTRING: 'server=localhost;port=3306;user id=root;password=test;database=mysqltest;ssl mode=none;DefaultCommandTimeout=3600' DATA__CERTIFICATESPATH: '$(Build.Repository.LocalPath)\.ci\server\certs\' DATA__MYSQLBULKLOADERLOCALCSVFILE: '$(Build.Repository.LocalPath)\tests\TestData\LoadData_UTF8_BOM_Unix.CSV' diff --git a/tests/SideBySide/AppConfig.cs b/tests/SideBySide/AppConfig.cs index c34e939a0..4d44ff8c5 100644 --- a/tests/SideBySide/AppConfig.cs +++ b/tests/SideBySide/AppConfig.cs @@ -46,6 +46,8 @@ private static IConfiguration BuildConfiguration() public static string SecondaryDatabase => Config.GetValue("Data:SecondaryDatabase"); + public static string SocketPath => Config.GetValue("Data:SocketPath"); + private static ServerFeatures UnsupportedFeatures => (ServerFeatures) Enum.Parse(typeof(ServerFeatures), Config.GetValue("Data:UnsupportedFeatures")); public static ServerFeatures SupportedFeatures => ~ServerFeatures.None & ~UnsupportedFeatures & ~(IsCiBuild ? ServerFeatures.Timeout : ServerFeatures.None); diff --git a/tests/SideBySide/ConnectAsync.cs b/tests/SideBySide/ConnectAsync.cs index 70ba7d241..f11905e92 100644 --- a/tests/SideBySide/ConnectAsync.cs +++ b/tests/SideBySide/ConnectAsync.cs @@ -406,6 +406,17 @@ public async Task PingConnection() } #endif + [SkippableFact(ServerFeatures.UnixDomainSocket)] + public async Task UnixDomainSocket() + { + var csb = AppConfig.CreateConnectionStringBuilder(); + csb.Server = AppConfig.SocketPath; + csb.ConnectionProtocol = MySqlConnectionProtocol.Unix; + using var connection = new MySqlConnection(csb.ConnectionString); + await connection.OpenAsync(); + Assert.Equal(ConnectionState.Open, connection.State); + } + readonly DatabaseFixture m_database; } diff --git a/tests/SideBySide/ConnectSync.cs b/tests/SideBySide/ConnectSync.cs index 315b76501..9c6e56ead 100644 --- a/tests/SideBySide/ConnectSync.cs +++ b/tests/SideBySide/ConnectSync.cs @@ -430,6 +430,17 @@ public void PingConnection() Assert.True(connection.Ping()); } + [SkippableFact(ServerFeatures.UnixDomainSocket)] + public void UnixDomainSocket() + { + var csb = AppConfig.CreateConnectionStringBuilder(); + csb.Server = AppConfig.SocketPath; + csb.ConnectionProtocol = MySqlConnectionProtocol.Unix; + using var connection = new MySqlConnection(csb.ConnectionString); + connection.Open(); + Assert.Equal(ConnectionState.Open, connection.State); + } + readonly DatabaseFixture m_database; } } diff --git a/tests/SideBySide/ServerFeatures.cs b/tests/SideBySide/ServerFeatures.cs index 53c44972e..80ea334a0 100644 --- a/tests/SideBySide/ServerFeatures.cs +++ b/tests/SideBySide/ServerFeatures.cs @@ -6,20 +6,21 @@ namespace SideBySide public enum ServerFeatures { None = 0, - Json = 1, - StoredProcedures = 2, - Sha256Password = 4, - RsaEncryption = 8, - LargePackets = 16, - CachingSha2Password = 32, - SessionTrack = 64, - Timeout = 128, - ErrorCodes = 256, - KnownCertificateAuthority = 512, - Tls11 = 1024, - Tls12 = 2048, - RoundDateTime = 4096, - UuidToBin = 8192, - Ed25519 = 16384, + Json = 0x1, + StoredProcedures = 0x2, + Sha256Password = 0x4, + RsaEncryption = 0x8, + LargePackets = 0x10, + CachingSha2Password = 0x20, + SessionTrack = 0x40, + Timeout = 0x80, + ErrorCodes = 0x100, + KnownCertificateAuthority = 0x200, + Tls11 = 0x400, + Tls12 = 0x800, + RoundDateTime = 0x1000, + UuidToBin = 0x2000, + Ed25519 = 0x4000, + UnixDomainSocket = 0x8000, } }