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

Christophe Sovant
13.24.2008 8310417a85804a034b2b5b58bc9f48d0687f829b
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../shared/stax.dtd">
<!--
 ! 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 2006-2008 Sun Microsystems, Inc.
 ! -->
<stax>
  <defaultcall function="main" />
  <function name="main">
    <sequence>
      <!--- Load the environment for the test suite execution -->
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/environment.xml' % TESTS_FUNCTIONS_DIR" />
      <call function="'loadEnvironment'" />
 
      <!-- The Functional Tests -->
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/security/security.xml' % TESTS_DIR" />
      <!--
      add keyword 'main_security' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/aci/aci.xml' % TESTS_DIR" />
      <!--
      add keyword 'main_aci' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/privileges/privileges.xml' % TESTS_DIR" />
      <!--
      add keyword 'main_privileges' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/dsconfig/dsconfig.xml' % TESTS_DIR" />
      <!--
      add keyword 'main_dsconfig' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/backends/backends.xml' % TESTS_DIR" />
      <!--
      add keyword 'main_backends' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/clu/clu.xml' % TESTS_DIR" />
      <!--
      add keyword 'main_clu' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/core/core.xml' % TESTS_DIR" />
      <!--
      add keyword 'main_core' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/schema/schema.xml' % TESTS_DIR" />
      <!--
      add keyword 'main_schema' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/replication/replication.xml' % TESTS_DIR" />
      <!--
      add keyword 'main_replication' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/indexes/indexes.xml' % TESTS_DIR" />
      <!--
      add keyword 'indexes' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/groups/groups.xml' % TESTS_DIR" />
      <!--
      add keyword 'main_groups' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/logging/logging.xml' % (TESTS_DIR)" />
      <!--
      add keyword 'main_logging' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/plugins/plugins.xml' % (TESTS_DIR)" />
      <!--
      add keyword 'main_plugins' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/tasks/tasks.xml' % (TESTS_DIR)" />
      <!--
      add keyword 'main_tasks' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/virtualAttributes/virtualAttributes.xml' % (TESTS_DIR)" />
      <!--
      add keyword 'main_virtualAttributes' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
 
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/monitoring/monitoring.xml' % (TESTS_DIR)" />
      <!--
      add keyword 'main_monitoring' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
      
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/dsml/dsml.xml' % (TESTS_DIR)" />
      <!--
      add keyword 'main_dsml' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
      
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/setup/setup.xml' % (TESTS_DIR)" />
      <!--
      add keyword 'main_setup' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
      
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/snmp/snmp.xml' % TESTS_DIR" />
      <!--
      add keyword 'main_snmp' in run-custom-suites.dat file to run this specific testsuite or run CLI : build run-my-tests
      -->
      
      <import machine="STAF_LOCAL_HOSTNAME"
              file="'%s/testcases/sample/sample.xml' % TESTS_DIR" />
      <script>
        # this function return a well-formatted testcase name
        def getTestCaseName(name):
          return '%s: %s: %s' % (CurrentTestPath['group'],CurrentTestPath['suite'],name)
 
        # this functions adds a known issue to a testcase's known issues list
        issuesList=[]
        def knownIssue(issue):
          issuesList.append(issue)
 
        class functionToRun:
          def __init__(self, name):
            self.name = name
 
          def getName(self):
            return self.name
 
        testlog=open('%s/tests-log.xml' % logsTestsDir,'w')
        testlog.write('&lt;qa&gt;\n')
        testlog.write('  &lt;functional-tests&gt;\n')
        testlog.write('    &lt;results&gt;\n')
        testlog.close()
 
        suitesFileName='%s/testcases/run-custom-suites.dat' % TESTS_DIR
 
        if not os.path.exists(suitesFileName):
          suitesFileName='%s/testcases/run-default-suites.dat' % TESTS_DIR
 
        f = open(suitesFileName, 'r')
        functionsToRun = []
        for line in f.readlines():
          functionsToRun.append(functionToRun(line.rstrip()))
        f.close()
      </script>
      <iterate var="function" in="functionsToRun">
        <sequence>
          <message>'calling function [%s]' % function.getName()</message>
          <call function="function.getName()" />
        </sequence>
      </iterate>
 
      <!-- in this section we'll compute the coverage for all the tests
           if coverage is turned on
           so far I could only get through this on either machines with a lot
           of memory or small sets of tests
      -->
      <if expr="os.path.exists('%s/lib/emma.jar' % dsPath)">
        <sequence>
          <script>
            coverageFiles=''
            for group in os.listdir('%s/coverage/' % TMPDIR):
              coverageFiles+='%s/coverage/%s/coverage.ec' % (TMPDIR,group)
          </script>
          <call function="'runCommand'">
            { 'name'      : 'Generate global coverage xml report',
              'command'   : 'java',
              'arguments' : ' -Xms64M -Xmx1024M -cp %s/lib/emma.jar emma report -r xml,html -in %s/coverage.em,%s -Dreport.xml.out.file=%s/coverage/coverage.xml -Dreport.html.out.file=%s/coverage/coverage.html -sp %s/../../../src' % (dsPath,dsPath,coverageFiles,TMPDIR,TMPDIR,TMPDIR),
              'path'      : TMPDIR
            }
          </call>
          <script>
            from java.io import FileInputStream
            from javax.xml.transform.stream import StreamSource
            from javax.xml.transform.stream import StreamResult
            from javax.xml.parsers import DocumentBuilderFactory
            from org.w3c.dom import *
 
            factory = DocumentBuilderFactory.newInstance()
            builder = factory.newDocumentBuilder()
 
            input = FileInputStream("%s/coverage/coverage.xml" % TMPDIR)
            document = builder.parse(input)
            dom = document.getDocumentElement()
            coverageNodes = dom.getElementsByTagName("all").item(0).getChildNodes()
            for coverageNodeIndex in range(coverageNodes.getLength()):
              thisNode = coverageNodes.item(coverageNodeIndex)
              if thisNode.getNodeName() == 'coverage':
                thisNodeAttributes = thisNode.getAttributes()
                if thisNodeAttributes.getNamedItem("type").getNodeValue() == 'block, %':
                  rawCoverage = thisNodeAttributes.getNamedItem("value").getNodeValue()
                  coverage = rawCoverage.split('%')[0]
            testlog=open('%s/tests-log.xml' % logsTestsDir,'a')
            testlog.seek(0,2)
            testlog.write("      &lt;all&gt;\n")
            testlog.write("        &lt;coverage&gt;\n")
            testlog.write("          %s\n" % coverage)
            testlog.write("        &lt;/coverage&gt;\n")
            testlog.write("      &lt;/all&gt;\n")
            testlog.close()
          </script>
        </sequence>
        <else>
          <script>
            testlog=open('%s/tests-log.xml' % logsTestsDir,'a')
            testlog.seek(0,2)
            testlog.write("      &lt;all&gt;\n")
            testlog.write("        &lt;coverage&gt;\n")
            testlog.write("          N/A\n")
            testlog.write("        &lt;/coverage&gt;\n")
            testlog.write("      &lt;/all&gt;\n")
            testlog.close()
          </script>
        </else>
      </if>
 
      <!-- here goes the section where we get the product's info -->
      <call function="'GetVar'">
        { 'location'  : STAF_REMOTE_HOSTNAME,
          'type'      : 'shared',
          'variable'  : 'Job%s_ServerInfo' % STAXJobID
        }
      </call>
 
      <if expr="RC != 0">
        <script>
          STAFResult='{}'
        </script>
      </if>
 
      <!-- Build the Servers Information Dictionary -->
      <script>
        ServersInfoDict=eval(STAFResult)
 
        ServerVersion='unknown'
        ServerBuildId='unknown'
        ServerJavaVersion='unknown'
        ServerJavaVendor='unknown'
        ServerJVMVersion='unknown'
        ServerJVMVendor='unknown'
        ServerJVMArchitecture='unknown'
        ServerSystemOS='unknown'
        ServerSystemName='unknown'
        ServerSvnRevision='unknown'
 
        if ServersInfoDict.has_key('%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)):
          ServerInfoDict=ServersInfoDict['%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)]
 
          ServerInfoKey='server version'
          if ServerInfoDict.has_key(ServerInfoKey):
            ServerVersion=ServerInfoDict[ServerInfoKey]
 
          ServerInfoKey='server buildid'
          if ServerInfoDict.has_key(ServerInfoKey):
            ServerBuildId=ServerInfoDict[ServerInfoKey]
 
          ServerInfoKey='java version'
          if ServerInfoDict.has_key(ServerInfoKey):
            ServerJavaVersion=ServerInfoDict[ServerInfoKey]
 
          ServerInfoKey='java vendor'
          if ServerInfoDict.has_key(ServerInfoKey):
            ServerJavaVendor=ServerInfoDict[ServerInfoKey]
 
          ServerInfoKey='jvm version'
          if ServerInfoDict.has_key(ServerInfoKey):
            ServerJVMVersion=ServerInfoDict[ServerInfoKey]
 
          ServerInfoKey='jvm vendor'
          if ServerInfoDict.has_key(ServerInfoKey):
            ServerJVMVendor=ServerInfoDict[ServerInfoKey]
 
          ServerInfoKey='jvm architecture'
          if ServerInfoDict.has_key(ServerInfoKey):
            ServerJVMArchitecture=ServerInfoDict[ServerInfoKey]
 
          ServerInfoKey='system os'
          if ServerInfoDict.has_key(ServerInfoKey):
            ServerSystemOS=ServerInfoDict[ServerInfoKey]
 
          ServerInfoKey='system name'
          if ServerInfoDict.has_key(ServerInfoKey):
            ServerSystemName=ServerInfoDict[ServerInfoKey]
 
          ServerInfoKey='svn revision'
          if ServerInfoDict.has_key(ServerInfoKey):
            ServerSvnRevision=ServerInfoDict[ServerInfoKey]
 
        else:
          ServerInfoDict='No key found (%s/%s)' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)
 
        # Platform and JVM can be overridden from config file
        try:
          if TEST_OS_STRING:
            ServerOsString=TEST_OS_STRING
          else:
            ServerOsString=ServerSystemOS
        except NameError,details:
            ServerOsString=ServerSystemOS
 
        try:
          if TEST_JVM_STRING:
            ServerJVMString=TEST_JVM_STRING
          else:
            ServerJVMString=ServerJVMVersion
        except NameError,details:
            ServerJVMString=ServerJVMVersion
 
        testlog=open('%s/tests-log.xml' % logsTestsDir,'a')
        testlog.seek(0,2)
        testlog.write('    &lt;/results&gt;\n')
        testlog.write('    &lt;identification&gt;\n')
        testlog.write('      &lt;version&gt;\n')
        testlog.write('        %s\n' % ServerVersion)
        testlog.write('      &lt;/version&gt;\n')
        testlog.write('      &lt;buildid&gt;\n')
        testlog.write('        %s\n' % ServerBuildId)
        testlog.write('      &lt;/buildid&gt;\n')
        testlog.write('      &lt;revision&gt;\n')
        testlog.write('        %s\n' % ServerSvnRevision)
        testlog.write('      &lt;/revision&gt;\n')
        testlog.write('      &lt;platform&gt;\n')
        testlog.write('        %s\n' % ServerSystemOS)
        testlog.write('      &lt;/platform&gt;\n')
        testlog.write('      &lt;os-label&gt;\n')
        testlog.write('        %s\n' % ServerOsString)
        testlog.write('      &lt;/os-label&gt;\n')
        testlog.write('      &lt;jvm-version&gt;\n')
        testlog.write('        %s\n' % ServerJVMVersion)
        testlog.write('      &lt;/jvm-version&gt;\n')
        testlog.write('      &lt;jvm-label&gt;\n')
        testlog.write('        %s\n' % ServerJVMString)
        testlog.write('      &lt;/jvm-label&gt;\n')
        testlog.write('      &lt;jvm-vendor&gt;\n')
        testlog.write('        %s\n' % ServerJVMVendor)
        testlog.write('      &lt;/jvm-vendor&gt;\n')
        testlog.write('      &lt;tests-dir&gt;\n')
        testlog.write('        %s\n' % logsDir)
        testlog.write('      &lt;/tests-dir&gt;\n')
        testlog.write('    &lt;/identification&gt;\n')
        testlog.write('  &lt;/functional-tests&gt;\n')
        testlog.write('&lt;/qa&gt;\n')
        testlog.close()
      </script>
    </sequence>
  </function>
</stax>