diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2019-09-29 09:10:35 +0000 |
---|---|---|
committer | Chris Akritidis <43294513+cakrit@users.noreply.github.com> | 2019-09-29 11:10:35 +0200 |
commit | 325857ef07822fa5e6a1330d96be55276d9e664a (patch) | |
tree | d9bcb3f8fa6f3ec61e911b901314df67a590988d /tests/acls | |
parent | 7de804a4e1e0a34424bad7ecb6541cb71c0c7b2a (diff) |
Common pattern for web and alarms together with two bug fixes (#6783)
* script_pattern: Fix script and bring pattern
This commit fixes the error given by shellckeck on stress.sh and brings a pattern for the other scripts, no
less important its given the possibility to change the url from outside of the scripts
* script_pattern: shellcheke
Correct the request.sh after to change it to avoid warning errors from shellchecker
* script_pattern: Remove of garbage value
With this PR I am removing the garbage value of a script
* script_pattern: Restore color
These 3 scripts changed in this commit was not restoring the terminal color,
this commit fixes this
Diffstat (limited to 'tests/acls')
-rw-r--r-- | tests/acls/acl.sh.in | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/tests/acls/acl.sh.in b/tests/acls/acl.sh.in index 772d664088..9ac404c075 100644 --- a/tests/acls/acl.sh.in +++ b/tests/acls/acl.sh.in @@ -8,6 +8,7 @@ NETDATA_VARLIB_DIR="/var/lib/netdata" RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[0;43m' +NOCOLOR='\033[0m' #change the previous acl file and with a new #and store it on a new file @@ -15,6 +16,8 @@ change_file(){ sed "s/$1/$2/g" netdata.cfg > "$4" } +NETDATAPID="" + change_ssl_file(){ KEYROW="ssl key = $3/key.pem" CERTROW="ssl certificate = $3/cert.pem" @@ -35,24 +38,24 @@ run_acl_tests() { TOT=$(grep -c "HTTP/1.1 301" log_*.txt | cut -d: -f2| grep -c 1) if [ "$TOT" -ne "$4" ]; then - echo -e "${RED}I got a wrong number of redirects($TOT) when SSL is activated, It was expected $4" + echo -e "${RED}I got a wrong number of redirects($TOT) when SSL is activated, It was expected $4 ${NOCOLOR}" rm log_* netdata.conf.test* netdata.txt health.csv index.html badge.csv tmp* key.pem cert.pem info.txt - killall netdata + kill $NETDATAPID exit 1 elif [ "$TOT" -eq "$4" ] && [ "$4" -ne "0" ]; then - echo -e "${YELLOW}I got the correct number of redirects($4) when SSL is activated and I try to access with HTTP." + echo -e "${YELLOW}I got the correct number of redirects($4) when SSL is activated and I try to access with HTTP. ${NOCOLOR}" return fi TOT=$(grep -c "HTTP/1.1 200 OK" log_* | cut -d: -f2| grep -c 1) if [ "$TOT" -ne "$3" ]; then - echo -e "${RED}I got a wrong number of \"200 OK\" from the queries, it was expected $3." - killall netdata + echo -e "${RED}I got a wrong number of \"200 OK\" from the queries, it was expected $3. ${NOCOLOR}" + kill $NETDATAPID rm log_* netdata.conf.test* netdata.txt health.csv index.html badge.csv tmp* key.pem cert.pem info.txt exit 1 fi - echo -e "${GREEN}ACLs were applied correctly" + echo -e "${GREEN}ACLs were applied correctly ${NOCOLOR}" } CONF=$(grep "bind" netdata.cfg) @@ -69,12 +72,14 @@ else fi change_file "$CONF" " bind to = *" "$CWD" "netdata.conf.test0" -netdata -c "netdata.conf.test0" +netdata -c "netdata.conf.test0" -D & +NETDATAPID=$! run_acl_tests $TOKEN "$BASICURL:19999" 5 0 -killall netdata +kill $NETDATAPID change_ssl_file "$CONF" " bind to = *=dashboard|registry|badges|management|netdata.conf *:20000=dashboard|registry|badges|management *:20001=dashboard|registry|netdata.conf^SSL=optional *:20002=dashboard|registry" "$CWD" "netdata.conf.test1" -netdata -c "netdata.conf.test1" +netdata -c "netdata.conf.test1" -D & +NETDATAPID=$! run_acl_tests $TOKEN "$BASICURL:19999" 5 5 run_acl_tests $TOKEN "$BASICURLS:19999" 5 0 @@ -86,10 +91,11 @@ run_acl_tests $TOKEN "$BASICURLS:20001" 4 0 run_acl_tests $TOKEN "$BASICURL:20002" 3 5 run_acl_tests $TOKEN "$BASICURLS:20002" 3 0 -killall netdata +kill $NETDATAPID change_ssl_file "$CONF" " bind to = *=dashboard|registry|badges|management|netdata.conf *:20000=dashboard|registry|badges|management *:20001=dashboard|registry|netdata.conf^SSL=force *:20002=dashboard|registry" "$CWD" "netdata.conf.test2" -netdata -c "netdata.conf.test2" +netdata -c "netdata.conf.test2" -D & +NETDATAPID=$! run_acl_tests $TOKEN "$BASICURL:19999" 5 5 run_acl_tests $TOKEN "$BASICURLS:19999" 5 0 @@ -101,10 +107,11 @@ run_acl_tests $TOKEN "$BASICURLS:20001" 4 0 run_acl_tests $TOKEN "$BASICURL:20002" 3 5 run_acl_tests $TOKEN "$BASICURLS:20002" 3 0 -killall netdata +kill $NETDATAPID change_ssl_file "$CONF" " bind to = *=dashboard|registry|badges|management|netdata.conf *:20000=dashboard|registry|badges|management^SSL=optional *:20001=dashboard|registry|netdata.conf^SSL=force" "$CWD" "netdata.conf.test3" -netdata -c "netdata.conf.test3" +netdata -c "netdata.conf.test3" -D & +NETDATAPID=$! run_acl_tests $TOKEN "$BASICURL:19999" 5 5 run_acl_tests $TOKEN "$BASICURLS:19999" 5 0 @@ -113,7 +120,7 @@ run_acl_tests $TOKEN "$BASICURLS:20000" 4 0 run_acl_tests $TOKEN "$BASICURL:20001" 4 5 run_acl_tests $TOKEN "$BASICURLS:20001" 4 0 -killall netdata +kill $NETDATAPID rm log_* netdata.conf.test* netdata.txt health.csv index.html badge.csv tmp* key.pem cert.pem info.txt -echo "All the tests were successful" +echo "All the tests were successful ${NOCOLOR}" |