Skip to content

Commit fd6fe36

Browse files
Merge pull request #29173 from neisw/revert-29025-external_bin_registry
TRT-1851: Revert "NO-JIRA: external binary registry"
2 parents eb78480 + 3b09efc commit fd6fe36

File tree

2 files changed

+38
-310
lines changed

2 files changed

+38
-310
lines changed

pkg/test/ginkgo/cmd_runsuite.go

+13-124
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import (
44
"bytes"
55
"context"
66
"fmt"
7-
"github.com/openshift/origin/pkg/monitortestlibrary/platformidentification"
8-
"github.com/openshift/origin/test/extended/util"
97
"io/ioutil"
10-
"log"
118
"math/rand"
129
"os"
1310
"os/signal"
@@ -125,36 +122,6 @@ func max(a, b int) int {
125122
return b
126123
}
127124

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-
158125
func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, junitSuiteName string, monitorTestInfo monitortestframework.MonitorTestInitializationInfo, upgrade bool) error {
159126
ctx := context.Background()
160127

@@ -163,95 +130,17 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, junitSuiteName string, mon
163130
return fmt.Errorf("failed reading origin test suites: %w", err)
164131
}
165132

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))
167134

168135
var fallbackSyntheticTestResult []*junitapi.JUnitTestCase
169136
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)
251140
if err == nil {
252-
var filteredTests []*testCase
141+
filteredTests := []*testCase{}
253142
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,
255144
// this also includes vendored k8s tests, since this path assumes we're
256145
// using external binary to run these tests we need to remove them
257146
// from the final lists, which contains:
@@ -262,29 +151,29 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, junitSuiteName string, mon
262151
}
263152
}
264153
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))
266155
} 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)
268157
// adding this test twice (one failure here, and success below) will
269158
// ensure it gets picked as flake further down in synthetic tests processing
270159
fallbackSyntheticTestResult = append(fallbackSyntheticTestResult, &junitapi.JUnitTestCase{
271160
Name: "[sig-arch] External binary usage",
272-
SystemOut: extractDetailsBuffer.String(),
161+
SystemOut: buf.String(),
273162
FailureOutput: &junitapi.FailureOutput{
274-
Output: extractDetailsBuffer.String(),
163+
Output: buf.String(),
275164
},
276165
})
277166
}
278-
fmt.Fprintf(o.Out, extractDetailsBuffer.String())
167+
fmt.Fprintf(o.Out, buf.String())
279168
fallbackSyntheticTestResult = append(fallbackSyntheticTestResult, &junitapi.JUnitTestCase{
280169
Name: "[sig-arch] External binary usage",
281-
SystemOut: extractDetailsBuffer.String(),
170+
SystemOut: buf.String(),
282171
})
283172
} else {
284173
fmt.Fprintf(o.Out, "Using built-in tests only due to OPENSHIFT_SKIP_EXTERNAL_TESTS being set\n")
285174
}
286175

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))
288177

289178
// this ensures the tests are always run in random order to avoid
290179
// any intra-tests dependencies

0 commit comments

Comments
 (0)