Skip to content

Commit

Permalink
Merge pull request #28786 from pacevedom/USHIFT-3142
Browse files Browse the repository at this point in the history
USHIFT-3142: Automatically exclude FeatureGate tagged tests
  • Loading branch information
openshift-merge-bot[bot] committed May 9, 2024
2 parents 8045e28 + c67fdc2 commit ac69ee5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion pkg/clioptions/suiteselection/feature_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package suiteselection
import (
"context"
"fmt"
"regexp"

clientconfigv1 "github.com/openshift/client-go/config/clientset/versioned"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
"regexp"
)

type featureGateFilter struct {
Expand Down Expand Up @@ -72,6 +73,10 @@ func (f *featureGateFilter) includeTest(name string) bool {
return f.enabled.HasAll(featureGates...)
}

func includeNonFeatureGateTest(name string) bool {
return featureGateRegex.FindAllStringSubmatch(name, -1) == nil
}

var (
featureGateRegex = regexp.MustCompile(`\[OCPFeatureGate:([^]]*)\]`)
)
9 changes: 6 additions & 3 deletions pkg/clioptions/suiteselection/suite_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import (
"bytes"
"context"
"fmt"
clientconfigv1 "github.com/openshift/client-go/config/clientset/versioned"
"io/ioutil"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"

clientconfigv1 "github.com/openshift/client-go/config/clientset/versioned"
apierrors "k8s.io/apimachinery/pkg/api/errors"

"k8s.io/client-go/discovery"

testginkgo "github.com/openshift/origin/pkg/test/ginkgo"
Expand Down Expand Up @@ -148,7 +149,9 @@ func (f *TestSuiteSelectionFlags) SelectSuite(
featureGateFilter, err := newFeatureGateFilter(context.TODO(), configClient)
switch {
case apierrors.IsNotFound(err):
// do nothing and we'll select all featuregated tests. this is the safest for something like microshift
// In case we are unable to determine if there is support for feature gates, exclude all featuregated tests
// as the test target doesnt comply with preconditions.
suite.AddRequiredMatchFunc(includeNonFeatureGateTest)
case err != nil:
return nil, fmt.Errorf("unable to build FeatureGate filter: %w", err)
default:
Expand Down

0 comments on commit ac69ee5

Please sign in to comment.