diff --git a/Makefile b/Makefile deleted file mode 100644 index d5d06b8b..00000000 --- a/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -SHELL=/bin/bash - -all: - npm install - -clean: - rm -rf node_modules/* - -check: - npm test - -eslint: - @echo "***eslint***" - @./node_modules/.bin/eslint lib/**/*.js test/**/*.js app.js - -TEST_SUITE := $(shell find test/{unit,integration,acceptance} -name "*.js") -TEST_SUITE_UNIT := $(shell find test/unit -name "*.js") -TEST_SUITE_INTEGRATION := $(shell find test/integration -name "*.js") -TEST_SUITE_ACCEPTANCE := $(shell find test/acceptance -name "*.js") -TEST_SUITE_BATCH := $(shell find test/*/batch -name "*.js") - -test: - @echo "***tests***" - @$(SHELL) test/run_tests.sh ${RUNTESTFLAGS} $(TEST_SUITE) - -test-unit: - @echo "***unit tests***" - @$(SHELL) test/run_tests.sh ${RUNTESTFLAGS} $(TEST_SUITE_UNIT) - -test-integration: - @echo "***integration tests***" - @$(SHELL) test/run_tests.sh ${RUNTESTFLAGS} $(TEST_SUITE_INTEGRATION) - -test-acceptance: - @echo "***acceptance tests***" - @$(SHELL) test/run_tests.sh ${RUNTESTFLAGS} $(TEST_SUITE_ACCEPTANCE) - -test-batch: - @echo "***batch queries tests***" - @$(SHELL) test/run_tests.sh ${RUNTESTFLAGS} $(TEST_SUITE_BATCH) - -test-all: test eslint - -coverage: - @RUNTESTFLAGS=--with-coverage make test - -.PHONY: test coverage diff --git a/configure b/configure deleted file mode 100755 index 3ae5ca06..00000000 --- a/configure +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -usage() { - echo "Usage: $0 [OPTION]" - echo - echo "Configuration:" - echo " --help display this help and exit" - echo " --with-pgport=NUM access PostgreSQL server on TCP port NUM" -} - -PGPORT=5432 - -while test -n "$1"; do - case "$1" in - --help|-h) - usage - exit 0 - ;; - --with-pgport=*) - PGPORT=`echo "$1" | cut -d= -f2` - ;; - *) - echo "Unused option '$1'" >&2 - ;; - esac - shift -done - -echo "PGPORT: $PGPORT" - -# TODO: allow specifying configuration settings ! -for f in config/environments/*.example; do - o=`dirname "$f"`/`basename "$f" .example` - echo "Writing $o" - sed "s/\( *module.exports.db_port[ \t]*= *'\?\)[^';]*\('\?;\)/\1$PGPORT\2/" < "$f" > "$o" -done diff --git a/docker-bash.sh b/docker-bash.sh deleted file mode 100755 index 5666ea1d..00000000 --- a/docker-bash.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -echo "*********************" -echo "To install Node.js, run:" -echo "/src/nodejs-install.sh" -echo "Use NODEJS_VERSION env var to select the Node.js version" -echo " " -echo "To start postgres, run:" -echo "/etc/init.d/postgresql start" -echo "*********************" -echo " " - -docker run -it -v `pwd`:/srv carto/nodejs-xenial-pg101:latest bash diff --git a/docker-test.sh b/docker-test.sh deleted file mode 100755 index c1d7995c..00000000 --- a/docker-test.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -docker run -e "NODEJS_VERSION=${2}" -v `pwd`:/srv ${1} bash test/run_tests_docker.sh && \ - docker ps --filter status=dead --filter status=exited -aq | xargs docker rm -v diff --git a/test/prepare_db.sh b/test/prepare_db.sh deleted file mode 100755 index bcc26c03..00000000 --- a/test/prepare_db.sh +++ /dev/null @@ -1,223 +0,0 @@ -#!/bin/sh - -# this script prepare database and redis instance to run acceptance test -# -# NOTE: assumes existance of a "template_postgis" loaded with -# compatible version of postgis (legacy.sql included) - -PREPARE_REDIS=yes -PREPARE_PGSQL=yes - -while [ -n "$1" ]; do - if test "$1" = "--skip-pg"; then - PREPARE_PGSQL=no - shift; continue - elif test "$1" = "--skip-redis"; then - PREPARE_REDIS=no - shift; continue - fi -done - -die() { - msg=$1 - echo "${msg}" >&2 - exit 1 -} - -# This is where postgresql connection parameters are read from -TESTENV=../config/environments/test.js - -# Extract postgres configuration -PGHOST=`node -e "console.log(require('${TESTENV}').db_host || '')"` -echo "PGHOST: [$PGHOST]" -PGPORT=`node -e "console.log(require('${TESTENV}').db_port || '')"` -echo "PGPORT: [$PGPORT]" - -PUBLICUSER=`node -e "console.log(require('${TESTENV}').db_pubuser || 'xxx')"` -PUBLICPASS=`node -e "console.log(require('${TESTENV}').db_pubuser_pass || 'xxx')"` -echo "PUBLICUSER: [${PUBLICUSER}]" -echo "PUBLICPASS: [${PUBLICPASS}]" - - -TESTUSERID=1 - -TESTUSER=`node -e "console.log(require('${TESTENV}').db_user || '')"` -if test -z "$TESTUSER"; then - echo "Missing db_user from ${TESTENV}" >&2 - exit 1 -fi -TESTUSER=`echo ${TESTUSER} | sed "s/<%= user_id %>/${TESTUSERID}/"` -echo "TESTUSER: [${TESTUSER}]" - -TESTPASS=`node -e "console.log(require('${TESTENV}').db_user_pass || '')"` -TESTPASS=`echo ${TESTPASS} | sed "s/<%= user_id %>/${TESTUSERID}/"` -echo "TESTPASS: [${TESTPASS}]" - -TEST_DB=`node -e "console.log(require('${TESTENV}').db_base_name || '')"` -if test -z "$TEST_DB"; then - echo "Missing db_base_name from ${TESTENV}" >&2 - exit 1 -fi -TEST_DB=`echo ${TEST_DB} | sed "s/<%= user_id %>/${TESTUSERID}/"` - -export PGHOST PGPORT - -if test x"$PREPARE_PGSQL" = xyes; then - - echo "preparing postgres..." - echo "PostgreSQL server version: `psql -A -t -c 'select version()'`" - echo "PAUSE; RESUME;" | psql pgbouncer 2>/dev/null # make sure there are no connections pgbouncer -> test_db - dropdb --if-exists ${TEST_DB} || die "Could not drop test database ${TEST_DB}" - createdb -Ttemplate_postgis -EUTF8 ${TEST_DB} || die "Could not create test database ${TEST_DB}" - psql -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";' ${TEST_DB} - psql -c "CREATE EXTENSION IF NOT EXISTS cartodb CASCADE;" ${TEST_DB} - - LOCAL_SQL_SCRIPTS='test populated_places_simple_reduced py_sleep quota_mock' - for i in ${LOCAL_SQL_SCRIPTS} - do - cat support/sql/${i}.sql | - sed -e 's/cartodb\./public./g' -e "s/''cartodb''/''public''/g" | - sed "s/:PUBLICUSER/${PUBLICUSER}/" | - sed "s/:PUBLICPASS/${PUBLICPASS}/" | - sed "s/:TESTUSER/${TESTUSER}/" | - sed "s/:TESTPASS/${TESTPASS}/" | - psql -q -v ON_ERROR_STOP=1 ${TEST_DB} > /dev/null || exit 1 - done - -fi - -if test x"$PREPARE_REDIS" = xyes; then - - REDIS_HOST=`node -e "console.log(require('${TESTENV}').redis_host || '127.0.0.1')"` - REDIS_PORT=`node -e "console.log(require('${TESTENV}').redis_port || '6336')"` - - echo "preparing redis..." - - # delete previous publicuser - cat <&2 - cleanup - exit 1 -} - -trap 'cleanup_and_exit' 1 2 3 5 9 13 - -while [ -n "$1" ]; do - if test "$1" = "--nodrop"; then - OPT_DROP_REDIS=no - OPT_DROP_PGSQL=no - shift - continue - elif test "$1" = "--nodrop-pg"; then - OPT_DROP_PGSQL=no - shift - continue - elif test "$1" = "--nodrop-redis"; then - OPT_DROP_REDIS=no - shift - continue - elif test "$1" = "--nocreate"; then - OPT_CREATE_REDIS=no - OPT_CREATE_PGSQL=no - shift - continue - elif test "$1" = "--nocreate-pg"; then - OPT_CREATE_PGSQL=no - shift - continue - elif test "$1" = "--nocreate-redis"; then - OPT_CREATE_REDIS=no - shift - continue - elif test "$1" = "--with-coverage"; then - OPT_COVERAGE=yes - shift - continue - else - break - fi -done - -if [ -z "$1" ]; then - echo "Usage: $0 [] []" >&2 - echo "Options:" >&2 - echo " --nocreate do not create the test environment on start" >&2 - echo " --nocreate-pg do not create the pgsql test environment" >&2 - echo " --nocreate-redis do not create the redis test environment" >&2 - echo " --nodrop do not drop the test environment on exit" >&2 - echo " --nodrop-pg do not drop the pgsql test environment" >&2 - echo " --nodrop-redis do not drop the redis test environment" >&2 - echo " --with-coverage use istanbul to determine code coverage" >&2 - exit 1 -fi - -TESTS=$@ - -if test x"$OPT_CREATE_REDIS" = xyes; then - echo "Starting redis on port ${REDIS_PORT}" - REDIS_CELL_PATH="${BASEDIR}/support/libredis_cell.so" - if [[ "$OSTYPE" == "darwin"* ]]; then - REDIS_CELL_PATH="${BASEDIR}/support/libredis_cell.dylib" - fi - echo "port ${REDIS_PORT}" | redis-server - --loadmodule ${REDIS_CELL_PATH} > ${BASEDIR}/test.log & - PID_REDIS=$! - echo ${PID_REDIS} > ${BASEDIR}/redis.pid -fi - -PREPARE_DB_OPTS= -if test x"$OPT_CREATE_PGSQL" != xyes; then - PREPARE_DB_OPTS="$PREPARE_DB_OPTS --skip-pg" -fi -if test x"$OPT_CREATE_REDIS" != xyes; then - PREPARE_DB_OPTS="$PREPARE_DB_OPTS --skip-redis" -fi - -echo "Preparing the environment" -cd ${BASEDIR} -sh prepare_db.sh ${PREPARE_DB_OPTS} || die "database preparation failure" -cd - - -PATH=node_modules/.bin/:node_modules/mocha/bin:$PATH - -echo -echo "Environment:" -echo -echo " ogr2ogr version: "`ogr2ogr --version` -echo - -if test x"$OPT_COVERAGE" = xyes; then - echo "Running tests with coverage" - ./node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- -u tdd --trace -t 5000 --exit ${TESTS} -else - echo "Running tests" - mocha -u tdd -t 5000 --exit ${TESTS} -fi -ret=$? - -cleanup || exit 1 - -exit $ret diff --git a/test/run_tests_docker.sh b/test/run_tests_docker.sh deleted file mode 100644 index 217ce06b..00000000 --- a/test/run_tests_docker.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -/etc/init.d/postgresql start - -source /src/nodejs-install.sh - -# Configure -./configure - -# Install cartodb-postgresql extension -git clone https://github.com/CartoDB/cartodb-postgresql.git -cd cartodb-postgresql && make && make install && cd .. - -echo "Node.js version: " -node -v - -echo "npm version:" -npm -v - -# install dependencies -npm ci -npm ls - -npm test