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

[fix] move missing packages to seperate checks

This commit is contained in:
Ramil Valitov 2020-07-06 23:21:18 +03:00
parent 96a95e833d
commit 5cca66bc04
No known key found for this signature in database
GPG Key ID: 2AB186DABDFE1914
3 changed files with 57 additions and 20 deletions

View File

@ -3,6 +3,27 @@ language: bash
jobs: jobs:
include: include:
- os: linux
dist: bionic
name: "Missing packages test"
arch: amd64
addons:
apt:
sources:
- sourceline: 'deb http://repo.zabbix.com/zabbix/4.0/ubuntu bionic main'
key_url: "https://repo.zabbix.com/zabbix-official-repo.key"
packages:
- bc
- curl
- grep
- sed
- gawk
- zabbix-agent
- zabbix-get
- php-fpm
before_script:
- sudo curl -o /usr/local/bin/shunit2 https://raw.githubusercontent.com/kward/shunit2/master/shunit2
script: bash tests/missing.sh
- os: linux - os: linux
dist: bionic dist: bionic
name: "Zabbix 4.0 @ Ubuntu 18 bionic, PHP default" name: "Zabbix 4.0 @ Ubuntu 18 bionic, PHP default"

View File

@ -267,25 +267,5 @@ testZabbixDiscoverTimeout() {
testZabbixDiscoverReturnsData testZabbixDiscoverReturnsData
} }
#################################
#The following tests should be last, no tests of actual data should be done afterwards
testMissingPackagesDiscoveryScript() {
sudo apt-get -y purge jq
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 utility 'jq'"
}
testMissingPackagesStatusScript() {
sudo apt-get -y purge libfcgi-bin libfcgi0ldbl
PHP_POOL=$(getAnySocket)
DATA=$(sudo bash "/etc/zabbix/zabbix_php_fpm_status.sh" "$PHP_POOL" "/php-fpm-status")
IS_OK=$(echo "$DATA" | grep -F ' not found.')
assertNotNull "Status script didn't report error on missing utility 'cgi-fcgi'"
}
# Load shUnit2. # Load shUnit2.
. shunit2 . shunit2

36
tests/missing.sh Normal file
View File

@ -0,0 +1,36 @@
#!/bin/bash
#Ramil Valitov ramilvalitov@gmail.com
#https://github.com/rvalitov/zabbix-php-fpm
#This script is used for testing
oneTimeSetUp() {
echo "Started job $TRAVIS_JOB_NAME"
echo "Host info:"
nslookup localhost
sudo ifconfig
sudo cat /etc/hosts
echo "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
echo "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 utility 'jq'" "$IS_OK"
}
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 utility 'cgi-fcgi'" "$IS_OK"
}
# Load shUnit2.
. shunit2