Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b954c809fd8947c573e4ae37a668e0c2cb652f32 (plain) (blame)
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
<?xml version="1.0" encoding="UTF-8"?>
<project
  name="collectTestResults"
  default="collectTestResults"
  basedir=".">

  <!-- example properties. Caller normally provides. -->
  <property
    name="job"
    value="ep4-unit-mac64" />
  <property
    name="buildNumber"
    value="49" />
  <property
    name="buildId"
    value="N20121014-2000" />
  <property
    name="eclipseStream"
    value="4.3.0" />
  <property
    name="EBUILDER_HASH"
    value="master" />


  <target
    name="collectTestResults"
    depends="init"
    description="Collect Test Results from Hudson to build machine location.">


    <fail unless="buildNumber" />

    <retry
      retrycount="3"
      retrydelay="1000">
      <get
        ignoreerrors="true"
        verbose="true"
        src="${hudsonResultURL}"
        dest="${tmpzipdir}/archive.zip" />
    </retry>

    <echo message="hudsonTestResultsURL ${hudsonTestResultsURL} " />
    <retry
      retrycount="3"
      retrydelay="1000">
      <get
        src="${hudsonTestResultsURL}"
        dest="${resultsDir}/${job}-${buildNumber}.xml" />
    </retry>

    <!-- not sure if mkdir needed? -->
    <mkdir dir="${resultsDir}/directorLogs" />

    <unzip
      overwrite="true"
      src="${tmpzipdir}/archive.zip"
      dest="${resultsDir}/">
      <globmapper
        from="archive/workarea/${buildId}/eclipse-testing/results/*"
        to="*" />
    </unzip>

    <exec
      executable="/bin/bash"
      failonerror="true">
      <arg value="${UTILITIES_HOME}/sdk/promotion/updateDropLocation.sh" />
      <arg value="${eclipseStream}" />
      <arg value="${buildId}" />
      <arg value="${EBUILDER_HASH}" />
      <arg value="${job}" />
      <arg value="${buildNumber}" />
    </exec>

    <delete failonerror="false">
      <fileset dir="${resultsDir}">
        <include name="${tmpzipdir}" />
        <include name="archive/**" />
      </fileset>
    </delete>

  </target>

  <target
    name="init"
    unless="collectTestResultsInitialized">

    <property environment="env" />
    <echo message="env.BUILD_HOME: ${env.BUILD_HOME}" />

    <condition property="UTILITIES_HOME" value="${env.WORKSPACE}/utilities/production" else="/shared/eclipse">
      <isset property="env.WORKSPACE"/>
    </condition>
    
    <condition
      property="env.HUDSON_ROOT_URI"
      value="shared">
      <contains
        string="${job}"
        substring="mac64"
        casesensitive="yes" />
    </condition>

    <property
      name="env.HUDSON_ROOT_URI"
      value="releng" />

    <!-- we set these "env" variables here not to effect the
      environment, but that because we need some value for them,
      so if not actually set in the environment, we create these
      with some reasonable default. (Though, if not set in the environment,
      could be a sign that somethign is not as expected?)
    -->
    <condition
      property="hudsonHost"
      value="${env.HUDSON_PERF_HOST}">
      <and>
        <isset property="HUDSON_PERF_HOST" />
        <contains
          string="${job}"
          substring="-perf-lin"
          casesensitive="yes" />
      </and>
    </condition>
    <!-- if that didn't set hudsonHost, check env variable before using fallback default -->
    <condition
      property="hudsonHost"
      value="${env.HUDSON_HOST}"
      else="ci.eclipse.org">
      <isset property="env.HUDSON_HOST" />
    </condition>


    <property
      name="env.HUDSON_PROTOCOL"
      value="https" />
    <property
      name="env.HUDSON_PORT"
      value="443" />

    <!-- if not set externally, set to eclipse default (for -perf-lin jobs) -->
    <property
      name="env.LINUX_PERF_SEGMENT"
      value="releng" />



    <condition
      property="hudsonPathSegment"
      value="${env.LINUX_PERF_SEGMENT}"
      else="${env.HUDSON_ROOT_URI}">
      <and>
        <isset property="env.LINUX_PERF_SEGMENT" />
        <contains
          string="${job}"
          substring="-perf-lin"
          casesensitive="yes" />
      </and>
    </condition>

    <property
      name="env.BUILD_HOME"
      value="/shared/eclipse/builds" />

    <echo message="env.BUILD_HOME: ${env.BUILD_HOME}" />


    <script language="javascript"><![CDATA[
            var buildId = project.getProperty("buildId");
            var patternbuildType = new RegExp(/^([IMXYNSRU])(\d{8})-(\d{4})$/);

            var sArraybuildType = patternbuildType.exec(buildId);
            // sArray 0 is "whole match"
            var buildType =  sArraybuildType[1];
            project.setProperty("buildType", buildType);

            var eclipseStream = project.getProperty("eclipseStream");
            var patternStream = new RegExp(/(\d+)\.(\d+)\.(\d+)/);

            var sArrayStream = patternStream.exec(eclipseStream);
            // sArray[0] is "whole match"
            var eclipseStreamMajor = sArrayStream[1];
            var eclipseStreamMinor = sArrayStream[2];
            var eclipseStreamService = sArrayStream[3];
            project.setProperty("eclipseStreamMajor", eclipseStreamMajor);
            project.setProperty("eclipseStreamMinor", eclipseStreamMinor);
            project.setProperty("eclipseStreamService", eclipseStreamService);

            var buildhome = project.getProperty("env.BUILD_HOME");

            var buildRoot= buildhome + "/" + eclipseStreamMajor + buildType;
            project.setProperty("buildRoot", buildRoot);
            var siteDir= buildRoot + "/siteDir";
            var postingDirectory = siteDir + "/eclipse/downloads/drops"
            if (eclipseStreamMajor > 3 )
            {
                postingDirectory = siteDir + "/eclipse/downloads/drops4";
            }
            project.setProperty("postingDirectory", postingDirectory);
            ]]>
    </script>

    <echo message="buildRoot: ${buildRoot}" />

    <echo message="postingDirectory: ${postingDirectory}" />

    <!--
      Two possible results directories.
      All of these asssume following naming conventions in Hudson jobs. TODO: in future could/should have properties
      that describe the tests anyway, so might want to use that, to deside results directories.Currently:
      contains -perf- : performance
      else: testresults
      We need to avoid "-baseline" distinction. If anything, 
      make one base on "LR" (long running). 
    -->
    <condition
      property="resultsDir"
      value="${postingDirectory}/${buildId}/performance"
      else="${postingDirectory}/${buildId}/testresults">
      <contains
        string="${job}"
        substring="-perf-"
        casesensitive="yes" />
    </condition>

    <!-- attempt to create incase hasn't been created yet -->
    <mkdir dir="${resultsDir}" />

    <property
      name="hudsonResultRootJobURL"
      value="${env.HUDSON_PROTOCOL}://${hudsonHost}:${env.HUDSON_PORT}/${hudsonPathSegment}/job/${job}/${buildNumber}" />


    <property
      name="hudsonResultRootURL"
      value="${hudsonResultRootJobURL}/artifact/*zip*" />
    <property
      name="hudsonResultURL"
      value="${hudsonResultRootURL}/archive.zip" />
    <echo message="hudsonResultURL ${hudsonResultURL} " />

    <property
      name="hudsonTestResultsURL"
      value="${hudsonResultRootJobURL}/testReport/api/xml?tree=failCount,passCount,skipCount,duration" />
    <echo message="hudsonTestResultsURL ${hudsonTestResultsURL} " />

    <property
      name="tmpzipdir"
      value="${resultsDir}/tmp${job}" />



    <mkdir dir="${tmpzipdir}" />

    <property
      name="collectTestResultsInitialized"
      value="true" />

  </target>

</project>

Back to the top