Skip to content

Commit ec38713

Browse files
committed
improve tests
1 parent ccef556 commit ec38713

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tests/check.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh -ex
1+
#!/bin/bash -ex
22

33
export TESTDIR=$(dirname $0)
44
export ZABBIX_USER=Admin
@@ -23,10 +23,10 @@ su postgres -c '/usr/pgsql-9.5/bin/pg_ctl start -w -D /var/lib/pgsql/9.5/data'
2323
echo "shared_preload_libraries = '\"\$libdir/pg_stat_statements\"'" > /var/lib/pgsql/9.5/data/postgresql.auto.conf
2424
mamonsu tune
2525
su postgres -c '/usr/pgsql-9.5/bin/pg_ctl restart -w -D /var/lib/pgsql/9.5/data'
26-
grep "shared_preload_libraries \= '\"\$libdir/pg_stat_statements\", pg_buffercache'" /var/lib/pgsql/9.5/data/postgresql.auto.conf
26+
grep "shared_preload_libraries \= '\"\$libdir/pg_stat_statements\", pg_buffercache'" /var/lib/pgsql/9.5/data/postgresql.auto.conf || (cat /var/lib/pgsql/9.5/data/postgresql.auto.conf && exit 1)
2727

2828
# mamonsu report
29-
(mamonsu report | grep version | grep 'PostgreSQL 9.5') || exit 1
29+
(mamonsu report | grep version | grep 'PostgreSQL 9.5') || exit 2
3030

3131
# export config
3232
cat <<EOF > /etc/mamonsu/plugins/def_conf_test.py
@@ -44,14 +44,14 @@ class DefConfTest(Plugin):
4444
os.system("touch /tmp/extenal_plugin_is_called")
4545
EOF
4646
mamonsu export config /tmp/config
47-
grep external_plugin_config /tmp/config || exit 2
47+
grep external_plugin_config /tmp/config || exit 3
4848
sed -i 's|.*max_checkpoint_by_wal_in_hour =.*|max_checkpoint_by_wal_in_hour = 5555555555555|g' /tmp/config
4949

5050
# write zabbix template
5151
mamonsu export template $ZABBIX_TEMPLATE -t $ZABBIX_TEMPLATE_NAME -c /tmp/config
52-
grep 5555555555555 /tmp/template.xml || exit 3
53-
grep 'pgsql\.uptime\[\]' /tmp/template.xml || exit 3
54-
grep 'system\.disk\.all_read' /tmp/template.xml || exit 3
52+
grep 5555555555555 /tmp/template.xml || exit 4
53+
grep 'pgsql\.uptime\[\]' /tmp/template.xml || exit 4
54+
grep 'system\.disk\.all_read' /tmp/template.xml || exit 4
5555

5656
# test export config
5757
cat <<EOF > /etc/mamonsu/agent.conf
@@ -68,7 +68,7 @@ enabled = False
6868
config = external_plugin_config2
6969
EOF
7070
mamonsu export config /tmp/config -a /etc/mamonsu/plugins -c /etc/mamonsu/agent.conf
71-
grep external_plugin_config2 /tmp/config || exit 2
71+
grep external_plugin_config2 /tmp/config || exit 5
7272

7373
# install zabbix
7474
yum install -y http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
@@ -148,24 +148,24 @@ mamonsu bootstrap -U postgres mamonsu
148148
sleep 125
149149

150150
# check external plugin is worked
151-
file /tmp/extenal_plugin_is_called || exit 4
151+
file /tmp/extenal_plugin_is_called || exit 6
152152

153153
# check metric from agent
154154
mamonsu agent -c /etc/mamonsu/agent.conf version
155155
mamonsu agent metric-get system.disk.all_read[] -c /etc/mamonsu/agent.conf
156156
mamonsu agent -c /etc/mamonsu/agent.conf metric-list | grep system
157157

158158
# metric log
159-
grep utilization /tmp/localhost.log || exit 5
160-
grep 'pgsql\.uptime' /tmp/localhost.log || exit 5
159+
grep utilization /tmp/localhost.log || exit 7
160+
grep 'pgsql\.uptime' /tmp/localhost.log || exit 7
161161

162162
# error in zabbix server
163-
(mamonsu zabbix item error $ZABBIX_CLIENT_HOST | grep ZBX_NOTSUPPORTED) && exit 6
163+
(mamonsu zabbix item error $ZABBIX_CLIENT_HOST | grep ZBX_NOTSUPPORTED) && exit 8
164164

165165
# other metric in zabbix server
166-
(mamonsu zabbix item lastvalue $ZABBIX_CLIENT_HOST | grep uptime) || exit 7
166+
(mamonsu zabbix item lastvalue $ZABBIX_CLIENT_HOST | grep uptime) || exit 9
167167

168168
# all plugin alive, exclude pg_wait_sampling
169-
(grep -v 'PGWAITSAMPLING' /var/log/mamonsu/agent.log | grep -i 'catch error') && exit 8
169+
(grep -v 'PGWAITSAMPLING' /var/log/mamonsu/agent.log | grep -i 'catch error') && exit 10
170170

171171
exit 0

0 commit comments

Comments
 (0)