#!/usr/bin/env bats load helpers.bash # MySQL client tests are set up to test Dolt as a MySQL server and # standard MySQL Clients in a wide array of languages. I used BATS because # it was easy to set up the Dolt piece using the command line. # # We create a Dolt database and start a server in the setup(). Then, each test # will attempt to access the server through a client. We'll do some basic # reads and writes to make sure the client works. As we discover any # gotchas, we can add tests for that specific language. setup() { setup_dolt_repo export MYSQL_TCP_PORT=$PORT export MYSQL_HOST=127.0.0.1 } teardown() { # Kill and wait the server before cd/rm so the process exits # before its data directory is removed. kill $SERVER_PID || : wait $SERVER_PID || : SERVER_PID= cd .. rm -rf $REPO_NAME # Check if postgresql is still running. If so stop it active=$(service postgresql status) if echo "$active" | grep "online"; then service postgresql stop fi } switch_mariadb_version() { local version="$1" run ln -vsfn "/usr/local/mariadb-$version" /usr/local/mariadb } mariadb() { /usr/local/mariadb/bin/mariadb --protocol=tcp -vvv --show-warnings "$@" } assert_mariadb_version_auth_and_db_selection() { local version="$1" switch_mariadb_version "$version" run mariadb --version [ "$status" -eq 0 ] [[ "$output" =~ "$version" ]] || false run mariadb -e "SELECT 1;" [ "$status" -ne 0 ] [[ "$output" =~ "Access denied for user 'root'" ]] || false run mariadb --user="$USER" "$REPO_NAME" -e "SELECT 1" [ "$status" -eq 0 ] [[ "$output" =~ "1" ]] || false run mariadb --user="$USER" "$REPO_NAME" -e "SELECT DATABASE();" [ "$status" -eq 0 ] [[ "$output" =~ "$REPO_NAME" ]] || false } @test "mariadb auth" { assert_mariadb_version_auth_and_db_selection "10.11" assert_mariadb_version_auth_and_db_selection "11.8" } @test "go go-sql-driver/mysql" { /build/bin/go/sql-driver-mysql-test $USER $PORT $REPO_NAME } @test "go go-mysql" { /build/bin/go/mysql-client-test $USER $PORT $REPO_NAME } @test "python mysql.connector" { /build/bin/python/mysql-connector-test $USER $PORT $REPO_NAME } @test "python mariadb connector" { /build/bin/python/mariadb-connector-test $USER $PORT $REPO_NAME } @test "python pymysql client" { /build/bin/python/pymysql-test $USER $PORT $REPO_NAME } @test "python sqlachemy client" { /build/bin/python/sqlalchemy-test $USER $PORT $REPO_NAME } @test "python replication client" { # Stop the server that setup launched kill $SERVER_PID || : wait $SERVER_PID || : # Configure binlog replication settings dolt sql -q "SET @@PERSIST.log_bin=1;" dolt sql -q "SET @@PERSIST.gtid_mode=ON;" dolt sql -q "SET @@PERSIST.enforce_gtid_consistency=ON;" dolt sql -q "SET @@PERSIST.binlog_format='ROW';" dolt sql -q "SET @@PERSIST.binlog_row_image='FULL';" dolt sql -q "SET @@PERSIST.binlog_row_metadata='FULL';" # Restart the SQL server dolt sql-server --host 0.0.0.0 --port=$PORT --loglevel=trace & SERVER_PID=$! sleep 1 # Give the server a chance to start /build/bin/python/python-replication-test $USER $PORT $REPO_NAME } @test "java mysql-connector-j" { java -jar /build/bin/java/mysql-connector-test.jar $USER $PORT $REPO_NAME } @test "java mysql-connector-j collation" { java -jar /build/bin/java/mysql-connector-test-collation.jar $USER $PORT $REPO_NAME } @test "java mariadb-java-client" { java -jar /build/bin/java/mariadb-connector-test.jar $USER $PORT $REPO_NAME } @test "java r2dbc-mariadb connector" { java -jar /build/bin/java/mariadb-R2DBC-test.jar $USER $PORT $REPO_NAME } @test "node mysql client" { node /build/bin/node/index.js $USER $PORT $REPO_NAME node /build/bin/node/knex.js $USER $PORT $REPO_NAME } @test "node mariadb connector" { node /build/bin/node/mariadb-connector.js $USER $PORT $REPO_NAME } @test "node mysql client, hosted workbench stability" { node /build/bin/node/workbench.js $USER $PORT $REPO_NAME /build/bin/node/testdata } @test "c mysql client" { /build/bin/c/mysql-client-test $USER $PORT $REPO_NAME } @test "c mariadb client" { /build/bin/c/mariadb-client-test $USER $PORT $REPO_NAME } @test "c mariadb odbc connector" { /build/bin/c/mariadb-odbc-test $USER $PORT $REPO_NAME } @test "cpp mysql connector" { /build/bin/cpp/mysql-connector-test $USER $PORT $REPO_NAME } @test "cpp mariadb connector" { /build/bin/cpp/mariadb-connector-test $USER $PORT $REPO_NAME } @test "dotnet mysql connector" { /build/bin/dotnet/mysql-connector-test $USER $PORT $REPO_NAME } @test "dotnet mysql client" { /build/bin/dotnet/mysql-client-test $USER $PORT $REPO_NAME } @test "perl DBD:mysql client" { perl /build/bin/perl/dbd-mysql-test.pl $USER $PORT $REPO_NAME } @test "perl DBD:MariaDB client" { perl /build/bin/perl/dbd-mariadb-test.pl $USER $PORT $REPO_NAME } @test "ruby ruby/mysql client" { ruby /build/bin/ruby/mysql-client-test.rb $USER $PORT $REPO_NAME } @test "ruby mysql2" { ruby /build/bin/ruby/mysql2-test.rb $USER $PORT $REPO_NAME } @test "elixir myxql" { /build/bin/elixir/myxql-driver-test $USER $PORT $REPO_NAME } @test "elixir mysql-otp" { /build/bin/elixir/mysql-otp-test $USER $PORT $REPO_NAME } @test "mysqldump" { mysqldump $REPO_NAME -P $PORT -h 0.0.0.0 -u $USER } @test "mysql_fdw read path" { service postgresql start run su -c "psql -U postgres <