blob: a66b44b7f1bd5871ea702bdf299190aaba32a36c (
plain)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
<?xml version="1.0" encoding="UTF-8"?>
<project name="Zabbix" default="build" basedir=".">
<target name="init-common">
<!-- Delete build directories from the previous run -->
<delete dir="build/logs" failonerror="off"/>
<!-- Create the different build directories -->
<mkdir dir="build/logs"/>
</target>
<target name="create-configs" depends="init-common">
<property name="url" value="${URL}"/>
<property name="dbtype" value="${DBTYPE}"/>
<property name="dbhost" value="${DBHOST}"/>
<property name="dbname" value="${DBNAME}"/>
<property name="dbuser" value="${DBUSER}"/>
<property name="dbpassword" value="${DBPASSWORD}"/>
<property name="phpunit_error_log" value="${PHPUNIT_ERROR_LOG}"/>
<property environment="env"/>
<!-- Create bootstrap.php -->
<copy overwrite="true" file="frontends/php/tests/bootstrap.php.template" tofile="frontends/php/tests/bootstrap.php"/>
<replace file="frontends/php/tests/bootstrap.php" token="{URL}" value="${env.WORKSPACE_URL}${url}"/>
<replace file="frontends/php/tests/bootstrap.php" token="{BASEDIR}" value="${basedir}"/>
<replace file="frontends/php/tests/bootstrap.php" token="{SCREENSHOT_DIR}" value="${env.SCREENSHOT_DIR}"/>
<replace file="frontends/php/tests/bootstrap.php" token="{SCREENSHOT_URL}" value="${env.SCREENSHOT_URL}"/>
<!-- Create PHP config file -->
<copy overwrite="true" file="frontends/php/tests/templates/zabbix.conf.php" tofile="frontends/php/conf/zabbix.conf.php"/>
<replace file="frontends/php/conf/zabbix.conf.php" token="{DBTYPE}" value="${dbtype}"/>
<replace file="frontends/php/conf/zabbix.conf.php" token="{DBHOST}" value="${dbhost}"/>
<replace file="frontends/php/conf/zabbix.conf.php" token="{DBNAME}" value="${dbname}"/>
<replace file="frontends/php/conf/zabbix.conf.php" token="{DBUSER}" value="${dbuser}"/>
<replace file="frontends/php/conf/zabbix.conf.php" token="{DBPASSWORD}" value="${dbpassword}"/>
<replace file="frontends/php/conf/zabbix.conf.php" token="{PHPUNIT_ERROR_LOG}" value="${phpunit_error_log}"/>
</target>
<target name="make-dbschema">
<!-- Create database schema -->
<exec executable="./bootstrap.sh" failonerror="on"></exec>
<exec executable="./configure" failonerror="on"></exec>
<exec executable="make" failonerror="on">
<arg line="-s"/>
<arg line="dbschema"/>
</exec>
</target>
<target name="init-postgresql" depends="create-configs,make-dbschema">
<!-- Create PostgreSQL database -->
<exec executable="psql" failonerror="on">
<env key="PGPASSWORD" value="${dbpassword}"/>
<arg line="-h '${dbhost}'"/>
<arg line="-U '${dbuser}'"/>
<arg line="-1"/>
<arg line="--set ON_ERROR_STOP=1"/>
<arg line="-c 'drop database if exists ${dbname}'"/>
</exec>
<exec executable="psql" failonerror="on">
<env key="PGPASSWORD" value="${dbpassword}"/>
<arg line="-h '${dbhost}'"/>
<arg line="-U '${dbuser}'"/>
<arg line="-1"/>
<arg line="--set ON_ERROR_STOP=1"/>
<arg line="-c 'create database ${dbname}'"/>
</exec>
<exec executable="psql" input="database/postgresql/schema.sql" failonerror="on">
<env key="PGPASSWORD" value="${dbpassword}"/>
<arg line="-h '${dbhost}'"/>
<arg line="-U '${dbuser}'"/>
<arg line="-1"/>
<arg line="--set ON_ERROR_STOP=1"/>
<arg line="${dbname}"/>
</exec>
<exec executable="psql" input="database/postgresql/images.sql" failonerror="on">
<env key="PGPASSWORD" value="${dbpassword}"/>
<arg line="-h '${dbhost}'"/>
<arg line="-U '${dbuser}'"/>
<arg line="-1"/>
<arg line="--set ON_ERROR_STOP=1"/>
<arg line="${dbname}"/>
</exec>
<exec executable="psql" input="database/postgresql/data.sql" failonerror="on">
<env key="PGPASSWORD" value="${dbpassword}"/>
<arg line="-h '${dbhost}'"/>
<arg line="-U '${dbuser}'"/>
<arg line="-1"/>
<arg line="--set ON_ERROR_STOP=1"/>
<arg line="${dbname}"/>
</exec>
</target>
<target name="init-frontend-postgresql" depends="init-postgresql">
<exec executable="psql" input="frontends/php/tests/selenium/data/data_test.sql" failonerror="on">
<env key="PGPASSWORD" value="${dbpassword}"/>
<arg line="-h '${dbhost}'"/>
<arg line="-U '${dbuser}'"/>
<arg line="-1"/>
<arg line="--set ON_ERROR_STOP=1"/>
<arg line="${dbname}"/>
</exec>
</target>
<target name="init-api-postgresql" depends="init-postgresql">
<exec executable="psql" input="frontends/php/tests/api_json/data/data_test.sql" failonerror="on">
<env key="PGPASSWORD" value="${dbpassword}"/>
<arg line="-h '${dbhost}'"/>
<arg line="-U '${dbuser}'"/>
<arg line="-1"/>
<arg line="--set ON_ERROR_STOP=1"/>
<arg line="${dbname}"/>
</exec>
</target>
<target name="init-mysql" depends="create-configs,make-dbschema">
<!-- Create MySQL database -->
<exec executable="mysql" failonerror="on">
<arg line="--host=${dbhost}"/>
<arg line="--user=${dbuser}"/>
<arg line="--password=${dbpassword}"/>
<arg line="--execute='drop database if exists ${dbname}'"/>
</exec>
<exec executable="mysql" failonerror="on">
<arg line="--host=${dbhost}"/>
<arg line="--user=${dbuser}"/>
<arg line="--password=${dbpassword}"/>
<arg line="--execute='create database ${dbname} character set utf8 collate utf8_bin'"/>
</exec>
<exec executable="mysql" input="database/mysql/schema.sql" failonerror="on">
<arg line="--host=${dbhost}"/>
<arg line="--user=${dbuser}"/>
<arg line="--password=${dbpassword}"/>
<arg line="${dbname}"/>
</exec>
<exec executable="mysql" input="database/mysql/images.sql" failonerror="on">
<arg line="--host=${dbhost}"/>
<arg line="--user=${dbuser}"/>
<arg line="--password=${dbpassword}"/>
<arg line="${dbname}"/>
</exec>
<exec executable="mysql" input="database/mysql/data.sql" failonerror="on">
<arg line="--host=${dbhost}"/>
<arg line="--user=${dbuser}"/>
<arg line="--password=${dbpassword}"/>
<arg line="${dbname}"/>
</exec>
</target>
<target name="init-frontend-mysql" depends="init-mysql">
<exec executable="mysql" input="frontends/php/tests/selenium/data/data_test.sql" failonerror="on">
<arg line="--host=${dbhost}"/>
<arg line="--user=${dbuser}"/>
<arg line="--password=${dbpassword}"/>
<arg line="${dbname}"/>
</exec>
</target>
<target name="init-api-mysql" depends="init-mysql">
<exec executable="mysql" input="frontends/php/tests/api_json/data/data_test.sql" failonerror="on">
<arg line="--host=${dbhost}"/>
<arg line="--user=${dbuser}"/>
<arg line="--password=${dbpassword}"/>
<arg line="${dbname}"/>
</exec>
</target>
<target name="test-phpunit" depends="init-common">
<exec executable="phpunit" dir="frontends/php/tests/unit" failonerror="off">
<arg line="--log-junit=${basedir}/build/logs/phpunit.xml"/>
<arg line="include/"/>
</exec>
</target>
<target name="test-frontend">
<exec executable="phpunit" dir="frontends/php/tests" failonerror="off">
<arg line="--log-junit=${basedir}/build/logs/phpunit.xml --bootstrap=bootstrap.php frontend.php"/>
</exec>
</target>
<target name="test-api">
<exec executable="phpunit" dir="frontends/php/tests" failonerror="off">
<arg line="--log-junit=${basedir}/build/logs/phpunit.xml --bootstrap=bootstrap.php api_json/ApiJsonTests.php"/>
</exec>
</target>
<target name="build-phpunit" depends="test-phpunit"/>
<target name="build-mysql" depends="init-frontend-mysql,test-frontend"/>
<target name="build-postgresql" depends="init-frontend-postgresql,test-frontend"/>
<target name="build-api-mysql" depends="init-api-mysql,test-api"/>
<target name="build-api-postgresql" depends="init-api-postgresql,test-api"/>
<!-- Default target -->
<target name="build" depends="build-phpunit,build-mysql,build-postgresql"/>
</project>
|