diff options
Diffstat (limited to 'tests/run-tests.sh')
| -rwxr-xr-x | tests/run-tests.sh | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/tests/run-tests.sh b/tests/run-tests.sh new file mode 100755 index 0000000..ef833c7 --- /dev/null +++ b/tests/run-tests.sh @@ -0,0 +1,112 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p jq curl + +function cleanup { + echo + popd >/dev/null + echo Shutting down container ... + sudo nixos-container stop hermes +} + +pushd $(dirname $0) >/dev/null +echo Stopping container for update ... +sudo nixos-container stop hermes || exit 2 +echo Updating container ... +sudo nixos-container update hermes --flake .#hermes-test || exit 2 +echo Starting container ... +sudo nixos-container start hermes || exit 2 + +trap cleanup EXIT +sleep 0.1 +IP=$(nixos-container show-ip hermes) +CURL_FLAGS='--location --silent' + +echo +echo Checking that all the services are running: +declare -A PORTS +PORTS[quentin]=8080 +PORTS[rss]=8082 +PORTS[mesh]=8084 +PORTS[git]=8086 +declare -A SUFFIX +SUFFIX[quentin]="" +SUFFIX[rss]="" +SUFFIX[git]="?p=about" +SUFFIX[mesh]="health" + +for SERVICE in "${!PORTS[@]}" +do + URL="http://$IP:${PORTS[$SERVICE]}/${SUFFIX[$SERVICE]}" + echo Checking connection to container version of $SERVICE.aristote.fr ... + RESULT=$(curl "$URL" $CURL_FLAGS --output /dev/null --write-out '%{http_code}\n') + case "$RESULT" in + 200) echo "Up and running at $URL !";; + 301) echo "Redirected.";; + *) echo "Connection failed.";; + esac +done + + +echo +echo Checking web keys directory: +URL_PREFIX="http://$IP:8083/.well-known/openpgpkey/aristote.vm" +KEYS="$(ls ../config/services/web/webkeydirectory/hu)" +for KEY in $KEYS +do + echo Checking key $KEY ... + RESULT=$(curl "$URL_PREFIX/hu/$KEY" $CURL_FLAGS --output /dev/null --write-out '%{http_code}\n') + if [[ ! "$RESULT" = 200 ]] + then + echo "Connection failed." + fi +done +echo Checking policy file ... +RESULT=$(curl "$URL_PREFIX/policy" $CURL_FLAGS --output /dev/null --write-out '%{http_code}\n') +if [[ ! "$RESULT" = 200 ]] +then + echo "Connection failed." +fi +echo Done. + + +echo +echo Checking custom RSS bridges: +BRIDGES="$(ls ../config/services/web/rss/*Bridge.php | xargs basename -s Bridge.php)" +for BRIDGE in $BRIDGES +do + echo Checking bridge $BRIDGE ... + RESULT=$(curl "http://$IP:${PORTS[rss]}/?action=display&bridge=$BRIDGE&format=Plaintext" $CURL_FLAGS --output /dev/null --write-out '%{http_code}\n') + if [[ ! "$RESULT" = 200 ]] + then + echo "Connection failed." + fi +done +echo Done. + + +# echo +# echo Checking custom Searx engines: +# declare -A QUERIES +# QUERIES[alternativeto]=Searx +# QUERIES[nlab]='Kan%20extension' +# QUERIES[wfr]=Paris +# QUERIES[wen]=Paris +# for ENGINE in "${!QUERIES[@]}" +# do +# echo Checking engine $ENGINE ... +# REQUEST_URL="http://$IP:${PORTS[searx]}/search?q=${QUERIES[$ENGINE]}+!$ENGINE&format=json" +# JSON_RESULT=$(curl "$REQUEST_URL" $CURL_FLAGS) +# RESULTS=$(echo $JSON_RESULT | jq '.results') +# UNRESPONSIVE_ENGINES=$(echo $JSON_RESULT | jq '.unresponsive_engines') +# if [[ ! "$UNRESPONSIVE_ENGINES" = '[]' ]] +# then +# echo "Engine not responsive." +# elif [[ "$RESULTS" = [] ]] +# then +# echo "No results found." +# fi +# done +# echo Done. + +echo +read -n1 -srp "Press any key to stop the server." |
