Skip to content

Commit 980e42d

Browse files
author
alexander popov
committed
tests
1 parent bfface9 commit 980e42d

File tree

8 files changed

+89
-8
lines changed

8 files changed

+89
-8
lines changed

Makefile.tests

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ run_builds:
77
run_functional_tests:
88
docker run -v "$(WORKDIR)":/var/tmp centos:7 /bin/bash -ex "/var/tmp/tests/check.sh"
99

10-
local_test:local_test_prepare run_local_test_pg9.5 run_local_test_pg9.6 run_local_test_pg10 run_local_test_pg11 run_local_test_pg12 run_local_test_pg13
10+
local_test:clean_local_tests local_test_prepare run_local_test_pg9.5 run_local_test_pg9.6 run_local_test_pg10 run_local_test_pg11 run_local_test_pg12 run_local_test_pg13
1111

12-
clean_local_tests: clean_zabbix clean_local_test_pg9.5 clean_local_test_pg9.6 clean_local_test_pg10 clean_local_test_pg11 clean_local_test_pg12 clean_local_test_pg13
12+
clean_local_tests: clean_local_test_pg9.5 clean_local_test_pg9.6 clean_local_test_pg10 clean_local_test_pg11 clean_local_test_pg12 clean_local_test_pg13 clean_zabbix
1313

1414
local_test_prepare: clean_zabbix
1515
docker network create --driver=bridge --subnet=172.18.0.0/16 network-local-tests

tests/local_install_mamonsu.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ cd /var/tmp/mamonsu
88
python3 setup.py build
99
python3 setup.py install
1010

11+
mkdir -p /etc/mamonsu
12+
touch /etc/mamonsu/agent.conf
13+
14+
mkdir -p /var/log/mamonsu
15+
touch /var/log/mamonsu/agent.log
1116
exit 0

tests/local_tests.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
#!/bin/bash -ex
22

33
/var/tmp/mamonsu/tests/local_install_mamonsu.sh
4-
/var/tmp/mamonsu/tests/bootstrap.sh
4+
5+
###### test mamonsu report *
6+
/var/tmp/mamonsu/tests/tests/report.sh
7+
8+
###### test mamonsu agent *
9+
/var/tmp/mamonsu/tests/tests/agent.sh
10+
11+
###### test mamonsu bootstrap *
12+
/var/tmp/mamonsu/tests/tests/bootstrap.sh
513

614
###### test mamonsu zabbix *
7-
mkdir /etc/mamonsu/
15+
mkdir -p /etc/mamonsu/
816
cp /var/tmp/mamonsu/packaging/conf/example.conf /etc/mamonsu/agent.conf
917
#ZABBIX_DOCKER_VERSIONS="5.2 5.0 4.4 4.2 4.0 3.4 3.2 3.0"
1018
ZABBIX_DOCKER_VERSIONS="5.2 5.0 4.4 4.2 4.0 3.2 3.0"
@@ -27,7 +35,7 @@ do
2735
Z_USER=$Z_USER
2836
Z_PASSWORD=$Z_PASSWORD
2937
Z_VERSION=$Z_VERSION"
30-
/var/tmp/mamonsu/tests/zabbix.sh
38+
/var/tmp/mamonsu/tests/tests/zabbix.sh
3139
done
3240

3341
exit 0

tests/tests/agent.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash -ex
2+
3+
4+
# тест команд mamonsu agent *
5+
6+
# Требования:
7+
# нет
8+
9+
mkdir -p /etc/mamonsu
10+
11+
cat <<EOF > /etc/mamonsu/agent.conf
12+
[postgres]
13+
host = 127.0.0.1
14+
user = mamonsu_agent
15+
database = mamonsu_agent
16+
password = supersecret
17+
18+
[zabbix]
19+
enabled = False
20+
21+
22+
[agent]
23+
enabled = True
24+
host = 127.0.0.1
25+
port = 10053
26+
27+
[metric_log]
28+
enabled = True
29+
directory = /tmp
30+
31+
[log]
32+
file = /var/log/mamonsu/agent.log
33+
level = DEBUG
34+
35+
EOF
36+
37+
38+
mamonsu &
39+
sleep 1
40+
41+
mamonsu agent version
42+
mamonsu agent metric-get system.disk.all_read[]
43+
mamonsu agent metric-list
44+
45+
mamonsu agent -c /etc/mamonsu/agent.conf version
46+
mamonsu agent metric-get system.disk.all_read[] -c /etc/mamonsu/agent.conf
47+
mamonsu agent -c /etc/mamonsu/agent.conf metric-list
48+
49+
exit 0

tests/tests/bootstrap.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash -ex
22

3-
# bootstrap test
3+
# тест команд mamonsu bootstrap *
4+
45
# Требования:
56
# запуск psql от пользователя postgres psql -U postgres
67
# в pg_hba долвны быть разрешения для всех пользователей trust
@@ -56,7 +57,7 @@ function check_db_objects() {
5657
$PSQL $DB -c "\df mamonsu_get_oldest_transaction" | grep "mamonsu_get_oldest_transaction" || exit 11
5758
echo "WALXLOG $WALXLOG"
5859
$PSQL $DB -c "\df mamonsu_count_"$WALXLOG"_files" | grep "mamonsu_count_"$WALXLOG"_files" || exit 11
59-
$PSQL $DB -c "\df mamonsu_buffer_cache" | grep "mamonsu_buffer_cache" || exit 11
60+
#$PSQL $DB -c "\df mamonsu_buffer_cache" | grep "mamonsu_buffer_cache" || exit 11
6061
$PSQL $DB -c "\df mamonsu_archive_command_files" | grep "mamonsu_archive_command_files" || exit 11
6162
$PSQL $DB -c "\df mamonsu_archive_stat" | grep "mamonsu_archive_stat" || exit 11
6263
$PSQL $DB -c "\df mamonsu_get_sys_param" | grep "mamonsu_get_sys_param" || exit 11

tests/tests/readme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# в данной дирректории содержатся готовые скрипты с тестами

tests/tests/report.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash -ex
2+
3+
4+
# тест команд mamonsu report *
5+
6+
# Требования:
7+
# нет
8+
9+
mamonsu report
10+
mamonsu report --port 5433
11+
mamonsu report --run-system=false
12+
mamonsu report --run-postgres=false
13+
mamonsu report --disable-sudo
14+
mamonsu report -w rep1.txt
15+
mamonsu report --report-path=rep2.txt
16+

tests/tests/zabbix.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash -ex
22

3-
# тест команд /mamonsu zabbix *
3+
# тест команд mamonsu zabbix *
4+
45
# Требования:
56
# наличие запущенного zabbix сервера и прописанные переменные окружения: Z_URL Z_USER Z_PASSWORD, Z_MAJOR_VERSION
67
# todo change and remove

0 commit comments

Comments
 (0)