linz / gazetteer

New Zealand Gazetteer of official place names
http://www.linz.govt.nz/regulatory/place-names/find-name/new-zealand-gazetteer-official-geographic-names/new-zealand-gazetteer-search-place-names#zoom=0&lat=-41.14127&lon=172.5&layers=BTTT
Other
2 stars 2 forks source link

CI - Python tests are hanging #123

Closed SPlanzer closed 4 years ago

SPlanzer commented 4 years ago

Bug Description

Python tests appear to be hanging when running CI.

For example recent README.md changes are not passing CI as they remain in an unfinished state at the py unit test stage. - https://github.com/linz/gazetteer/pull/122/checks?check_run_id=686880173

This is unexpected as it is assumed these changes are from a branch that were passing CI and README.md changes should not afect running of CI python test.

Steps to Reproduce

Run CI

Desktop

CI as per - https://github.com/linz/gazetteer/pull/122/checks?check_run_id=686880173

Screenshots

billgeo commented 4 years ago

Note: I created this branch and commit through the Github UI rather than pushing from my local machine. Not sure if that operates differently somehow? You'd kind of hope not though.

SPlanzer commented 4 years ago

qgis_testrunners.sh as used by github actions

#!/bin/bash
# Run a python test inside QGIS
# Note: the test module and function are specified in dotted notation
# for example, to run the test function run_all (which is the default anyway)
# $ qgis_testrunner.sh tests_folder.test_module.run_all
# tests_folder must be in PYTHONPATH (plugins main folders are automatically added to path)

### Turn on debug mode ###
#set -x

TEST_NAME=$1

TEST_RUNNER_PATH=${TEST_RUNNER_PATH:-/usr/bin/qgis_testrunner.py}
QGIS_BUILD_PATH=${QGIS_BUILD_PATH:-qgis}

echo "Running test $1 ..."
OUTPUT=$(QGIS_TEST_MODULE=${TEST_NAME} unbuffer ${QGIS_BUILD_PATH} --version-migration --nologo --code ${TEST_RUNNER_PATH} "$TEST_NAME"  2>/dev/null | tee /tmp/tty); echo "$OUTPUT";

EXIT_CODE="$?"
if [ -z "$OUTPUT" ]; then
    echo "ERROR: no output from the test runner! (exit code: ${EXIT_CODE})"
    exit 1
fi
echo "$OUTPUT" | grep -q 'FAILED'
IS_FAILED="$?"
echo "$OUTPUT" | grep -q 'OK' && echo "$OUTPUT" | grep -q 'Ran'
IS_PASSED="$?"
echo "$OUTPUT" | grep "QGIS died on signal"
IS_DEAD="$?"
echo "Finished running test $1 (codes: IS_DEAD=$IS_DEAD IS_FAILED=$IS_FAILED IS_PASSED=$IS_PASSED)."
if [ "$IS_PASSED" -eq "0" ] && [ "$IS_FAILED" -eq "1" ] && [ "$IS_DEAD" -eq "1" ]; then
    exit 0;
fi
exit 1
SPlanzer commented 4 years ago

Removing most tests from CI show this is an issue with the tests themselves hanging.

SPlanzer commented 4 years ago

tests were opening the gaz app and the app was throwing an sqlalchemy error.

I have upgraded to the newest sqlalchemy version (see PR #126). This now sees tests pass