forked from yabba/openx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-canoo.xml
340 lines (302 loc) · 14.6 KB
/
build-canoo.xml
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!--
This script contains the targets required to set up and run canoo web tests
on the EC2 machine.
Dependencies:
* The directory '/var/www/html/openx' on the remote EC2 machine.
Moreover, it is owned and writable by the 'admin' user.
* The '/tests/canoo/properties/user.properties' file contains a proper
EC2 configuration for canoo testing.
* The 'ec2.properties' contains the proper ec2 connection properties.
* The ssh/scp required jsch-0.1.33.jar from http://www.jcraft.com/jsch/index.html
is available for ant (e.g. in the ant's lib directory)
* For the canoo tests to work ant-contrib is required:
http://ant-contrib.sourceforge.net/
You have to put it into canoo lib directory
-->
<project name="canoo" default="run-test-canoo" basedir=".">
<property name="canoo.log" value="${basedir}/canoo.log"/>
<property name="timeout" value="60000"/>
<property name="delivery_test" value="${basedir}/www/delivery_test"/>
<property file="${basedir}/tests/canoo/tests/config/webtest.properties"/>
<property file="${basedir}/tests/canoo/tests/config/tests.properties"/>
<property name="wt.resultpath" location="results"/>
<property name="wt.resultfile" value="webtestResults.xml"/>
<property name="wt.testInWork" value="tests/canoo/tests/test_suite"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<condition property="property_file" value="user.local.properties" else="user.remote.properties">
<istrue value="${run.local}"/>
</condition>
<property file="${basedir}/tests/canoo/properties/${property_file}" prefix="canoo"/>
<property file="${basedir}/ec2.properties"/>
<property name="ec2.openx.config" value="${canoo.host}.conf.php"/>
<property name="ec2.openx.database" value="openx"/>
<import file="${wt.home}/webtest.xml" description="Import all functionalities for a full build"/>
<import file="${basedir}/tests/canoo/definitions.xml" description="Import all functionalities for a full build"/>
<macrodef name="enableMarketPlace" description="Enable or disable MarketPlace in delivery scripts before installation.">
<attribute name="enable" description="Should be MarketPlace enabled"/>
<sequential>
<if>
<istrue value="@{enable}"/>
<then>
<replace file="${basedir}/etc/dist.conf.php">
<replacetoken><![CDATA[[marketplace]
enabled=0]]></replacetoken>
<replacevalue><![CDATA[[marketplace]
enabled=1]]></replacevalue>
</replace>
</then>
<else>
<replace file="${basedir}/etc/dist.conf.php">
<replacetoken><![CDATA[[marketplace]
enabled=1]]></replacetoken>
<replacevalue><![CDATA[[marketplace]
enabled=0]]></replacevalue>
</replace>
</else>
</if>
</sequential>
</macrodef>
<macrodef name="canoo-ssh" description="Executes ssh command on the currently configured ec2 machine.">
<attribute name="command" description="Command to be executed."/>
<attribute name="username" default="admin"/>
<attribute name="password" default="${ec2.admin.password}"/>
<sequential>
<sshexec host="${canoo.host}" username="admin" password="${ec2.admin.password}" trust="yes" output="${canoo.log}" append="true" timeout="${timeout}" command="@{command}"/>
</sequential>
</macrodef>
<macrodef name="canoo-ssh-root" description="Executes ssh command on the currently configured ec2 machine.">
<attribute name="command" description="Command to be executed."/>
<sequential>
<canoo-ssh command="@{command}" username="root" password="${ec2.root.password}"/>
</sequential>
</macrodef>
<macrodef name="clean-delivery-cache-remote">
<sequential>
<canoo-ssh-root command="rm -f ${ec2.openx.dir}/var/cache/deliverycache_* ${ec2.openx.dir}/var/cache/cache_*"/>
</sequential>
</macrodef>
<macrodef name="canoo-scp" description="Copies the specified file to the ec2 machine.">
<attribute name="dir" description="Directory to copy the file to." default=""/>
<element name="files" description="Fileset to be copied."/>
<sequential>
<scp todir="admin@@${canoo.host}:@{dir}" trust="yes" password="${ec2.admin.password}">
<files/>
</scp>
</sequential>
</macrodef>
<!-- changes file permissions on plugins (located in plugins/) created during the installation -->
<target name="canoo-chmod">
<available property="fileFound" file="${basedir}/target/www/delivery_test/chmod.php" />
<if>
<istrue value="${fileFound}"/>
<then>
<replace dir="${basedir}/target/www/delivery_test" value="${basedir}/target"> <!-- /plugins -->
<include name="chmod.php"/>
<replacetoken>@path</replacetoken>
</replace>
<!--<get src="${wt.protocol}://${wt.host}:${wt.port}/${wt.basepath}/delivery_test/chmod.php" dest="/dev/null" ignoreerrors="true"/>-->
<exec executable="wget">
<arg value="${wt.protocol}://${wt.host}:${wt.port}/${wt.basepath}/delivery_test/chmod.php"/>
<arg value="--output-document=/dev/null" />
<arg value="--no-check-certificate" />
</exec>
</then>
</if>
</target>
<!-- Cleans up the old OpenX directory. -->
<target name="canoo-prepare-dir">
<property name="ec2.openx.dir" value="/var/www/html/${release}"/>
<echo message="Preparing directory: ${ec2.openx.dir}"/>
<canoo-ssh command="mkdir ${ec2.openx.dir}"/>
</target>
<target name="canoo-copy-package">
<canoo-scp>
<files>
<fileset dir="${dir.test.results}" includes="${canoo.package}"/>
</files>
</canoo-scp>
</target>
<target name="canoo-unpack-package">
<canoo-ssh command="tar xzf ${canoo.package} -C ${ec2.openx.dir}"/>
<!-- <canoo-ssh command="touch ${ec2.openx.dir}/var/INSTALLED"/> -->
<canoo-ssh command="chmod -R a+w ${ec2.openx.dir}/var"/>
<canoo-ssh command="chmod -R a+w ${ec2.openx.dir}/www/images"/>
<canoo-scp dir="${ec2.openx.dir}/www">
<files>
<fileset dir="${basedir}/tests/canoo/php/" includes="*"/>
</files>
</canoo-scp>
</target>
<!-- should be less EC2 dependant -->
<target name="canoo-create-openx-configuration-remote">
<property name="openx.url" value="${canoo.host}/${release}/www"/>
<exec dir="${basedir}/tests" executable="php" failonerror="true">
<arg value="create-config-file.php" />
<arg value="${ec2.openx.config}" />
<arg value="database.host=${canoo.host}"/>
<arg value="database.username=${canoo.sql.user}"/>
<arg value="database.password=${canoo.sql.password}"/>
<arg value="database.name=${ec2.openx.database}"/>
<arg value="debug.production=0"/>
<arg value="webpath.admin=${openx.url}/admin"/>
<arg value="webpath.delivery=${openx.url}/delivery"/>
<arg value="webpath.deliverySSL=${openx.url}/delivery"/>
<arg value="webpath.images=${openx.url}/images"/>
<arg value="webpath.imagesSSL=${openx.url}/images"/>
<arg value="openads.installed=1"/>
<arg value="table.prefix=oa_"/>
<arg value="maintenance.autoMaintenance=0"/>
</exec>
<canoo-scp dir="${ec2.openx.dir}/var">
<files>
<fileset dir="tests" includes="${ec2.openx.config}"/>
</files>
</canoo-scp>
<canoo-ssh command="rm -f ${ec2.openx.dir}/var/UPGRADE"/>
</target>
<target name="setup-delivery-files">
<copy todir="${delivery_test}" verbose="true">
<fileset dir="${basedir}/tests/canoo/php"/>
</copy>
<replace dir="${delivery_test}" value="${wt.protocol}://${wt.host}:${wt.port}/${wt.basepath}/delivery/spcjs.php?id=1&charset=UTF-8">
<include name="spcjs.html"/>
<replacetoken>@address</replacetoken>
</replace>
</target>
<target name="clean-delivery">
<delete dir="${delivery_test}" />
</target>
<macrodef name="execute-webtest" description="Executes webtest with provided target and additional properties.">
<attribute name="target" description="Target to execute."/>
<attribute name="properties" default="" description="Additional properties."/>
<sequential>
<if>
<istrue value="${run.local}"/>
<then>
<!-- run locally -->
<exec executable="${canoo.webtest.exec}" failonerror="true">
<arg line="-f ${basedir}/tests/canoo/start.xml -Drun.local=${run.local} @{target} @{properties}"/>
</exec>
</then>
<else>
<!-- run remotely -->
<exec executable="${canoo.webtest.exec}" failonerror="true">
<arg line="-f ${basedir}/tests/canoo/start.xml -Drun.local=${run.local} @{target} -Dbasepath=${release}/www @{properties}"/>
</exec>
</else>
</if>
</sequential>
</macrodef>
<target name="init.check.unix">
<condition property="is.unix">
<os family="unix" />
</condition>
</target>
<target name="init.check.windows">
<condition property="is.windows">
<os family="windows" />
</condition>
</target>
<target name="init.canoo.unix" depends="init.check.unix" if="is.unix">
<echo message="Canoo tests - init" />
<echo message="Unix setup" />
<echo message="Chmod on var and www/images directory"/>
<chmod dir="${basedir}/var" perm="a+rwx" type="dir"/>
<chmod dir="${basedir}/var" perm="a+rw" type="both" includes="**/*"/>
<chmod dir="${basedir}/www" perm="a+rwx" type="dir"/>
<chmod dir="${basedir}/www" perm="a+rw" type="both" includes="**/*" parallel="false"/>
<chmod dir="${basedir}/plugins" perm="a+rwx" type="dir"/>
<chmod dir="${basedir}/plugins" perm="a+rw" type="both" includes="**/*" parallel="true" verbose="true"/>
<!--
<chmod perm="a+rw" verbose="true"> type="both"
<dirset dir="${basedir}/plugins/*">
<include name="**"/>
</dirset>
<fileset dir="${basedir}/plugins/*">
<include name="**/*"/>
</fileset>
</chmod>
-->
<enableMarketPlace enable="${marketplace.enabled}"/>
<replace file="${basedir}/etc/dist.conf.php">
<replacefilter token="popup = false" value="popup = true"/>
<replacefilter token="adview = false" value="adview = true"/>
<replacefilter token="xmlrpc = false" value="xmlrpc = true"/>
</replace>
</target>
<target name="init.canoo.windows" depends="init.check.windows" if="is.windows">
<echo message="Canoo tests - init"/>
<echo message="Windows setup"/>
<enableMarketPlace enable="${marketplace.enabled}"/>
</target>
<target name="run-test" depends="test-unit-webService-APIv2">
<echo message="Starting test automation framework ..." />
</target>
<target name="run-test-canoo" depends="setup-delivery-files, init.canoo.unix, init.canoo.windows, wt.init, wt.defineTasks.init, customprepend, wt.full">
<!--<target name="run-test-canoo" depends="init.canoo.unix, init.canoo.windows, wt.init, wt.defineTasks.init, customprepend, wt.full">-->
<echo message="Running Canoo tests" />
</target>
<target name="customprepend">
<path id="wt.defineTasks.classpath.customPrepend">
<pathelement path="${basedir}/tests/canoo/tests/config/log-overridden"/>
<pathelement path="${basedir}/tests/canoo/tests/config/log"/>
</path>
<property name="wt.defineTasks.init.skip" value="true"/>
</target>
<target name="test-canoo-one">
<execute-webtest target="test-one" properties="-Dcanoo.host=${canoo.host} -Dec2.admin.password=${ec2.admin.password} -Dec2.openx.dir=${ec2.openx.dir} -Duc=${uc}" />
</target>
<target name="prepare-webService-API-test-config">
<echo message="Prepare configuration file for XMLRPC API unit tests" />
<copy file="${basedir}/www/api/v1/xmlrpc/tests/unit/src/test/resources/config.example.properties" tofile="${basedir}/www/api/v1/xmlrpc/tests/unit/src/test/resources/config.properties"/>
<replace file="${basedir}/www/api/v1/xmlrpc/tests/unit/src/test/resources/config.properties" value="${wt.protocol}://${wt.host}:${wt.port}/${wt.basepath}/api/v1/xmlrpc/">
<replacetoken>@serviceURL</replacetoken>
</replace>
<replace file="${basedir}/www/api/v1/xmlrpc/tests/unit/src/test/resources/config.properties" value="${admin.pass}">
<replacetoken>@password</replacetoken>
</replace>
<replace file="${basedir}/www/api/v1/xmlrpc/tests/unit/src/test/resources/config.properties" value="${admin.login}">
<replacetoken>@username</replacetoken>
</replace>
<copy file="${basedir}/www/api/v2/xmlrpc/tests/unit/src/test/resources/config.example.properties" tofile="${basedir}/www/api/v2/xmlrpc/tests/unit/src/test/resources/config.properties"/>
<replace file="${basedir}/www/api/v2/xmlrpc/tests/unit/src/test/resources/config.properties" value="${wt.protocol}://${wt.host}:${wt.port}/${wt.basepath}/api/v2/xmlrpc/">
<replacetoken>@serviceURL</replacetoken>
</replace>
<replace file="${basedir}/www/api/v2/xmlrpc/tests/unit/src/test/resources/config.properties" value="${admin.pass}">
<replacetoken>@password</replacetoken>
</replace>
<replace file="${basedir}/www/api/v2/xmlrpc/tests/unit/src/test/resources/config.properties" value="${admin.login}">
<replacetoken>@username</replacetoken>
</replace>
</target>
<target name="test-unit-webService-API" if="test.unit.xmlrpc.api" depends="run-test-canoo, prepare-webService-API-test-config">
<exec executable="${test.unit.xmlrpc.mvn.executable}" searchpath="true" failonerror="false" resultproperty="test.unit.v1.xmlrpc.mvn.result" dir="${basedir}/www/api/v1/xmlrpc/tests/unit/">
<env key="MAVEN_TERMINATE_CMD" value="on" />
<arg line="clean test" />
</exec>
<condition property="api.v1.has.failed">
<equals arg1="0" arg2="${test.unit.v1.xmlrpc.mvn.result}" />
</condition>
<exec executable="${test.unit.xmlrpc.mvn.executable}" searchpath="true" dir="${basedir}/www/api/v1/xmlrpc/tests/unit/">
<arg line="${test.unit.xmlrpc.mvn.params} surefire-report:report-only" />
</exec>
<fail unless="api.v1.has.failed" message="[ERROR] There are test failures/errors in XMLRPC unit tests. Maven result code ${test.unit.v1.xmlrpc.mvn.result}"/>
</target>
<target name="test-unit-webService-APIv2" if="test.unit.xmlrpc.api" depends="test-unit-webService-API">
<exec executable="${test.unit.xmlrpc.mvn.executable}" searchpath="true" failonerror="false" resultproperty="test.unit.v2.xmlrpc.mvn.result" dir="${basedir}/www/api/v2/xmlrpc/tests/unit/">
<env key="MAVEN_TERMINATE_CMD" value="on" />
<arg line="clean test" />
</exec>
<condition property="api.v2.has.failed">
<equals arg1="0" arg2="${test.unit.v2.xmlrpc.mvn.result}" />
</condition>
<exec executable="${test.unit.xmlrpc.mvn.executable}" searchpath="true" dir="${basedir}/www/api/v2/xmlrpc/tests/unit/">
<arg line="${test.unit.xmlrpc.mvn.params} surefire-report:report-only" />
</exec>
<fail unless="api.v2.has.failed" message="[ERROR] There are test failures/errors in XMLRPC v2 unit tests. Maven result code ${test.unit.v2.xmlrpc.mvn.result}"/>
</target>
<target name="clean-ec2" description="Cleans the ec2 from all the files left.">
<canoo-ssh command="rm ${canoo.package}"/>
<canoo-ssh-root command="rm -rf ${ec2.openx.dir}"/>
</target>
</project>