From 45dbf7de0b1978533a9eddf70e51464eb2ce2148 Mon Sep 17 00:00:00 2001 From: Ramil Valitov Date: Mon, 29 Jun 2020 01:44:32 +0300 Subject: [PATCH] [add] similar pool names test --- tests/all.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/all.sh b/tests/all.sh index 53fd65e..fb22e12 100644 --- a/tests/all.sh +++ b/tests/all.sh @@ -54,6 +54,11 @@ setupPools() { done <<<"$PHP_LIST" } +getNumberOfPHPVersions() { + PHP_COUNT=$(find /etc/php/ -name 'www.conf' -type f | wc -l) + echo "$PHP_COUNT" +} + getAnySocket() { #Get any socket of PHP-FPM: PHP_FIRST=$(find /etc/php/ -name 'www.conf' -type f | head -n1) @@ -150,5 +155,21 @@ testZabbixDiscoverReturnsData() { assertNotNull "Discover script failed: $DATA" "$IS_OK" } +testZabbixDiscoverSimilarSocketPoolNames() { + DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"]) + NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"socket1",' | wc -l) + PHP_COUNT=$(getNumberOfPHPVersions) + POOLS=$(echo "($PHP_COUNT * $MAX_POOLS)/1" | bc) + assertEquals "Found $NUMBER_OF_POOLS pools instead of $POOLS" "$NUMBER_OF_POOLS" "$POOLS" +} + +testZabbixDiscoverSimilarHttpPoolNames() { + DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"]) + NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"http1",' | wc -l) + PHP_COUNT=$(getNumberOfPHPVersions) + POOLS=$(echo "($PHP_COUNT * $MAX_POOLS)/1" | bc) + assertEquals "Found $NUMBER_OF_POOLS pools instead of $POOLS" "$NUMBER_OF_POOLS" "$POOLS" +} + # Load shUnit2. . shunit2