@@ -4,10 +4,7 @@ import (
4
4
"bytes"
5
5
"context"
6
6
"fmt"
7
- "github.com/openshift/origin/pkg/monitortestlibrary/platformidentification"
8
- "github.com/openshift/origin/test/extended/util"
9
7
"io/ioutil"
10
- "log"
11
8
"math/rand"
12
9
"os"
13
10
"os/signal"
@@ -125,36 +122,6 @@ func max(a, b int) int {
125
122
return b
126
123
}
127
124
128
- type RunMatchFunc func (run * RunInformation ) bool
129
-
130
- type RunInformation struct {
131
- // jobType may be nil for topologies without
132
- // platform identification.
133
- * platformidentification.JobType
134
- suite * TestSuite
135
- }
136
-
137
- type externalBinaryStruct struct {
138
- // The payload image tag in which an external binary path can be found
139
- imageTag string
140
- // The binary path to extract from the image
141
- binaryPath string
142
-
143
- // nil, nil - run for all suites
144
- // (), nil, - run for only those matched by include
145
- // nil, () - run for all except excluded
146
- // (), () - include overridden by exclude
147
- includeForRun RunMatchFunc
148
- excludeForRun RunMatchFunc
149
- }
150
-
151
- type externalBinaryResult struct {
152
- err error
153
- skipReason string
154
- externalBinary * externalBinaryStruct
155
- externalTests []* testCase
156
- }
157
-
158
125
func (o * GinkgoRunSuiteOptions ) Run (suite * TestSuite , junitSuiteName string , monitorTestInfo monitortestframework.MonitorTestInitializationInfo , upgrade bool ) error {
159
126
ctx := context .Background ()
160
127
@@ -163,95 +130,17 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, junitSuiteName string, mon
163
130
return fmt .Errorf ("failed reading origin test suites: %w" , err )
164
131
}
165
132
166
- fmt .Fprintf (o .Out , "Found %d tests for in openshift-tests binary for suite %q \n " , len (tests ), suite . Name )
133
+ fmt .Fprintf (o .Out , "found %d tests for suite\n " , len (tests ))
167
134
168
135
var fallbackSyntheticTestResult []* junitapi.JUnitTestCase
169
136
if len (os .Getenv ("OPENSHIFT_SKIP_EXTERNAL_TESTS" )) == 0 {
170
- // A registry of available external binaries and in which image
171
- // they reside in the payload.
172
- externalBinaries := []externalBinaryStruct {
173
- {
174
- imageTag : "hyperkube" ,
175
- binaryPath : "/usr/bin/k8s-tests" ,
176
- },
177
- }
178
-
179
- var (
180
- externalTests []* testCase
181
- wg sync.WaitGroup
182
- resultCh = make (chan externalBinaryResult , len (externalBinaries ))
183
- err error
184
- )
185
-
186
- // Lines logged to this logger will be included in the junit output for the
187
- // external binary usage synthetic.
188
- var extractDetailsBuffer bytes.Buffer
189
- extractLogger := log .New (& extractDetailsBuffer , "" , log .LstdFlags | log .Lmicroseconds )
190
-
191
- oc := util .NewCLIWithoutNamespace ("default" )
192
- jobType , err := platformidentification .GetJobType (context .Background (), oc .AdminConfig ())
193
- if err != nil {
194
- // Microshift does not permit identification. External binaries must
195
- // tolerate nil jobType.
196
- extractLogger .Printf ("Failed determining job type: %v" , err )
197
- }
198
-
199
- runInformation := & RunInformation {
200
- JobType : jobType ,
201
- suite : suite ,
202
- }
203
-
204
- releaseImageReferences , err := extractReleaseImageStream (extractLogger )
205
- if err != nil {
206
- return fmt .Errorf ("unable to extract image references from release payload: %w" , err )
207
- }
208
-
209
- for _ , externalBinary := range externalBinaries {
210
- wg .Add (1 )
211
- go func (externalBinary externalBinaryStruct ) {
212
- defer wg .Done ()
213
-
214
- var skipReason string
215
- if (externalBinary .includeForRun != nil && ! externalBinary .includeForRun (runInformation )) ||
216
- (externalBinary .excludeForRun != nil && externalBinary .excludeForRun (runInformation )) {
217
- skipReason = "excluded by suite selection functions"
218
- }
219
-
220
- var tagTestSet []* testCase
221
- var tagErr error
222
- if len (skipReason ) == 0 {
223
- tagTestSet , tagErr = externalTestsForSuite (ctx , extractLogger , releaseImageReferences , externalBinary .imageTag , externalBinary .binaryPath )
224
- }
225
-
226
- resultCh <- externalBinaryResult {
227
- err : tagErr ,
228
- skipReason : skipReason ,
229
- externalBinary : & externalBinary ,
230
- externalTests : tagTestSet ,
231
- }
232
-
233
- }(externalBinary )
234
- }
235
-
236
- wg .Wait ()
237
- close (resultCh )
238
-
239
- for result := range resultCh {
240
- if result .skipReason != "" {
241
- extractLogger .Printf ("Skipping test discovery for image %q and binary %q: %v\n " , result .externalBinary .imageTag , result .externalBinary .binaryPath , result .skipReason )
242
- } else if result .err != nil {
243
- extractLogger .Printf ("Error during test discovery for image %q and binary %q: %v\n " , result .externalBinary .imageTag , result .externalBinary .binaryPath , result .err )
244
- err = result .err
245
- } else {
246
- extractLogger .Printf ("Discovered %v tests from image %q and binary %q\n " , len (result .externalTests ), result .externalBinary .imageTag , result .externalBinary .binaryPath )
247
- externalTests = append (externalTests , result .externalTests ... )
248
- }
249
- }
250
-
137
+ buf := & bytes.Buffer {}
138
+ fmt .Fprintf (buf , "Attempting to pull tests from external binary...\n " )
139
+ externalTests , err := externalTestsForSuite (ctx )
251
140
if err == nil {
252
- var filteredTests []* testCase
141
+ filteredTests := []* testCase {}
253
142
for _ , test := range tests {
254
- // tests contains all the tests "registered" in openshift -tests binary,
143
+ // tests contains all the tests "registered" in openshif -tests binary,
255
144
// this also includes vendored k8s tests, since this path assumes we're
256
145
// using external binary to run these tests we need to remove them
257
146
// from the final lists, which contains:
@@ -262,29 +151,29 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, junitSuiteName string, mon
262
151
}
263
152
}
264
153
tests = append (filteredTests , externalTests ... )
265
- extractLogger . Printf ( "Discovered a total of %v external tests and will run a total of %v \n " , len (externalTests ), len ( tests ))
154
+ fmt . Fprintf ( buf , "Got %d tests from external binary \n " , len (externalTests ))
266
155
} else {
267
- extractLogger . Printf ( "Errors encountered while extracting one or more external test suites; Falling back to built-in suite : %v\n " , err )
156
+ fmt . Fprintf ( buf , "Falling back to built-in suite, failed reading external test suites: %v\n " , err )
268
157
// adding this test twice (one failure here, and success below) will
269
158
// ensure it gets picked as flake further down in synthetic tests processing
270
159
fallbackSyntheticTestResult = append (fallbackSyntheticTestResult , & junitapi.JUnitTestCase {
271
160
Name : "[sig-arch] External binary usage" ,
272
- SystemOut : extractDetailsBuffer .String (),
161
+ SystemOut : buf .String (),
273
162
FailureOutput : & junitapi.FailureOutput {
274
- Output : extractDetailsBuffer .String (),
163
+ Output : buf .String (),
275
164
},
276
165
})
277
166
}
278
- fmt .Fprintf (o .Out , extractDetailsBuffer .String ())
167
+ fmt .Fprintf (o .Out , buf .String ())
279
168
fallbackSyntheticTestResult = append (fallbackSyntheticTestResult , & junitapi.JUnitTestCase {
280
169
Name : "[sig-arch] External binary usage" ,
281
- SystemOut : extractDetailsBuffer .String (),
170
+ SystemOut : buf .String (),
282
171
})
283
172
} else {
284
173
fmt .Fprintf (o .Out , "Using built-in tests only due to OPENSHIFT_SKIP_EXTERNAL_TESTS being set\n " )
285
174
}
286
175
287
- fmt .Fprintf (o .Out , "Found %d tests (including externals)\n " , len (tests ))
176
+ fmt .Fprintf (o .Out , "found %d tests (incl externals)\n " , len (tests ))
288
177
289
178
// this ensures the tests are always run in random order to avoid
290
179
// any intra-tests dependencies
0 commit comments