mirror of
https://github.com/rvalitov/zabbix-php-fpm.git
synced 2023-11-05 03:30:27 +01:00
[add] run duration test
This commit is contained in:
parent
d6efe19e0b
commit
25a5ea1465
43
tests/all.sh
43
tests/all.sh
@ -18,6 +18,15 @@ function restoreUserParameters() {
|
|||||||
sudo cp "$TRAVIS_BUILD_DIR/zabbix/userparameter_php_fpm.conf" "$(sudo find /etc/zabbix/ -name 'zabbix_agentd*.d' -type d | head -n1)"
|
sudo cp "$TRAVIS_BUILD_DIR/zabbix/userparameter_php_fpm.conf" "$(sudo find /etc/zabbix/ -name 'zabbix_agentd*.d' -type d | head -n1)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function AddSleepToConfig() {
|
||||||
|
PARAMS_FILE=$(getUserParameters)
|
||||||
|
sudo sed -i 's#.*zabbix_php_fpm_discovery.*#UserParameter=php-fpm.discover[*],sudo /etc/zabbix/zabbix_php_fpm_discovery.sh sleep $1#' "$PARAMS_FILE"
|
||||||
|
echo "New UserParameter file:"
|
||||||
|
sudo cat "$PARAMS_FILE"
|
||||||
|
sudo service zabbix-agent restart
|
||||||
|
sleep 2
|
||||||
|
}
|
||||||
|
|
||||||
copyPool() {
|
copyPool() {
|
||||||
ORIGINAL_FILE=$1
|
ORIGINAL_FILE=$1
|
||||||
POOL_NAME=$2
|
POOL_NAME=$2
|
||||||
@ -260,15 +269,6 @@ testDiscoverScriptSleep() {
|
|||||||
assertTrue "No success stop checks detected" "[ $STOP_OK_COUNT -gt 0 ]"
|
assertTrue "No success stop checks detected" "[ $STOP_OK_COUNT -gt 0 ]"
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddSleepToConfig() {
|
|
||||||
PARAMS_FILE=$(getUserParameters)
|
|
||||||
sudo sed -i 's#.*zabbix_php_fpm_discovery.*#UserParameter=php-fpm.discover[*],sudo /etc/zabbix/zabbix_php_fpm_discovery.sh sleep $1#' "$PARAMS_FILE"
|
|
||||||
echo "New UserParameter file:"
|
|
||||||
sudo cat "$PARAMS_FILE"
|
|
||||||
sudo service zabbix-agent restart
|
|
||||||
sleep 2
|
|
||||||
}
|
|
||||||
|
|
||||||
testZabbixDiscoverSleep() {
|
testZabbixDiscoverSleep() {
|
||||||
#Add sleep
|
#Add sleep
|
||||||
AddSleepToConfig
|
AddSleepToConfig
|
||||||
@ -276,6 +276,31 @@ testZabbixDiscoverSleep() {
|
|||||||
testZabbixDiscoverReturnsData
|
testZabbixDiscoverReturnsData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testDiscoverScriptRunDuration() {
|
||||||
|
START_TIME=$(date +%s%N)
|
||||||
|
DATA=$(sudo -u zabbix sudo "/etc/zabbix/zabbix_php_fpm_discovery.sh" "debug" "sleep" "/php-fpm-status")
|
||||||
|
END_TIME=$(date +%s%N)
|
||||||
|
ELAPSED_TIME=$(echo "($END_TIME - $START_TIME)/1000000" | bc)
|
||||||
|
|
||||||
|
echo "Elapsed time $ELAPSED_TIME ms"
|
||||||
|
|
||||||
|
assertTrue "The script worked for too long" "[ $ELAPSED_TIME -lt 3000 ]"
|
||||||
|
}
|
||||||
|
|
||||||
|
testZabbixDiscoverRunDuration() {
|
||||||
|
#Add sleep
|
||||||
|
AddSleepToConfig
|
||||||
|
|
||||||
|
START_TIME=$(date +%s%N)
|
||||||
|
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"])
|
||||||
|
END_TIME=$(date +%s%N)
|
||||||
|
ELAPSED_TIME=$(echo "($END_TIME - $START_TIME)/1000000" | bc)
|
||||||
|
|
||||||
|
echo "Elapsed time $ELAPSED_TIME ms"
|
||||||
|
|
||||||
|
assertTrue "The script worked for too long" "[ $ELAPSED_TIME -lt 3000 ]"
|
||||||
|
}
|
||||||
|
|
||||||
testDiscoverScriptDoubleRun() {
|
testDiscoverScriptDoubleRun() {
|
||||||
DATA_FIRST=$(sudo -u zabbix sudo "/etc/zabbix/zabbix_php_fpm_discovery.sh" "debug" "sleep" "/php-fpm-status")
|
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")
|
DATA_SECOND=$(sudo -u zabbix sudo "/etc/zabbix/zabbix_php_fpm_discovery.sh" "debug" "sleep" "/php-fpm-status")
|
||||||
|
Loading…
Reference in New Issue
Block a user