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

gary_williams
16.19.2006 4eccd20d1f132abc562fb04c8ef11dd2a4975775
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
<!--
 ! 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
 !
 !
 !      Portions Copyright 2006 Sun Microsystems, Inc.
 ! -->
 
<project name="opends-tests-integration" basedir="." default="all">
  <description>
    This is the build script for the functional tests for the 
    OpenDS Directory Server.  See the
    BUILDING file in this directory for build instructions.
  </description>
 
  <!-- generate the timestamp we'll use to tag/store the test results       -->
  <tstamp>
    <format property="run.time" pattern="yyyy.MM.dd-HH.mm.ss"                />
  </tstamp>
  
  <!-- General build-wide properties                                        -->
  <property name="opends.dir"       location="../.."                         />
  <property name="tests.src.dir"    location="src/server"                    />
  <property name="tests.build.dir"     
            location="${opends.dir}/build/integration-tests"                 />
  <property name="tests.classes"
            location="${tests.build.dir}/classes"                            />
  <property name="tests.run.dir"    
            location="${tests.build.dir}/run/${run.time}"                    />
  
  <property name="lib.dir"          location="${opends.dir}/lib"             />
  <property name="ext.dir"          location="${opends.dir}/ext"             />
  <property name="testng.dir"       location="${ext.dir}/testng"             />
  <property name="testng.lib.dir"   location="${testng.dir}/lib"             />
 
  <property name="opends.build.dir"   location="${opends.dir}/build"         />
  <property name="opends.package.dir" location="${opends.build.dir}/package" />
  <property name="opends.classes"     location="${opends.build.dir}/classes" />
  <property name="opends.src"         location="${opends.dir}/src/server"    />
 
  <!-- product values for opends -->
  <property name="product.version"     value="0.1"                           />
  <property name="product.name"        value="OpenDS"                        />
  
  <!-- Properties for code coverage -->
  <property name="emma.lib.dir" value="${ext.dir}/emma/lib"                  />
  <property name="opends.coverage.dir" 
            location="${opends.build.dir}/coverage"                          />
  <property name="coverage.instr.dir"
       location="${opends.coverage.dir}/instrumentedcode"                    />
  <property name="coverage.data.dir"
       location="${opends.coverage.dir}/gathereddata"                        />
  <property name="coverage.report.dir"
            location="${opends.coverage.dir}/reports"                        />
  <property name="integration.coverage.report.dir" 
            location="${coverage.report.dir}/integration"                    />
  <property name="global.coverage.report.dir"
            location="${coverage.report.dir}/global"                         />
 
  <!-- assertion to determine the operating system -->
  <condition property="isWindows">
    <os family="windows"/>
  </condition>
  <condition property="isUnix">
    <not>
      <os family="windows"/>
    </not>
  </condition>
  
  <!-- integration-tests.properties ...
      edit or create this file if you need custom port or install path
       it can have any of the following properties
       port.ldap
       port.ssl
       install.dir
       host.name
       bindDN
       password
       
       see set-default-props target for default values
  -->
  <property file="integration-tests.properties"                              />
 
  <target name="set-default-props"
          description="defines the default values if no custom values were provided">
    <property name="install.dir" value="${tests.build.dir}/install"          />
    <property name="port.ldap"   value="1389"                                />
    <property name="port.ssl"    value="1636"                                />
    <property name="host.name"   value="localhost"                           />
    <property name="bindDN"      value="cn=Directory Manager"                />
    <property name="password"    value="password"                            />
    <property name="full.install.dir" 
            value="${install.dir}/${product.name}-${product.version}"        />
    <property name="MEM" value="128M"                                        />
  </target>
  
  <!-- this is a private target that checks for emma instrumented opends 
       classes 
  -->
  <target name="check-opends-instrumentation">
    <available file="${coverage.instr.dir}/org/opends/server" 
              type="dir" 
              property="is-opends-instrumented" 
              value="true"                                     />
  </target>
  
  <target name="coverage" 
          if="is-opends-instrumented"
          depends="check-opends-instrumentation"
          description="initialize emma">
    <echo message="Found opends emma instrumentation, configuring emma to gather code coverage during integration tests run"/>
    <mkdir dir="${coverage.data.dir}"               />
    <mkdir dir="${coverage.report.dir}"             />
    <mkdir dir="${global.coverage.report.dir}"      />
    <mkdir dir="${integration.coverage.report.dir}" />
  </target>
  
  <target name="init"
          description="initialize properties and create directories to allow for the integration tests to run succesfully"
          depends="set-default-props">
    <path id="emma.lib">
      <pathelement location="${emma.lib.dir}/emma.jar" />
      <pathelement location="${emma.lib.dir}/emma_ant.jar" />
    </path>
    <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
  </target>
    
  
  <!-- The build target that should be used to build everything. -->
  <target name="all"
       depends="init,clean,tests,bootstrap,run-tests,wipeout"
       description="Build using all defined targets." />
 
  <!-- Remove all dynamically-generated build files. -->
  <target name="clean"
       description="Clean up the compiled integration tests"
       depends="set-default-props">
    <delete dir="${tests.classes}"           />
  </target>
  
  <!-- Compile the functional tests source files. -->
  <target name="tests" 
       description="Compile the functional tests source files.">
 
    <mkdir dir="${tests.classes}" />
 
    <javac srcdir="${tests.src.dir}" destdir="${tests.classes}" optimize="true"
         debug="on" debuglevel="lines,source" source="1.5" target="1.5"
         deprecation="true" fork="true" >
      <compilerarg value="-Xlint:all" />
 
      <classpath>
        <!-- libraries required to build -->
        <fileset dir="${lib.dir}">
          <include name="*.jar" />
        </fileset>
        <!-- include the testng library to build the test cases -->
        <fileset dir="${testng.lib.dir}">
          <include name="*.jar" />
        </fileset>
        <pathelement location="${opends.classes}" />
      </classpath>
    </javac>
  </target>
  
  <target name="run-tests" 
          description="run the integration test suite" 
          depends="init,coverage">
    <taskdef resource="testngtasks">
      <classpath>
        <fileset dir="${testng.lib.dir}">
          <include name="*.jar" />
        </fileset>
      </classpath>
    </taskdef>
    
    <mkdir dir="${tests.run.dir}"        />
    <mkdir dir="${tests.run.dir}/backup" />
    <mkdir dir="${tests.run.dir}/logs/tests"   />
    <mkdir dir="${tests.run.dir}/reports/testng" />
    <mkdir dir="${tests.run.dir}/reports/junit" />
    <mkdir dir="${tests.run.dir}/logs/server"/>
    
    <echo message="generating tests xml file ..."/>
    <copy file="testng.xml.stubs"     
          tofile="${tests.run.dir}/testng.xml"         
          overwrite="true"           >
      <filterchain>
        <expandproperties/>
      </filterchain>
    </copy>
    
    <!-- where for testng to go pick the test suite definition -->
    <fileset id="testng.xml" dir="${tests.run.dir}" >
      <include name="testng.xml"  />
    </fileset>
    
    <testng outputdir="${tests.run.dir}/reports/testng" 
            haltonfailure="true"
            enableAssert="false"
            listener="org.opends.server.OpenDSTestListener">
      <classpath>
        <!-- where to get the instrumented server classes (if built) -->
        <pathelement location="${coverage.instr.dir}"/>
        <!-- where to get the server classes -->
        <pathelement  location="${opends.classes}" />
        <!-- where to get the testng library -->
        <fileset dir="${testng.lib.dir}">
          <include name="*.jar" />
        </fileset>
        
        <!-- where to get the test classes -->
        <pathelement location="${tests.classes}" />
        <!-- last but not least, where to get the emma library -->
        <path refid="emma.lib"/>
      </classpath>
      
      <!-- coverage specific jvm options -->
        <!-- where to store the run-time coverage data --> 
      <jvmarg  value="-Demma.coverage.out.file=${coverage.data.dir}/integration.emma" />
        <!-- do not keep previous run coverage data, start from scratch everytime -->
      <jvmarg value="-Demma.coverage.out.merge=false" />
      
      <!-- give the jvm some extra room -->
      <jvmarg value="-Xmx${MEM}" />
      <jvmarg value="-Xms${MEM}" />
      
      <!-- where to get the test suite definition -->
      <xmlfileset dir="${tests.run.dir}" includes="testng.xml"/>
    </testng>
    
    <!-- convert the testng results to junit -->
    <junitreport todir="${tests.run.dir}/reports/junit">
      <fileset dir="${tests.run.dir}/reports/testng/${product.name}">
        <include name="*.xml"/>
      </fileset>
    </junitreport>
 
 
    <!-- some cleanup from the tests themselves-->
    <delete dir="${tests.run.dir}/backup" />
    <!-- save the server log files for issues investigation -->
    <copy todir="${tests.run.dir}/logs/server">
      <fileset dir="${full.install.dir}/logs"/>
    </copy>
    
    
    <emma enabled="${is-opends-instrumented}" >
      <!-- generate the integration test coverage report -->
      <report sourcepath="${opends.src}" >
        <fileset dir="${coverage.data.dir}" >
          <include name="integration.emma" />
          <include name="metadata.emma" />
        </fileset>
        <txt outfile="${integration.coverage.report.dir}/coverage.txt" />
        <html outfile="${integration.coverage.report.dir}/index.html" />
      </report>
    </emma>
    
    <emma enabled="${is-opends-instrumented}">
      <!-- generate the global test coverage report -->
      <report sourcepath="${opends.src}" >
        <fileset dir="${coverage.data.dir}" >
          <include name="*.emma" />
        </fileset>
        <txt outfile="${global.coverage.report.dir}/coverage.txt" />
        <html outfile="${global.coverage.report.dir}/index.html" />
      </report>
    </emma>
  </target>
  
  <target name="install" 
          description="deploy the opends bits"  
          depends="set-default-props"  >
    <property name="config.file"   
              location="${full.install.dir}/config/config.ldif"/>
    <mkdir dir="${install.dir}"/>
    <unzip dest="${install.dir}">
      <fileset dir="${opends.package.dir}">
        <include name="*.zip"/>
      </fileset>
    </unzip>
  </target>
 
  <target name="uninstall"
          description="Uninstall opends"
          depends="set-default-props" >
    <delete dir="${install.dir}" />
  </target>
  
  <target name="configure"
          description="configures opends to listen on the right port number"
          depends="set-default-props"
          >
    <java classname="org.opends.server.tools.ConfigureDS">
      <!-- building the classpath to run the configurator -->
      <classpath>
        <fileset dir="${full.install.dir}/lib">
          <include name="*.jar"/>
        </fileset>
      </classpath>
      
      <!-- provide the arguments here -->
      <arg value="--configClass" />
      <arg value="org.opends.server.extensions.ConfigFileHandler"  />
      <arg value="--configFile" />
      <arg value="${full.install.dir}/config/config.ldif"       />
      <arg line="-p ${port.ldap}" />
      <arg value="-D"/>
      <arg value="${bindDN}"/>
      <arg value="-w"/>
      <arg value="${password}"/>
    </java>
  </target>
  
  <!-- Windows specific start / stop commands -->
  <target name="start-windows" if="isWindows">
    <echo message="Starting in the background ..."/>
    <exec 
      executable="${full.install.dir}\bin\start-ds.bat"
      spawn="true"                                                           />
  </target>
  <target name="stop-windows"  if="isWindows" >
    <echo message="Stopping ..." />
    <exec 
      executable="${full.install.dir}\bin\stop-ds.bat">
      <arg line="-h ${host.name}"/>
      <arg line="-p ${port.ldap}"/>
      <arg line="-w ${password}"/>
      <arg value="-D"/>
      <arg value="${bindDN}"/>
    </exec>
  </target>
 
  <!-- Unix specific start / stop commands -->
  <target name="start-unix" if="isUnix" >
    <echo message="Starting in the background ..."/>
    <exec 
      executable="${full.install.dir}/bin/start-ds.sh"
      spawn="true"                                                           />
  </target>
  <target name="stop-unix" if="isUnix" >
    <echo message="Stopping ..." />
    <exec 
      executable="${full.install.dir}/bin/stop-ds.sh" >
      <arg line="-h ${host.name}"/>
      <arg line="-p ${port.ldap}"/>
      <arg line="-w ${password}"/>
      <arg value="-D"/>
      <arg value="${bindDN}"/>
    </exec>
  </target>
  
  <!-- platform independent start / stop targets -->
  <target name="start" 
          description="start the server" 
          depends="set-default-props,start-windows,start-unix" />
  <target name="stop"
          description="stop the server"
          depends="set-default-props,stop-windows,stop-unix" />
 
 
  
  <target name="sleep">
    <!--
      this is somewhat based on experience
      before we can delete the installation directory
      we have to wait for opends to exit gracefully and free all the locks on 
      the various resources it uses.
      this may need to be computed based on the tests execution time to try
      to approximate the machine speed 
      right now it's hardcoded to 15 seconds
    -->
    <sleep seconds="15"/>
  </target>
  
  <target name="bootstrap"
          description="bootstrap opends"
          depends="install,configure,start" />
  <target name="wipeout"
          description="stop and uninstall opends" 
          depends="stop,sleep,uninstall"          />
  
</project>