Created
August 12, 2022 12:18
-
-
Save arbakker/08b14c7db145ef7897335bef29b9d341 to your computer and use it in GitHub Desktop.
Bash script to inspect timouts occuring op WCS service #bash #curl #parallel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| URL="https://service.pdok.nl/rws/ahn3/wcs/v1_0?version=2.0.1&request=GetCoverage&service=WCS&CoverageID=ahn3_05m_dtm&crs=http%3A%2F%2Fwww.opengis.net%2Fdef%2Fcrs%2FEPSG%2F0%2F28992&format=image%2Ftiff&scalesize=x%281493%29%2Cy%28808%29&subset=x%28114021.98659130755%2C121802.44239326802%29&subset=y%28487095.239434995%2C491336.6998494373%29" | |
| COUNT=0 | |
| RESULT_FILE=$(mktemp) | |
| function do_request(){ | |
| REQ_NR="$1" | |
| echo "" | |
| echo "req_nr - $REQ_NR, url - $URL" | |
| curl "$URL" --max-time 15 -o /dev/null | |
| if [[ $? -eq 28 ]]; then | |
| echo 1 >> $RESULT_FILE | |
| echo "request timed out after 15 seconds, should take about 2" | |
| fi | |
| } | |
| echo "# TEST WCS PARALLEL" | |
| N_REQUESTS=80 | |
| NR_OF_PARALLEL_REQUEST=20 | |
| export -f do_request | |
| export URL | |
| export RESULT_FILE | |
| export NR_OF_PARALLEL_REQUEST | |
| parallel -j$NR_OF_PARALLEL_REQUEST do_request {} ::: $(seq 1 $N_REQUESTS) | |
| echo "" | |
| echo "############################################################" | |
| echo "" | |
| COUNT=$(wc -l $RESULT_FILE | awk 'END {print $1}') | |
| echo "$COUNT requests timed out" | |
| if [[ $COUNT -gt 0 ]];then | |
| exit 1 | |
| else | |
| exit 0 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment