Refactor REST API test script into a npm test framework
The script can now be used to run an arbitrary set of Node.js tests as long as they define the `test` npm target. Refactored REST API tests to fit into this framework.
This commit is contained in:
@ -1,3 +1,6 @@
|
|||||||
add_custom_target(test_rest_api
|
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})
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||||
|
@ -1,22 +1,31 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# This script builds and installs MaxScale, starts a MaxScale instance, runs the
|
# This script builds and installs MaxScale, starts a MariaDB cluster and runs any
|
||||||
# tests use npm and stops MaxScale.
|
# tests that define a `npm test` target
|
||||||
#
|
#
|
||||||
# This is definitely not the most efficient way to test the binaries but it's a
|
# 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.
|
# 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 <MaxScale sources> <test sources> <test directory>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
srcdir=$1
|
srcdir=$1
|
||||||
maxscaledir=$PWD/maxscale_test/
|
testsrc=$2
|
||||||
testdir=$PWD/local_test/
|
testdir=$3
|
||||||
|
|
||||||
|
maxscaledir=$PWD/maxscale_test/
|
||||||
|
|
||||||
|
# Create the test directory
|
||||||
mkdir -p $testdir && cd $testdir
|
mkdir -p $testdir && cd $testdir
|
||||||
|
|
||||||
# Currently all tests that use npm are for the REST API
|
# Copy the common test files (docker-compose.yml etc.)
|
||||||
cp -t $testdir -r $srcdir/server/core/test/rest-api/*
|
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
|
# Bring MariaDB servers up, this is an asynchronous process
|
||||||
docker-compose up -d || exit 1
|
docker-compose up -d || exit 1
|
Reference in New Issue
Block a user