Skip to content

Commit

Permalink
Improved ci tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Schoechlin committed Dec 14, 2017
1 parent 5bd9518 commit e4a453e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
35 changes: 23 additions & 12 deletions ci_test
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,39 @@ wget -c "http://repo.zabbix.com/zabbix/3.2/ubuntu/pool/main/z/zabbix/zabbix-agen
wget -c "http://repo.zabbix.com/zabbix/3.2/ubuntu/pool/main/z/zabbix/zabbix-get_${REL}_amd64.deb"
sudo killall -KILL zabbix_agentd
sudo dpkg -i zabbix-agent_*.deb zabbix-get_*.deb
sudo sed -i '~s,# DebugLevel.*,DebugLevel=4,' /etc/zabbix/zabbix_agentd.conf
sudo tail -F /var/log/zabbix/zabbix_agentd.log &
sudo sed -i '~s,# DebugLevel.*,DebugLevel=2,' /etc/zabbix/zabbix_agentd.conf
sudo sed -i '~s,^Server=.*,Server=127.0.0.1' /etc/zabbix/zabbix_agentd.conf

echo "*** VALIDATIONS"

COMPILEDIR="$(mktemp -d /tmp/pycompile-XXXXXX)"
for SCRIPT in $(grep -l "#!/usr/bin/env python3" extension-files/tools/*|sort -u|xargs);
do
cp $SCRIPT $COMPILEDIR/
assertSuccess STOP_ON_ERROR "python -m py_compile ${COMPILEDIR}/$(basename $SCRIPT)"
assertSuccess STOP_ON_ERROR "python3 -m py_compile ${COMPILEDIR}/$(basename $SCRIPT)"
done

echo "*** TESTS"
assertSuccess STOP_ON_ERROR "sudo dpkg -i zabbix-agent-extensions_*.deb"
assertSuccess STOP_ON_ERROR "zabbix_get -s localhost -k linux.dmesg | tee /dev/stderr | grep -q -P 'OK: ALL OK|ERROR:'" # Without sudo
assertSuccess STOP_ON_ERROR "zabbix_get -s localhost -k linux.dmesg | tee /dev/stderr | grep -q 'OK: ALL OK|ERROR:'" # Without sudo
assertSuccess STOP_ON_ERROR "zabbix_get -s localhost -k linux.multipath | tee /dev/stderr | grep -q 'OK:'" # With sudo
assertSuccess STOP_ON_ERROR "zabbix_get -s localhost -k vfs.dev.discovery | tee /dev/stderr | grep -q '#BLOCKDEVICE'" # With sudo
assertSuccess STOP_ON_ERROR "zabbix_get -s localhost -k 'custom.process[zabbix_agentd,minage]'|tee /dev/stderr | grep -q -P '^\d+$'"
assertSuccess STOP_ON_ERROR "zabbix_get -s localhost -k 'custom.process[zabbix_agentd,maxage]'|tee /dev/stderr | grep -q -P '^\d+$'"
assertSuccess STOP_ON_ERROR "zabbix_get -s localhost -k 'custom.process[nosuchprocess,maxage]'|tee /dev/stderr | grep -q -P '^\d+$'"
assertSuccess STOP_ON_ERROR "zabbix_get -s localhost -k 'zabbix.agent_extensions.version'|tee /dev/stderr | grep -q -P '^\d+'"
sudo tail -f /var/log/zabbix/zabbix_agentd.log &
for i in `seq 1 30`;do
nc -vvv -w 1 127.0.0.1 10050
if [ "$?" = "0" ];then
break
fi
echo -n "."
sleep 1
done
echo
pkill tail

assertSuccess STOP_ON_ERROR "zabbix_get -s 127.0.0.1 -k linux.dmesg | tee /dev/stderr | grep -q -P 'OK: ALL OK|ERROR:'" # Without sudo
assertSuccess STOP_ON_ERROR "zabbix_get -s 127.0.0.1 -k linux.dmesg | tee /dev/stderr | grep -q -P 'OK: ALL OK|ERROR:'" # Without sudo
assertSuccess STOP_ON_ERROR "zabbix_get -s 127.0.0.1 -k linux.multipath | tee /dev/stderr | grep -q 'OK:'" # With sudo
assertSuccess STOP_ON_ERROR "zabbix_get -s 127.0.0.1 -k vfs.dev.discovery | tee /dev/stderr | grep -q '#BLOCKDEVICE'" # With sudo
assertSuccess STOP_ON_ERROR "zabbix_get -s 127.0.0.1 -k 'custom.process[zabbix_agentd,minage]'|tee /dev/stderr | grep -q -P '^\d+$'"
assertSuccess STOP_ON_ERROR "zabbix_get -s 127.0.0.1 -k 'custom.process[zabbix_agentd,maxage]'|tee /dev/stderr | grep -q -P '^\d+$'"
assertSuccess STOP_ON_ERROR "zabbix_get -s 127.0.0.1 -k 'custom.process[nosuchprocess,maxage]'|tee /dev/stderr | grep -q -P '^\d+$'"
assertSuccess STOP_ON_ERROR "zabbix_get -s 127.0.0.1 -k 'zabbix.agent_extensions.version'|tee /dev/stderr | grep -q -P '^\d+'"
assertSuccess STOP_ON_ERROR 'sudo dpkg -P zabbix-agent-extensions'

echo
Expand Down
2 changes: 2 additions & 0 deletions extension-files/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ if ( (grep -q "Ubuntu" /etc/os-release) || (grep -q "Debian" /etc/os-release) ||
chown zabbix:zabbix /var/run/zabbix-generic-discovery/

if (which systemctl >/dev/null 2>&1);then
echo "Restarting with systemctl"
systemctl restart zabbix-agent
else
echo "Restarting with /etc/init.d/zabbix-agent"
/etc/init.d/zabbix-agent restart
fi

Expand Down

0 comments on commit e4a453e

Please sign in to comment.