From e11053523212672db021102e4db66f1a006a55b8 Mon Sep 17 00:00:00 2001 From: Ramil Valitov Date: Fri, 3 Jul 2020 16:48:27 +0300 Subject: [PATCH] Feature/zabbix5 tests + codefactor (#41) --- .travis.yml | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++- README.md | 2 +- tests/all.sh | 15 ++++++++++++++ 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08c7f48..57dd101 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,6 +51,30 @@ jobs: - php-fpm before_script: - sudo curl -o /usr/local/bin/shunit2 https://raw.githubusercontent.com/kward/shunit2/master/shunit2 + - os: linux + dist: bionic + name: "Zabbix 5.0 @ Ubuntu 18 bionic, PHP default" + arch: amd64 + addons: + apt: + sources: + - sourceline: 'deb http://repo.zabbix.com/zabbix/5.0/ubuntu bionic main' + key_url: "https://repo.zabbix.com/zabbix-official-repo.key" + packages: + - ca-certificates + - curl + - grep + - sed + - gawk + - lsof + - jq + - libfcgi-bin + - unzip + - zabbix-agent + - zabbix-get + - php-fpm + before_script: + - sudo curl -o /usr/local/bin/shunit2 https://raw.githubusercontent.com/kward/shunit2/master/shunit2 - os: linux dist: bionic name: "Zabbix 4.0 @ Ubuntu 18 bionic, PHP 7.0-7.4" @@ -58,7 +82,7 @@ jobs: addons: apt: sources: - - sourceline: 'deb http://repo.zabbix.com/zabbix/4.4/ubuntu bionic main' + - sourceline: 'deb http://repo.zabbix.com/zabbix/4.0/ubuntu bionic main' key_url: "https://repo.zabbix.com/zabbix-official-repo.key" - sourceline: 'ppa:ondrej/php' packages: @@ -109,6 +133,35 @@ jobs: - php7.4-fpm before_script: - sudo curl -o /usr/local/bin/shunit2 https://raw.githubusercontent.com/kward/shunit2/master/shunit2 + - os: linux + dist: bionic + name: "Zabbix 5.0 @ Ubuntu 18 bionic, PHP 7.0-7.4" + arch: amd64 + addons: + apt: + sources: + - sourceline: 'deb http://repo.zabbix.com/zabbix/5.0/ubuntu bionic main' + key_url: "https://repo.zabbix.com/zabbix-official-repo.key" + - sourceline: 'ppa:ondrej/php' + packages: + - ca-certificates + - curl + - grep + - sed + - gawk + - lsof + - jq + - libfcgi-bin + - unzip + - zabbix-agent + - zabbix-get + - php7.0-fpm + - php7.1-fpm + - php7.2-fpm + - php7.3-fpm + - php7.4-fpm + before_script: + - sudo curl -o /usr/local/bin/shunit2 https://raw.githubusercontent.com/kward/shunit2/master/shunit2 script: bash tests/all.sh notifications: diff --git a/README.md b/README.md index e63bc73..1cee9bb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PHP-FPM Zabbix Template with Auto Discovery and Multiple Pools -![Zabbix versions](https://img.shields.io/badge/Zabbix_versions-5.0,_4.4,_4.2,_4.0-green.svg?style=flat) ![PHP](https://img.shields.io/badge/PHP-5.3.3+-blue.svg?style=flat) ![PHP7](https://img.shields.io/badge/PHP7-supported-green.svg?style=flat) ![LLD](https://img.shields.io/badge/LLD-yes-green.svg?style=flat) ![ISPConfig](https://img.shields.io/badge/ISPConfig-supported-green.svg?style=flat) [![Build Status](https://travis-ci.com/rvalitov/zabbix-php-fpm.svg?branch=master)](https://travis-ci.com/rvalitov/zabbix-php-fpm) +![Zabbix versions](https://img.shields.io/badge/Zabbix_versions-5.0,_4.4,_4.2,_4.0-green.svg?style=flat) ![PHP](https://img.shields.io/badge/PHP-5.3.3+-blue.svg?style=flat) ![PHP7](https://img.shields.io/badge/PHP7-supported-green.svg?style=flat) ![LLD](https://img.shields.io/badge/LLD-yes-green.svg?style=flat) ![ISPConfig](https://img.shields.io/badge/ISPConfig-supported-green.svg?style=flat) [![Build Status](https://travis-ci.com/rvalitov/zabbix-php-fpm.svg?branch=master)](https://travis-ci.com/rvalitov/zabbix-php-fpm) [![CodeFactor](https://www.codefactor.io/repository/github/rvalitov/zabbix-php-fpm/badge)](https://www.codefactor.io/repository/github/rvalitov/zabbix-php-fpm) ![Banner](https://github.com/rvalitov/zabbix-php-fpm/wiki/media/repository-open-graph-template.png) diff --git a/tests/all.sh b/tests/all.sh index d186c4a..12bad36 100644 --- a/tests/all.sh +++ b/tests/all.sh @@ -59,6 +59,7 @@ getAnyPort() { } oneTimeSetUp() { + echo "Started job $TRAVIS_JOB_NAME" echo "Copying Zabbix files..." #Install files: sudo cp "$TRAVIS_BUILD_DIR/zabbix/zabbix_php_fpm_discovery.sh" "/etc/zabbix" @@ -89,6 +90,20 @@ testZabbixGetInstalled() { assertNotNull "Utility zabbix-get not installed" "$ZABBIX_GET" } +testZabbixAgentVersion() { + #Example: 4.4 + REQUESTED_VERSION=$(echo "$TRAVIS_JOB_NAME" | grep -i -F "zabbix" | head -n1 | cut -d "@" -f1 | cut -d " " -f2) + INSTALLED_VERSION=$(zabbix_agentd -V | grep -F "zabbix" | head -n1 | rev | cut -d " " -f1 | rev | cut -d "." -f1,2) + assertSame "Requested version $REQUESTED_VERSION and installed version $INSTALLED_VERSION of Zabbix agent do not match" "$REQUESTED_VERSION" "$INSTALLED_VERSION" +} + +testZabbixGetVersion() { + #Example: 4.4 + REQUESTED_VERSION=$(echo "$TRAVIS_JOB_NAME" | grep -i -F "zabbix" | head -n1 | cut -d "@" -f1 | cut -d " " -f2) + INSTALLED_VERSION=$(zabbix_get -V | grep -F "zabbix" | head -n1 | rev | cut -d " " -f1 | rev | cut -d "." -f1,2) + assertSame "Requested version $REQUESTED_VERSION and installed version $INSTALLED_VERSION of zabbix_get do not match" "$REQUESTED_VERSION" "$INSTALLED_VERSION" +} + testPHPIsRunning() { IS_OK=$(sudo ps ax | grep -F "php-fpm: pool " | grep -F -v "grep" | head -n1) assertNotNull "No running PHP-FPM instances found" "$IS_OK"