diff --git a/server/core/test/rest-api/CMakeLists.txt b/server/core/test/rest-api/CMakeLists.txt index d7e871584..2b4b34b31 100644 --- a/server/core/test/rest-api/CMakeLists.txt +++ b/server/core/test/rest-api/CMakeLists.txt @@ -1,3 +1,6 @@ add_custom_target(test_rest_api - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_rest_api.sh ${CMAKE_SOURCE_DIR} + COMMAND ${CMAKE_SOURCE_DIR}/test/run_npm_test.sh + ${CMAKE_SOURCE_DIR} # Path to MaxScale sources + ${CMAKE_CURRENT_SOURCE_DIR} # Path to test sources + ${CMAKE_BINARY_DIR}/rest-api/ # Location where tests are built and run WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/server/core/test/rest-api/docker-compose.yml b/test/docker-compose.yml similarity index 100% rename from server/core/test/rest-api/docker-compose.yml rename to test/docker-compose.yml diff --git a/server/core/test/rest-api/test_rest_api.sh b/test/run_npm_test.sh similarity index 81% rename from server/core/test/rest-api/test_rest_api.sh rename to test/run_npm_test.sh index 86ddc4978..8ea72ea37 100755 --- a/server/core/test/rest-api/test_rest_api.sh +++ b/test/run_npm_test.sh @@ -1,22 +1,31 @@ #!/bin/bash -# This script builds and installs MaxScale, starts a MaxScale instance, runs the -# tests use npm and stops MaxScale. +# This script builds and installs MaxScale, starts a MariaDB cluster and runs any +# tests that define a `npm test` target # # This is definitely not the most efficient way to test the binaries but it's a # guaranteed method of creating a consistent and "safe" testing environment. -# -# TODO: Install and start a local MariaDB server for testing purposes +if [ $# -lt 3 ] +then + echo "USAGE: $0 " + exit 1 +fi srcdir=$1 -maxscaledir=$PWD/maxscale_test/ -testdir=$PWD/local_test/ +testsrc=$2 +testdir=$3 +maxscaledir=$PWD/maxscale_test/ + +# Create the test directory mkdir -p $testdir && cd $testdir -# Currently all tests that use npm are for the REST API -cp -t $testdir -r $srcdir/server/core/test/rest-api/* +# Copy the common test files (docker-compose.yml etc.) +cp -t $testdir -r $srcdir/test/* + +# Copy test sources to test workspace +cp -t $testdir -r $testsrc/* # Bring MariaDB servers up, this is an asynchronous process docker-compose up -d || exit 1 diff --git a/server/core/test/rest-api/sql/master/users.sql b/test/sql/master/users.sql similarity index 100% rename from server/core/test/rest-api/sql/master/users.sql rename to test/sql/master/users.sql diff --git a/server/core/test/rest-api/sql/slave/replication.sql b/test/sql/slave/replication.sql similarity index 100% rename from server/core/test/rest-api/sql/slave/replication.sql rename to test/sql/slave/replication.sql