mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
04.20.2013 c64b052d2fc60dcadbc8afcf1ef5b82b6857e512
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, include this CDDL HEADER in each
 ! file and include the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !
 !      Copyright 2008-2010 Sun Microsystems, Inc.
 !      Portions Copyright 2011-2013 ForgeRock AS
 ! -->
<project name="opends-staf-tests" basedir="../.." default="usage">
 
  <description>
    Installer ant file for the staf platform
    This allows tests that need a running instance of staf to easily
    get one and hides all the complexity under the hood
  </description>
 
 
  <!-- ################## -->
  <!-- # ANT PROPERTIES # -->
  <!-- ################## -->
 
  <!-- Display ant properties -->
  <target name="properties">
    <echoproperties/>
  </target>
 
 
  <!-- ######## -->
  <!-- # INIT # -->
  <!-- ######## -->
 
  <!-- Initialise variables -->
  <target name="global-init">
    <!-- Define project.home variable -->
    <dirname file="${basedir}/.." property="project.home"/>
 
    <!-- Default value for product.name variable -->
    <property file="${project.home}/PRODUCT"/>
    <property name="product.short.name"
      value="${SHORT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}.${POINT_VERSION}"/>
 
    <!-- Define antfile.dir variable -->
    <property name="antfile.dir" value="${basedir}/shared/ant"/>
 
    <!-- Load ant-contrib -->
    <taskdef resource="net/sf/antcontrib/antlib.xml">
      <classpath>
        <fileset dir="${project.home}/ext/ant/lib">
          <include name="*/*.jar"/>
        </fileset>
      </classpath>
    </taskdef>
 
    <!-- User environment -->
    <property environment="env"/>
 
    <!-- Check if the current platform is supported -->
    <switch value="${os.name}">
      <case value="SunOS">
        <!-- Solaris system -->
        <switch value="${os.arch}">
          <case value="sparc">
            <!-- Solaris sparc 32 bit -->
            <property name="os.myname" value="solaris-sparc"/>
          </case>
          <case value="sparcv9">
            <!-- Solaris sparc 64 bit -->
            <property name="os.myname" value="solaris-sparc64"/>
          </case>
          <case value="x86">
            <!-- Solaris x86 -->
            <property name="os.myname" value="solaris-x86"/>
          </case>
          <case value="amd64">
            <!-- Solaris amd64 -->
            <property name="os.myname" value="solaris-x64-64"/>
          </case>
        </switch>
 
        <exec executable="uname" outputproperty="host.name">
            <arg line="-n"/>
        </exec>
        <property name="extension.binary" value=""/>
        <property name="extension.shell" value=""/>
        <property name="var.path" value="PATH"/>
      </case>
      <case value="Linux">
        <!-- Linux system -->
        <switch value="${os.arch}">
          <case value="i386">
            <!-- Linux i386 -->
            <property name="os.myname" value="linux"/>
          </case>
          <case value="amd64">
            <!-- Linux amd64 -->
            <property name="os.myname" value="linux-amd64"/>
          </case>
        </switch>
 
        <exec executable="uname" outputproperty="host.name">
            <arg line="-n"/>
        </exec>
        <property name="extension.binary" value=""/>
        <property name="extension.shell" value=""/>
        <property name="var.path" value="PATH"/>
      </case>
      <case value="Mac OS X">
        <!-- MacOSX system -->
        <switch value="${os.arch}">
          <case value="x86_64">
            <!-- Linux i386 -->
            <property name="os.myname" value="macosx-universal"/>
          </case>
        </switch>
 
        <exec executable="uname" outputproperty="host.name">
            <arg line="-n"/>
        </exec>
        <property name="extension.binary" value=""/>
        <property name="extension.shell" value=""/>
        <property name="var.path" value="PATH"/>
      </case>
      <default>
        <osfamily property="os.family"/>
        <if>
          <equals arg1="${os.family}" arg2="windows"/>
          <then>
            <!-- Windows system -->
            <property name="os.myname" value="win32"/>
 
            <property name="host.name" value="${env.COMPUTERNAME}"/>
            <property name="extension.binary" value=".exe"/>
            <property name="extension.shell" value=".bat"/>
            <property name="var.path" value="Path"/>
          </then>
          <else>
            <fail>"Unsupported platform. ${os.name} - ${os.arch}"</fail>
          </else>
        </if>
      </default>
    </switch>
    
    <!-- Define tmp.dir variable -->
    <property name="tmp.dir" value="${java.io.tmpdir}/temp_files/${host.name}"/>
    
    <!-- Default value for staf.type -->
    <if>
      <not>
        <isset property="staf.type"/>
      </not>
      <then>
        <property name="staf.type" value="controller"/>
      </then>
    </if>
 
    <!-- Default value for tests.type -->
    <if>
      <not>
        <isset property="tests.type"/>
      </not>
      <then>
        <property name="tests.type" value="functional-tests"/>
      </then>
    </if>
 
    <!-- Default values for build environment -->
    <property file="${antfile.dir}/build.properties"/>
 
    <!-- User-defined values -->
    <if>
      <available file="${basedir}/user.properties"/>
      <then>
        <var file="${basedir}/user.properties"/>
      </then>
    </if>
 
    <!-- Tests-defined values -->
    <if>
      <available file="${env.CONFIG_FILE}"/>
      <then>
        <var file="${env.CONFIG_FILE}"/>
      </then>
      <else>
        <if>
          <available file="${basedir}/${tests.type}-${local.hostname}.properties"/>
          <then>
            <var file="${basedir}/${tests.type}-${local.hostname}.properties"/>
          </then>
        </if>
      </else>
    </if>
 
    <!-- Set value for tests.config.file variable depending on tests.mode -->
    <if>
      <equals arg1="${tests.mode}" arg2="remote"/>
      <then>
        <property name="tests.config.file" value="config-${local.hostname}-${remote.hostname}.py"/>
      </then>
      <else>
        <property name="tests.config.file" value="config-${local.hostname}.py"/>
      </else>
    </if>
 
    <!-- Set value for email.subject variable depending on tests.type -->
    <if>
      <equals arg1="${tests.type}" arg2="functional-tests"/>
      <then>
        <property name="email.subject"
        value="Functional tests: ${opends.name} ${remote.hostname} ${tests.os.string} ${tests.jvm.string}"/>
      </then>
      <else>
        <property name="email.subject"
        value="Stress tests: ${opends.name} ${remote.hostname} ${tests.os.string} ${tests.jvm.string}"/>
      </else>
    </if>
 
    <!-- Set value for variables which depends on user configuration -->
    <var name="staf.name" value="STAF-v${staf.version}-${os.myname}"/>
    <var name="staf.install.dir" value="${repository.dir}/install"/>
    <var name="staf.config.dir" value="${repository.dir}/configs"/>
    <var name="staf.config.file" value="${staf.config.dir}/staf-${staf.type}-${host.name}.cfg"/>
    <var name="staf.bin.dir" value="${staf.install.dir}/${staf.name}/bin"/>
    <var name="staf.daemon" value="${staf.bin.dir}/STAFProc${extension.binary}"/>
    <var name="staf.executable" value="${staf.bin.dir}/STAF${extension.binary}"/>
 
    <var name="archives.dir" value="${repository.dir}/archives"/>
    <var name="tests.run.dir" value="${logs.dir}"/>
 
    <if>
      <equals arg1="${os.family}" arg2="windows"/>
      <then>
        <!-- Windows system -->
        <property name="staf.archive"
                  value="STAF${staf.version}-setup-${os.myname}.exe"/>
        <property name="staf.lib.dir" value="${staf.install.dir}/${staf.name}/bin"/>
      </then>
      <else>
        <!-- Other systems -->
        <property name="staf.archive"
                  value="STAF${staf.version}-${os.myname}.tar.gz"/>
        <property name="staf.lib.dir" value="${staf.install.dir}/${staf.name}/lib"/>
      </else>
    </if>
    <var name="stax.name" value="STAX-v${stax.version}"/>
    <var name="stax.archive" value="STAXV${stax.version}.zip"/>
    <var name="email.name" value="Email-v${email.version}"/>
    <var name="email.archive" value="EmailV${email.version}.zip"/>
    <var name="event.name" value="Event-v${event.version}"/>
    <var name="event.archive" value="EventV${event.version}.zip"/>
    <var name="eventmanager.name" value="EventManager-v${eventmanager.version}"/>
    <var name="eventmanager.archive" value="EventManagerV${eventmanager.version}.zip"/>
    <var name="http.name" value="HTTP-v${http.version}"/>
    <var name="http.archive" value="HTTPV${http.version}.zip"/>
    <var name="tomcat.url" value="http://archive.apache.org/dist/tomcat/tomcat-6/v${tomcat.version}/bin"/>
    <var name="tomcat.archive" value="apache-tomcat-${tomcat.version}.zip"/>
    <var name="glassfish.url" value="http://download.java.net/glassfish/${glassfish.version}/release"/>
    <var name="glassfish.archive" value="glassfish-${glassfish.version}.zip"/>
    <var name="sunwebserver.archive" value="sjsws-${sunwebserver.version}-${os.myname}.zip"/>
 
    <switch value="${wc.type}">
      <case value="glassfish">
        <!-- Glassfish webcontainer -->
        <var name="wc.url" value="${glassfish.url}"/>
        <var name="wc.archive" value="${glassfish.archive}"/>
        <var name="wc.version" value="${glassfish.version}"/>
      </case>
      <case value="sunwebserver">
        <!-- SunWebserver webcontainer -->
        <var name="wc.url" value="${sunwebserver.url}"/>
        <var name="wc.archive" value="${sunwebserver.archive}"/>
        <var name="wc.version" value="${sunwebserver.version}"/>
      </case>
      <default>
        <!-- Tomcat webcontainer -->
        <var name="wc.url" value="${tomcat.url}"/>
        <var name="wc.archive" value="${tomcat.archive}"/>
        <var name="wc.version" value="${tomcat.version}"/>
      </default>
    </switch>
 
 
  </target>
 
  <!-- ######### -->
  <!-- # USAGE # -->
  <!-- ######### -->
 
  <!-- Display usage -->
  <target name="usage"
          depends="global-init">
    <ant antfile="${antfile.dir}/usage.xml" target="usage"/>
  </target>
 
 
  <!-- ############# -->
  <!-- # CONFIGURE # -->
  <!-- ############# -->
 
  <!-- Configure user variables -->
  <target name="user-configure"
          depends="global-init">
    <ant antfile="${antfile.dir}/user.xml" target="configure"/>
  </target>
 
  <!-- ######### -->
  <!-- # PROXY # -->
  <!-- ######### -->
 
  <!-- Check proxy -->
  <target name="proxy-check"
          depends="global-init">
    <ant antfile="${antfile.dir}/proxy.xml" target="check"/>
  </target>
 
  <!-- Set proxy -->
  <target name="proxy-set"
          depends="global-init,proxy-check">
    <ant antfile="${antfile.dir}/proxy.xml" target="set"/>
  </target>
 
 
  <!-- ############ -->
  <!-- # DOWNLOAD # -->
  <!-- ############ -->
 
  <!-- Download dependencies -->
  <target name="dependencies-download"
          depends="global-init,proxy-set">
    <ant antfile="${antfile.dir}/dependencies.xml" target="download"/>
  </target>
 
  <!-- Remove current dependencies -->
  <target name="dependencies-remove"
          depends="global-init">
    <ant antfile="${antfile.dir}/dependencies.xml" target="remove"/>
  </target>
 
  <!-- Remove old dependencies -->
  <target name="dependencies-removeold"
          depends="global-init">
    <ant antfile="${antfile.dir}/dependencies.xml" target="removeold"/>
  </target>
 
  <!-- Remove all dependencies -->
  <target name="dependencies-removeall"
          depends="global-init">
    <ant antfile="${antfile.dir}/dependencies.xml" target="removeall"/>
  </target>
 
 
  <!-- ######## -->
  <!-- # STAF # -->
  <!-- ######## -->
 
  <target name="set-controller-type">
    <property name="staf.type" value="controller"/>
  </target>
 
  <target name="set-slave-type">
    <property name="staf.type" value="slave"/>
  </target>
 
  <!-- Install STAF and STAF services -->
  <target name="staf-install"
          depends="global-init,dependencies-download">
    <ant antfile="${antfile.dir}/staf.xml" target="install"/>
  </target>
 
  <!-- Uninstall STAF and STAF services -->
  <target name="staf-uninstall"
          depends="global-init,staf-stop">
    <ant antfile="${antfile.dir}/staf.xml" target="uninstall"/>
  </target>
 
  <!-- Start STAF -->
  <target name="staf-start">
    <antcall target="staf-controller-start"/>
  </target>
 
  <target name="staf-controller-start"
          depends="set-controller-type,global-init,staf-install">
    <var name="staf.type" value="controller"/>
    <ant antfile="${antfile.dir}/staf.xml" target="start"/>
  </target>
 
  <target name="staf-slave-start"
          depends="set-slave-type,global-init,staf-install">
    <var name="staf.type" value="slave"/>
    <ant antfile="${antfile.dir}/staf.xml" target="start"/>
  </target>
 
  <!-- Stop STAF -->
  <target name="staf-stop"
          depends="global-init">
    <ant antfile="${antfile.dir}/staf.xml" target="stop"/>
  </target>
 
  <!-- Status STAF -->
  <target name="staf-status"
          depends="global-init">
    <ant antfile="${antfile.dir}/staf.xml" target="status"/>
  </target>
 
   <!-- Start STAF GUI -->
  <target name="staf-gui"
          depends="global-init,staf-start">
    <ant antfile="${antfile.dir}/staf.xml" target="gui"/>
  </target>
 
  <!-- Display STAF JVM logs -->
  <target name="staf-jvmlogs"
          depends="global-init,staf-start">
    <ant antfile="${antfile.dir}/staf.xml" target="jvmlogs"/>
  </target>
 
 
  <!-- ######### -->
  <!-- # TESTS # -->
  <!-- ######### -->
  <!-- generate tests specs -->
  <target name="tests-specs"
          depends="set-func-type,global-init">
    <ant antfile="${antfile.dir}/tests.xml" target="specs"/>
  </target>
 
  <target name="set-func-type">
    <property name="tests.type" value="functional-tests"/>
  </target>
 
   <target name="set-stress-type">
    <property name="tests.type" value="stress-tests"/>
  </target>
 
  <!-- Configure tests to run -->
  <target name="tests-configure">
    <antcall target="tests-func-configure"/>
  </target>
 
  <!-- Configure functional tests to run -->
  <target name="tests-func-configure"
          depends="set-func-type,global-init">
    <ant antfile="${antfile.dir}/tests.xml" target="configure"/>
  </target>
 
  <!-- Configure stress tests to run -->
  <target name="tests-stress-configure"
          depends="set-stress-type,global-init">
    <ant antfile="${antfile.dir}/tests.xml" target="configure"/>
  </target>
 
  <!-- Run tests -->
  <target name="tests-run">
    <antcall target="tests-func-run"/>
  </target>
 
  <!-- Run functional tests -->
  <target name="tests-func-run"
          depends="set-func-type,global-init,opends-build,staf-start">
    <ant antfile="${antfile.dir}/tests.xml" target="run"/>
  </target>
 
  <target name="tests-func-coverage"
          depends="set-func-type,global-init,opends-build,staf-start">
    <ant antfile="${antfile.dir}/tests.xml" target="testwithcoverage"/>
  </target>
 
  <!-- Run stress tests -->
  <target name="tests-stress-run"
          depends="set-stress-type,global-init,opends-build,staf-start">
    <ant antfile="${antfile.dir}/tests.xml" target="run"/>
  </target>
 
 
  <!-- ########## -->
  <!-- # OPENDS # -->
  <!-- ########## -->
 
  <!-- Build OpenDS zip -->
  <target name="opends-build"
          depends="global-init">
    <ant antfile="${antfile.dir}/opends.xml" target="build"/>
  </target>
</project>