diff --git a/.travis.yml b/.travis.yml index 7a2b5da..b781de9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,27 @@ language: bash jobs: 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 dist: bionic name: "Zabbix 4.0 @ Ubuntu 18 bionic, PHP default" diff --git a/tests/all.sh b/tests/all.sh index 61f4b2b..f92c0f6 100644 --- a/tests/all.sh +++ b/tests/all.sh @@ -267,25 +267,5 @@ testZabbixDiscoverTimeout() { 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. . shunit2 diff --git a/tests/missing.sh b/tests/missing.sh new file mode 100644 index 0000000..4ab25f3 --- /dev/null +++ b/tests/missing.sh @@ -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