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

108 lines
2.7 KiB
Bash
Raw Normal View History

Feature/timeout (#42) * WIP timeout * [add] zabbix discover test * decrease number of pools * [add] similar pool names test * [fix] pools check * [add] discovery debug errors * [add] extra output * [add] full output * [add] json * [del] localhost * [add] tests for localhost * [fix] #35 analyze all pools * [fix] port pools test * [add] show host info * [fix] localhost name resolution * display full log * [add] info for IP processing * [fix] IP processing * [add] timeout test * [fix] sudo delete pools * [add] test missing packages * [add] timeout checks * [add] pm checks * [fix] pools count in tests * [fix] move missing packages to seperate checks * [fix] testZabbixDiscoverNumberOfIPPools * [fix] explicitly remove packages * [fix] testMissingPackagesDiscoveryScript * [fix] status * [add] more info on error * [fix] testMissingPackagesDiscoveryScript * [add] run scripts as zabbix user * WIP tests for commands * [del] update echo * [fix] bash zabbix * [fix] socket test * [fix] discover pools errors * [add] ondemand hot pools * [fix] discover script errors * [fix] recache of ondemand pools * [add] continous checks * [fix] discover checks * [add] more details * [add] sort cache and results * [add] sleep tests * WIP checks * [fix] sleep timeout * [fix] ondemand calls * [add] more info * [add] script timeout test * [add] time execution print * [add] double run tests * [add] more timeout for ondemand pools * [fix] userparameters sleep * [add] display pools * [add] clear cache in tests * [fix] delete cache * [fix] max recursive checks * [add] run duration test * [add] more duration tests * [fix] execution time is measured in ms * [add] ondemand cache test * [add] enrease Zabbix timeout * [fix] zabbix timeout checks * [add] multiple run steps * [fix] stop PHP-FPM before modifications * [fix] port checks and port range * [fix] port calculation * [fix] increase timeout * [fix] order of tests * [fix] run PHP directory ending slash * [add, fix] cache of PHP run directory * [fix] PHP locations * Intermediate fix for timeout feature (#48) * [add] more asserts and checks * [fix] PHP sockets detection in tests * [fix] improved socket dir detection * [fix] improved service name detection, code simplification * [fix] socket pools check * [fix] mapfile -d * [add] local vars * [add] Travis CI folds * [add] color output * [add] extra sleep for service actions * Feature/cache location (#50)
2020-09-14 10:59:05 +02:00
#!/bin/bash
#Ramil Valitov ramilvalitov@gmail.com
#https://github.com/rvalitov/zabbix-php-fpm
#This script is used for testing
# Used for section folding in Travis CI
SECTION_UNIQUE_ID=""
# ----------------------------------
# Colors
# ----------------------------------
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
LIGHTGRAY='\033[0;37m'
DARKGRAY='\033[1;30m'
LIGHTRED='\033[1;31m'
LIGHTGREEN='\033[1;32m'
YELLOW='\033[1;33m'
LIGHTBLUE='\033[1;34m'
LIGHTPURPLE='\033[1;35m'
LIGHTCYAN='\033[1;36m'
WHITE='\033[1;37m'
function printYellow() {
local info=$1
echo -e "${YELLOW}$info${NOCOLOR}"
}
function printRed() {
local info=$1
echo -e "${RED}$info${NOCOLOR}"
}
function printGreen() {
local info=$1
echo -e "${LIGHTGREEN}$info${NOCOLOR}"
}
function printSuccess() {
local name=$1
printGreen "✓ OK: test '$name' passed"
}
function printDebug() {
local info=$1
echo -e "${DARKGRAY}$info${NOCOLOR}"
}
function printAction() {
local info=$1
echo -e "${LIGHTBLUE}$info${NOCOLOR}"
}
function travis_fold_start() {
local name=$1
local info=$2
local CURRENT_TIMING
CURRENT_TIMING=$(date +%s%3N)
SECTION_UNIQUE_ID="$name.$CURRENT_TIMING"
echo -e "travis_fold:start:${SECTION_UNIQUE_ID}\033[33;1m${info}\033[0m"
}
function travis_fold_end() {
echo -e "\ntravis_fold:end:${SECTION_UNIQUE_ID}\r"
}
oneTimeSetUp() {
printAction "Started job $TRAVIS_JOB_NAME"
travis_fold_start "host_info" "ⓘ Host information"
nslookup localhost
sudo ifconfig
sudo cat /etc/hosts
travis_fold_end
printAction "Copying Zabbix files..."
#Install files:
sudo cp "$TRAVIS_BUILD_DIR/zabbix/zabbix_php_fpm_discovery.sh" "/etc/zabbix"
sudo cp "$TRAVIS_BUILD_DIR/zabbix/zabbix_php_fpm_status.sh" "/etc/zabbix"
sudo cp "$TRAVIS_BUILD_DIR/zabbix/userparameter_php_fpm.conf" "$(find /etc/zabbix/ -name 'zabbix_agentd*.d' -type d | head -n1)"
sudo chmod +x /etc/zabbix/zabbix_php_fpm_discovery.sh
sudo chmod +x /etc/zabbix/zabbix_php_fpm_status.sh
printAction "All done, starting tests..."
}
testMissingPackagesDiscoveryScript() {
DATA=$(sudo bash "/etc/zabbix/zabbix_php_fpm_discovery.sh" "/php-fpm-status")
IS_OK=$(echo "$DATA" | grep -F ' not found.')
assertNotNull "Discovery script didn't report error on missing utilities $DATA" "$IS_OK"
printSuccess "${FUNCNAME[0]}"
}
testMissingPackagesStatusScript() {
DATA=$(sudo bash "/etc/zabbix/zabbix_php_fpm_status.sh" "localhost:9000" "/php-fpm-status")
IS_OK=$(echo "$DATA" | grep -F ' not found.')
assertNotNull "Status script didn't report error on missing utilities $DATA" "$IS_OK"
printSuccess "${FUNCNAME[0]}"
}
# Load shUnit2.
. shunit2