-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathREADME
129 lines (89 loc) · 4.3 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Basic set up for the test
--------------------------
(1) setup MySQL.
$ mysql -u root < ../../data/test/setup.sql
(2) Setup RabbitMQ
See also 'How to start' section in ../README.md (server/README.md)
In addition, you need to add an user and a virtual host of RabbitMQ:
$ sudo -u rabbitmq -H /usr/sbin/rabbitmqctl add_user hatohol hatohol
$ sudo -u rabbitmq -H /usr/sbin/rabbitmqctl add_vhost hatohol
$ sudo -u rabbitmq -H /usr/sbin/rabbitmqctl set_permissions -p hatohol hatohol '^test\..*' '.*' '.*'
(3) Remove or disable 'apport' if it's installed.
The details are written in the later part of this document.
(4) Run tests
You can run tests by the following command:
$ ./run-test.sh
To suppress Hatohol's verbose log, adding MLPL_LOGGER_LEVEL=WARN is recommended:
$ MLPL_LOGGER_LEVEL=WARN ./run-test.sh
If you want to enable tests concerned with RabbitMQ (HAPI JSON and HAPI2.0),
please specify the URL of it by TEST_AMQP_URL:
$ TEST_AMQP_URL="amqp://hatohol:hatohol@localhost:5672/hatohol" ./run-test.sh
## Hint
See also .travis.yml in the top directory, which contains proceudure
to build Hatohol and run tests for TravisCI.
Speed-up technique of the test
------------------------------
(1) HATOHOL_MYSQL_ENGINE_MEMORY=1
The above setting request MySQL to use a heap (memory) storage engine.
It has effect only for DBAgentMySQL and the related classes.
This way is a little slower than the way (2). However, this is easier,
because no other settings are needed.
When this environment variable is set, the test case:
testArmZabbixAPI::test_getEventsBySplitWay needs about several hundred MB
of heap memory, although the MySQL's default maximum heap size is 16MB.
So the parameters should be changed by editing my.conf.
[mysqld]
max_heap_table_size = 512M
(2) Put the DB of MySQL on tmpfs
This way is faster than that of (1). However, it affects all
applications using MySQL. So you should use a virtual machine or
environment such as LXC or KVM. Container based ways such as LXC are
recommended because degradation of I/O performance of them is less than that
of fully virtualization ways.
2-1: Edit /etc/mysql/my.cnf like
- datadir = /var/lib/mysql
+ datadir = /dev/shm/mysql
2-2: Probably you need to execute the following command.
$ mysql_install_db
2-3: Install the DB for NDOUtils
If you already ndoutils for NDOUtils, you can copy by the mysqldump command.
mysqldump -u root ndoutils > ndoutils.sql (do before 2-1)
mysqldump -u root ndoutils < ndoutils.sql (do after 2-2)
### You can use any combination of the above ways. For example,
$ HATOHOL_MYSQL_ENGINE_MEMORY=1 ./run-test.sh
[Ref.]
In my evironment (Core i7 860 + Mem 12GB + SATA HDD),
they drastically improve the test speed.
1033 sec. ->
264 sec. (HATOHOL_MYSQL_ENGINE_MEMORY=1)
28 sec. (with all the above ways)
How to show the stack trace on an HatoholException
-------------------------------------------------
Set the environment variable like
$ HATOHOL_EXCEPTION_STACK_TRACE=1 ./run-test.sh
Hint: fix an error: accessing to ndoutils on MySQL
--------------------------------------------------
The DB for ndoutils is created when NDOUtils package is installed.
However, there're some situations in which the installation of the package is
not prefered. In this case, the following steps can be used to pass the test.
$ mysql -u root -e "CREATE DATABASE ndoutils;"
$ mysql -u root ndoutils < ../misc/ndoutils.mysql
$ mysql -u root -e "GRANT all on ndoutils.* TO ndoutils@localhost IDENTIFIED BY 'admin';"
Hint: fix an error: expeted failure code is diffrent on some tests
------------------------------------------------------------------
Some tests for ActionManager fails due to the following reason.
Failure: testActionManager::test_execCommandActionCrashSoon
<failureCode == actionLog.failureCode>
expected: <13>
actual: <14>
The reason may be due to the content of /proc/sys/kernel/core_pattern.
Some distribution (such as Ubuntu 13.10, 14.04) sets it to a command that
calls 'apport' like,
$ cat /proc/sys/kernel/core_pattern
|/usr/share/apport/apport %p %s %c %P
It can be fixed by setting a normal string such as 'core' or
removing the apport package.
How to use a specified port for MySQLWorker
-------------------------------------------
Ex.) port 8006
$ TEST_MYSQL_PORT=8006 ./run-test.sh -t /testMySQLWorkerZabbix/