3
0
mirror of https://github.com/rvalitov/zabbix-php-fpm.git synced 2023-11-05 03:30:27 +01:00

[add] sleep tests

This commit is contained in:
Ramil Valitov 2020-07-07 05:55:00 +03:00
parent ab44dad6ec
commit 3ae47e6346
No known key found for this signature in database
GPG Key ID: 2AB186DABDFE1914
2 changed files with 35 additions and 16 deletions

View File

@ -209,7 +209,23 @@ testZabbixDiscoverReturnsData() {
assertNotNull "Discover script failed: $DATA" "$IS_OK" assertNotNull "Discover script failed: $DATA" "$IS_OK"
} }
function discoverAll() { testDiscoverScriptSleep() {
DATA=$(sudo -u zabbix sudo "/etc/zabbix/zabbix_php_fpm_discovery.sh" "debug" "sleep" "/php-fpm-status")
CHECK_OK=$(echo "$DATA" | grep -F "Check execution time OK")
STOP_OK=$(echo "$DATA" | grep -F "stop required")
assertNotNull "No success time checks detected" "$CHECK_OK"
assertNotNull "No success stop checks detected" "$STOP_OK"
}
testDiscoverScriptDoubleRun() {
DATA_FIRST=$(sudo -u zabbix sudo "/etc/zabbix/zabbix_php_fpm_discovery.sh" "debug" "sleep" "/php-fpm-status")
DATA_SECOND=$(sudo -u zabbix sudo "/etc/zabbix/zabbix_php_fpm_discovery.sh" "debug" "sleep" "/php-fpm-status")
assertNotEquals "Multiple discovery routines provide the same results" "$DATA_FIRST" "$DATA_SECOND"
}
function discoverAllZabbix() {
DATA_OLD=$1 DATA_OLD=$1
DATA_COUNT=$2 DATA_COUNT=$2
@ -228,12 +244,12 @@ function discoverAll() {
echo "Data new: $DATA" echo "Data new: $DATA"
return 1 return 1
fi fi
discoverAll "$DATA" "$DATA_COUNT" discoverAllZabbix "$DATA" "$DATA_COUNT"
fi fi
} }
testZabbixDiscoverNumberOfStaticPools() { testZabbixDiscoverNumberOfStaticPools() {
DATA=$(discoverAll) DATA=$(discoverAllZabbix)
STATUS=$? STATUS=$?
if [[ $STATUS -ne 0 ]]; then if [[ $STATUS -ne 0 ]]; then
echo "$DATA" echo "$DATA"
@ -247,7 +263,7 @@ testZabbixDiscoverNumberOfStaticPools() {
} }
testZabbixDiscoverNumberOfDynamicPools() { testZabbixDiscoverNumberOfDynamicPools() {
DATA=$(discoverAll) DATA=$(discoverAllZabbix)
STATUS=$? STATUS=$?
if [[ $STATUS -ne 0 ]]; then if [[ $STATUS -ne 0 ]]; then
echo "$DATA" echo "$DATA"
@ -261,7 +277,7 @@ testZabbixDiscoverNumberOfDynamicPools() {
} }
testZabbixDiscoverNumberOfOndemandPoolsCold() { testZabbixDiscoverNumberOfOndemandPoolsCold() {
DATA=$(discoverAll) DATA=$(discoverAllZabbix)
STATUS=$? STATUS=$?
if [[ $STATUS -ne 0 ]]; then if [[ $STATUS -ne 0 ]]; then
echo "$DATA" echo "$DATA"
@ -288,16 +304,19 @@ testZabbixDiscoverNumberOfOndemandPoolsHot() {
POOL_NAME="ondemand$c" POOL_NAME="ondemand$c"
POOL_SOCKET="/run/php/php${PHP_VERSION}-fpm-${POOL_NAME}.sock" POOL_SOCKET="/run/php/php${PHP_VERSION}-fpm-${POOL_NAME}.sock"
SCRIPT_NAME=$POOL_SOCKET \ PHP_STATUS=$(
SCRIPT_FILENAME=$POOL_SOCKET \ SCRIPT_NAME=$POOL_SOCKET \
QUERY_STRING=json \ SCRIPT_FILENAME=$POOL_SOCKET \
REQUEST_METHOD=GET \ QUERY_STRING=json \
sudo cgi-fcgi -bind -connect "$POOL_URL" 2>/dev/null REQUEST_METHOD=GET \
sudo cgi-fcgi -bind -connect "$POOL_URL" 2>/dev/null
)
assertNotNull "Failed to connect to $POOL_SOCKET" "$PHP_STATUS"
done done
fi fi
done <<<"$PHP_LIST" done <<<"$PHP_LIST"
DATA=$(discoverAll) DATA=$(discoverAllZabbix)
STATUS=$? STATUS=$?
if [[ $STATUS -ne 0 ]]; then if [[ $STATUS -ne 0 ]]; then
echo "$DATA" echo "$DATA"
@ -311,7 +330,7 @@ testZabbixDiscoverNumberOfOndemandPoolsHot() {
} }
testZabbixDiscoverNumberOfIPPools() { testZabbixDiscoverNumberOfIPPools() {
DATA=$(discoverAll) DATA=$(discoverAllZabbix)
STATUS=$? STATUS=$?
if [[ $STATUS -ne 0 ]]; then if [[ $STATUS -ne 0 ]]; then
echo "$DATA" echo "$DATA"
@ -325,7 +344,7 @@ testZabbixDiscoverNumberOfIPPools() {
} }
testZabbixDiscoverNumberOfPortPools() { testZabbixDiscoverNumberOfPortPools() {
DATA=$(discoverAll) DATA=$(discoverAllZabbix)
STATUS=$? STATUS=$?
if [[ $STATUS -ne 0 ]]; then if [[ $STATUS -ne 0 ]]; then
echo "$DATA" echo "$DATA"
@ -341,8 +360,8 @@ testZabbixDiscoverNumberOfPortPools() {
#This test should be last in Zabbix tests #This test should be last in Zabbix tests
testZabbixDiscoverTimeout() { testZabbixDiscoverTimeout() {
#Create lots of pools #Create lots of pools
MAX_POOLS=100 MAX_POOLS=20
MAX_PORTS=100 MAX_PORTS=20
setupPools setupPools
testZabbixDiscoverReturnsData testZabbixDiscoverReturnsData

View File

@ -301,7 +301,7 @@ function SavePrintResults() {
${S_PRINTF} "%s\n" "${PENDING_LIST[@]}" >"$PENDING_FILE" ${S_PRINTF} "%s\n" "${PENDING_LIST[@]}" >"$PENDING_FILE"
#We must sort the cache list #We must sort the cache list
readarray -t CACHE < <(for a in "${CACHE[@]}"; do echo "$a"; done | sort) readarray -t CACHE < <(for a in "${CACHE[@]}"; do echo "$a"; done | $S_SORT)
if [[ -n $DEBUG_MODE ]]; then if [[ -n $DEBUG_MODE ]]; then
PrintDebug "List of pools to be saved to cache pools file:" PrintDebug "List of pools to be saved to cache pools file:"