Skip to content

Commit

Permalink
Remove abao
Browse files Browse the repository at this point in the history
  • Loading branch information
ambrussimon committed Dec 14, 2017
1 parent 01dd637 commit 8d16ce6
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 1,948 deletions.
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ CMD ["unitd", "--control", "*:8080", "--no-daemon", "--log", "/dev/stdout"]
FROM dist as testing

RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community mongodb=3.4.4-r0
RUN apk add --no-cache nodejs-npm=6.10.3-r1 \
&& npm install tests/integration_tests/abao
ENV PATH=/src/core/node_modules/.bin:$PATH

RUN pip install -r tests/requirements.txt

Expand Down
9 changes: 0 additions & 9 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ All tests are executed by default. Subsets can be run using the filtering option
* To run linting, use `--lint` (`-l`)
* To run unit tests, use `--unit` (`-u`)
* To run integration tests, use `--integ` (`-i`)
* To run abao tests, use `--abao` (`-a`)
* To pass any arguments to `py.test`, use `-- PYTEST_ARGS`

See [py.test usage](https://docs.pytest.org/en/latest/usage.html) for more.
Expand All @@ -31,11 +30,3 @@ Without rebuilding the image, run only integration tests matching `foo`, use the
```
./tests/bin/run-tests-docker.sh -B -- -i -- -k foo -vvv --pdb
```

### Tools
- [abao](https://github.com/cybertk/abao/)

### Testing API against RAML with Abao
Abao is one of the testing tools run during our TravisCI build. It tests the API implementation against what’s defined in the RAML spec. Adding a new resource / url to the RAML spec will cause Abao to verify that resource during integration tests. Sometimes abao cannot properly test a resource (file field uploads) or a test may require chaining variable. Abao has before and after hooks for tests, written in javascript. These can be used to skip a test, inject variables into the request, or make extra assertions about the response. See tests/integration/abao in the repo for the hooks file. See [abao github readme](https://github.com/cybertk/abao/blob/master/README.md) for more information on how to use hooks.

Abao tests can depend on specific resources (eg. group, project, session, etc.) pre-existing in the DB. That resource loading should be maintained within `tests/integration_tests/abao/load_fixture.py` and is executed automatically via the integration test scripts at `test/bin`.
8 changes: 6 additions & 2 deletions tests/bin/run-tests-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ USAGE="
Usage:
$0 [OPTION...] [-- TEST_ARGS...]
Build scitran-core image and run tests in a Docker container.
Build scitran/core image and run tests in a Docker container.
Also displays coverage report and saves HTML in htmlcov dir.
Options:
-h, --help Print this help and exit
Expand All @@ -20,6 +21,7 @@ Options:
"


main() {
local DOCKER_IMAGE=
local TEST_ARGS=
Expand Down Expand Up @@ -82,10 +84,10 @@ main() {
--network core-test \
--volume $(pwd)/api:/src/core/api \
--volume $(pwd)/tests:/src/core/tests \
--env SCITRAN_SITE_API_URL=http://core-test-service/api \
--env SCITRAN_CORE_DRONE_SECRET=$SCITRAN_CORE_DRONE_SECRET \
--env SCITRAN_PERSISTENT_DB_URI=mongodb://core-test-service:27017/scitran \
--env SCITRAN_PERSISTENT_DB_LOG_URI=mongodb://core-test-service:27017/logs \
--env SCITRAN_SITE_API_URL=http://core-test-service/api \
scitran/core:testing \
tests/bin/run-tests-ubuntu.sh $TEST_ARGS
}
Expand All @@ -97,6 +99,8 @@ clean_up() {

log "INFO: Test return code = $TEST_RESULT_CODE"
if [ "${TEST_RESULT_CODE}" = "0" ]; then
log "INFO: Collecting coverage..."

# Copy unit test coverage
docker cp core-test-runner:/src/core/.coverage .coverage.unit-tests 2>/dev/null

Expand Down
34 changes: 10 additions & 24 deletions tests/bin/run-tests-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,32 @@ Usage:
Runs linting and all tests if no options are provided.
Runs subset of tests when using the filtering options.
Displays coverage report if all tests ran and passed.
Assumes running in scitran-core container or that core and all of its
dependencies are installed the same way as in the Dockerfile, and that
* TODO scitran-core instance is running at...
* TODO mongodb is runnin at...
Assumes running in a scitran/core:testing container or that core and all
of its dependencies are installed the same way as in the Dockerfile.
Options:
-h, --help Print this help and exit
-l, --lint Run linting
-u, --unit Run unit tests
-i, --integ Run integration tests
-a, --abao Run abao tests
-- PYTEST_ARGS Arguments passed to py.test
Envvars (required for integration tests):
SCITRAN_SITE_API_URL URI to a running core instance (including /api)
SCITRAN_CORE_DRONE_SECRET API shared secret
SCITRAN_PERSISTENT_DB_URI Mongo URI to the scitran DB
SCITRAN_PERSISTENT_DB_LOG_URI Mongo URI to the scitran log DB
"


main() {
export RUN_ALL=true
local RUN_LINT=false
local RUN_UNIT=false
local RUN_INTEG=false
local RUN_ABAO=false
local PYTEST_ARGS=

while [ $# -gt 0 ]; do
Expand All @@ -51,10 +53,6 @@ main() {
RUN_ALL=false
RUN_INTEG=true
;;
-a|--abao)
RUN_ALL=false
RUN_ABAO=true
;;
--)
shift
PYTEST_ARGS="$@"
Expand All @@ -78,8 +76,7 @@ main() {
RUN_LINT=true
RUN_UNIT=true
RUN_INTEG=true
RUN_ABAO=true
elif ${RUN_LINT} && ${RUN_UNIT} && ${RUN_INTEG} && ${RUN_ABAO}; then
elif ${RUN_LINT} && ${RUN_UNIT} && ${RUN_INTEG}; then
# All filtering options were used, the same as none
RUN_ALL=true
fi
Expand All @@ -104,17 +101,6 @@ main() {
log "Running integration tests ..."
PYTHONDONTWRITEBYTECODE=1 py.test tests/integration_tests/python $PYTEST_ARGS
fi

if ${RUN_ABAO}; then
log "Running abao tests ..."
# Create resources that Abao relies on
python tests/integration_tests/abao/load_fixture.py

local BASEDIR=$(pwd)
cd raml/schemas/definitions
abao ../../api.raml "--server=$SCITRAN_SITE_API_URL" "--hookfiles=../../../tests/integration_tests/abao/abao_test_hooks.js"
cd $BASEDIR
fi
}


Expand Down
Loading

0 comments on commit 8d16ce6

Please sign in to comment.