Skip to content

Commit 88b656f

Browse files
Merge pull request #28436 from soltysh/conditional_skip
OCPNODE-1892: Conditionally skip tests to help with k8s 1.29
2 parents 1d470ab + 353223b commit 88b656f

File tree

1 file changed

+52
-9
lines changed

1 file changed

+52
-9
lines changed

pkg/test/ginkgo/cmd_runsuite.go

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"context"
66
"fmt"
7-
"github.com/sirupsen/logrus"
87
"io/ioutil"
98
"math/rand"
109
"os"
@@ -16,20 +15,22 @@ import (
1615
"syscall"
1716
"time"
1817

19-
"github.com/openshift/origin/pkg/clioptions/clusterinfo"
20-
21-
"github.com/openshift/origin/pkg/monitortestframework"
18+
"github.com/sirupsen/logrus"
2219

2320
"github.com/onsi/ginkgo/v2"
21+
"github.com/openshift/origin/pkg/clioptions/clusterinfo"
2422
"github.com/openshift/origin/pkg/defaultmonitortests"
2523
"github.com/openshift/origin/pkg/disruption/backend/sampler"
2624
"github.com/openshift/origin/pkg/monitor"
2725
monitorserialization "github.com/openshift/origin/pkg/monitor/serialization"
26+
"github.com/openshift/origin/pkg/monitortestframework"
2827
"github.com/openshift/origin/pkg/riskanalysis"
2928
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
3029
"github.com/spf13/pflag"
3130
"k8s.io/apimachinery/pkg/util/sets"
3231
"k8s.io/cli-runtime/pkg/genericclioptions"
32+
"k8s.io/client-go/discovery"
33+
"k8s.io/client-go/rest"
3334
)
3435

3536
const (
@@ -196,6 +197,17 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, junitSuiteName string, mon
196197

197198
fmt.Fprintf(o.Out, "found %d filtered tests\n", len(tests))
198199

200+
restConfig, err := clusterinfo.GetMonitorRESTConfig()
201+
if err != nil {
202+
return err
203+
}
204+
205+
// skip tests due to newer k8s
206+
tests, err = o.filterOutRebaseTests(restConfig, tests)
207+
if err != nil {
208+
return err
209+
}
210+
199211
count := o.Count
200212
if count == 0 {
201213
count = suite.Count
@@ -246,11 +258,6 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, junitSuiteName string, mon
246258
parallelism = 10
247259
}
248260

249-
restConfig, err := clusterinfo.GetMonitorRESTConfig()
250-
if err != nil {
251-
return err
252-
}
253-
254261
ctx, cancelFn := context.WithCancel(context.Background())
255262
defer cancelFn()
256263
abortCh := make(chan os.Signal, 2)
@@ -586,3 +593,39 @@ func (o *GinkgoRunSuiteOptions) Run(suite *TestSuite, junitSuiteName string, mon
586593
fmt.Fprintf(o.Out, "%d pass, %d skip (%s)\n", pass, skip, duration)
587594
return ctx.Err()
588595
}
596+
597+
func (o *GinkgoRunSuiteOptions) filterOutRebaseTests(restConfig *rest.Config, tests []*testCase) ([]*testCase, error) {
598+
discoveryClient, err := discovery.NewDiscoveryClientForConfig(restConfig)
599+
if err != nil {
600+
return nil, err
601+
}
602+
serverVersion, err := discoveryClient.ServerVersion()
603+
if err != nil {
604+
return nil, err
605+
}
606+
// TODO: this version along with below exclusions lists needs to be updated
607+
// for the rebase in-progress.
608+
if !strings.HasPrefix(serverVersion.Minor, "29") {
609+
return tests, nil
610+
}
611+
612+
// Below list should only be filled in when we're trying to land k8s rebase.
613+
// Don't pile them up!
614+
exclusions := []string{
615+
// compare https://github.com/kubernetes/kubernetes/pull/119454
616+
`[sig-network] Services should complete a service status lifecycle`,
617+
}
618+
619+
matches := make([]*testCase, 0, len(tests))
620+
outerLoop:
621+
for _, test := range tests {
622+
for _, excl := range exclusions {
623+
if strings.Contains(test.name, excl) {
624+
fmt.Fprintf(o.Out, "Skipping %q due to rebase in-progress\n", test.name)
625+
continue outerLoop
626+
}
627+
}
628+
matches = append(matches, test)
629+
}
630+
return matches, nil
631+
}

0 commit comments

Comments
 (0)