summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/monkey/qa/run_tests.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:19:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:20:02 +0000
commit58daab21cd043e1dc37024a7f99b396788372918 (patch)
tree96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /fluent-bit/lib/monkey/qa/run_tests.sh
parentReleasing debian version 1.43.2-1. (diff)
downloadnetdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz
netdata-58daab21cd043e1dc37024a7f99b396788372918.zip
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'fluent-bit/lib/monkey/qa/run_tests.sh')
-rwxr-xr-xfluent-bit/lib/monkey/qa/run_tests.sh119
1 files changed, 119 insertions, 0 deletions
diff --git a/fluent-bit/lib/monkey/qa/run_tests.sh b/fluent-bit/lib/monkey/qa/run_tests.sh
new file mode 100755
index 000000000..4c0b9fa75
--- /dev/null
+++ b/fluent-bit/lib/monkey/qa/run_tests.sh
@@ -0,0 +1,119 @@
+
+#!/bin/sh
+TEST_FILES=`ls *.htt`
+TOTAL_TESTS=`echo $TEST_FILES | wc -w`
+
+# Server parameters file
+CONFIG_FILE='__CONFIG'
+
+LOGFILE='errors.log'
+
+# Clear log file
+:>$LOGFILE
+
+# Should we stop at the first error? (yes | no)
+STOP_AT_ERRORS=no
+
+# httest error code for 'Connection refused'
+CONN_REFUSED=111
+
+# Enable colors in output :) (yes | no)
+WITH_COLOR=yes
+
+# httest command
+HTTEST_CMD='httest'
+
+NTEST=1
+TESTS_FAILED=0
+TESTS_OK=0
+TESTS_AVOIDED=0
+CHECKLOGS=0
+
+if [ "$1" = "-l" ]; then
+ CHECKLOGS=1
+ TOTAL_TESTS=`expr $TOTAL_TESTS \* 2`
+fi
+
+for test_file in $TEST_FILES; do
+# echo -ne "[TEST $NTEST/$TOTAL_TESTS]\t""case: $test_file\t\t"
+ printf "[%3d/%d] %-32s " $NTEST $TOTAL_TESTS "$test_file"
+
+ OUTPUT=`$HTTEST_CMD "$test_file" 2>&1`
+ ERRCODE=$?
+
+ case $ERRCODE in
+ 0)
+ TESTS_OK=$((TESTS_OK+1))
+ [ $WITH_COLOR = yes ] && echo -n ""
+ echo -n "=> [OK]"
+ [ $WITH_COLOR = yes ] && echo -n ""
+ ;;
+
+ $CONN_REFUSED)
+ echo
+ echo "Connection refused... (Is monkey running?)" >&2
+ exit $CONN_REFUSED
+ ;;
+
+ *)
+ TESTS_FAILED=$((TESTS_FAILED+1))
+ [ $WITH_COLOR = yes ] && echo -n ""
+ echo -n "=> [FAILED]"
+ [ $WITH_COLOR = yes ] && echo -n ""
+
+ perl -e 'print "-" x 78, "\n"' >>"$LOGFILE"
+ echo "$OUTPUT" >>"$LOGFILE"
+ perl -e 'print "-" x 78, "\n"' >>"$LOGFILE"
+
+ [ $STOP_AT_ERRORS = yes ] && exit 1
+ esac
+
+ # Check for logfiles rules
+ NTEST=$((NTEST+1))
+
+ if [ $CHECKLOGS = 0 ]; then
+ echo
+ continue
+ fi
+
+ echo
+ test_file=`echo $test_file | sed 's/\.htt/\.log/g'`
+ printf "[%3d/%d] %-32s " $NTEST $TOTAL_TESTS "$test_file"
+
+ if [ ! -e "log_rules/$test_file" ]; then
+ ERRCODE=2
+ else
+ # We need to sleep for a while as Monkey needs to flush
+ # the logs, that happens every 3 seconds
+ sleep 2
+ CHECKLOG=`./checklog -l log_rules/$test_file`
+ ERRCODE=$?
+ fi
+
+ case $ERRCODE in
+ 0)
+ [ $WITH_COLOR = yes ] && echo -n ""
+ echo "=> [OK]"
+ [ $WITH_COLOR = yes ] && echo -n ""
+ TESTS_OK=$((TESTS_OK+1))
+ ;;
+ 1)
+ [ $WITH_COLOR = yes ] && echo -n ""
+ echo "=> [FAILED]"
+ echo $CHECKLOG
+ [ $WITH_COLOR = yes ] && echo -n ""
+ TESTS_FAILED=$((TESTS_FAILED+1))
+ [ $STOP_AT_ERRORS = yes ] && exit 1
+ ;;
+
+ 2) [ $WITH_COLOR = yes ] && echo -n ""
+ echo "=> [NO RULES]"
+ [ $WITH_COLOR = yes ] && echo -n ""
+ TESTS_AVOIDED=$((TESTS_AVOIDED+1))
+ ;;
+ esac
+
+ NTEST=$((NTEST+1))
+done
+
+echo -e "\n$TESTS_OK test(s) succeeded, $TESTS_FAILED test(s) failed, $TESTS_AVOIDED test(s) avoided."