diff --git a/devel/run-e2e.sh b/devel/run-e2e.sh index 8862a14e4..9c1a7b531 100755 --- a/devel/run-e2e.sh +++ b/devel/run-e2e.sh @@ -48,6 +48,9 @@ if [[ -n "$GINKGO_FOCUS" ]]; then GINKGO_FOCUS="--ginkgo.focus=${GINKGO_FOCUS}"; # 'export GINKGO_SKIP="Venafi Cloud"' (skips all suites with 'Venafi Cloud' in the name). if [[ -n "$GINKGO_SKIP" ]]; then GINKGO_SKIP="--ginkgo.skip=${GINKGO_SKIP}"; fi +# Default feature gates to enable +FEATURE_GATES="${FEATURE_GATES:-ExperimentalCertificateSigningRequestControllers=true,ExperimentalGatewayAPISupport=true}" + # Configure PATH to use bazel provided e2e tools setup_tools @@ -68,6 +71,7 @@ ginkgo -nodes 10 -flakeAttempts ${FLAKE_ATTEMPTS:-1} \ --report-dir="${ARTIFACTS:-$REPO_ROOT/_artifacts}" \ --acme-dns-server="$DNS_SERVER" \ --acme-ingress-ip="$INGRESS_IP" \ + --feature-gates="${FEATURE_GATES}" \ ${GINKGO_SKIP:+"$GINKGO_SKIP"} \ ${GINKGO_FOCUS:+"$GINKGO_FOCUS"} \ "$@" diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 94544a4ce..51ad9e04b 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -34,6 +34,8 @@ import ( _ "github.com/jetstack/cert-manager/test/e2e/suite" ) +var featureGates string + func init() { logs.InitLogs(flag.CommandLine) framework.DefaultConfig.AddFlags(flag.CommandLine) @@ -46,7 +48,6 @@ func init() { ginkgoconfig.GinkgoConfig.RandomizeAllSpecs = true wait.ForeverTestTimeout = time.Second * 60 - } func TestE2E(t *testing.T) { diff --git a/test/e2e/framework/config/BUILD.bazel b/test/e2e/framework/config/BUILD.bazel index 8225446d2..bfcfbe807 100644 --- a/test/e2e/framework/config/BUILD.bazel +++ b/test/e2e/framework/config/BUILD.bazel @@ -19,6 +19,8 @@ go_library( tags = ["manual"], visibility = ["//visibility:public"], deps = [ + "//pkg/util/feature:go_default_library", + "@com_github_spf13_pflag//:go_default_library", "@io_k8s_apimachinery//pkg/util/errors:go_default_library", "@io_k8s_client_go//tools/clientcmd:go_default_library", ], diff --git a/test/e2e/framework/config/config.go b/test/e2e/framework/config/config.go index 7af6ae734..9d17fd03e 100644 --- a/test/e2e/framework/config/config.go +++ b/test/e2e/framework/config/config.go @@ -21,11 +21,17 @@ import ( "fmt" "os" "path/filepath" + "strings" + "github.com/spf13/pflag" utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/client-go/tools/clientcmd" + + utilfeature "github.com/jetstack/cert-manager/pkg/util/feature" ) +var featureGates string + type Config struct { KubeConfig string KubeContext string @@ -56,6 +62,14 @@ func (c *Config) Validate() error { errs = append(errs, c.Addons.Validate()...) errs = append(errs, c.Suite.Validate()...) + // Apply feature gate flag on the actual shared feature gate map using a + // pflag set with the copied value. + ps := pflag.NewFlagSet("", pflag.ContinueOnError) + utilfeature.DefaultMutableFeatureGate.AddFlag(ps) + if err := ps.Parse([]string{"--feature-gates=" + flag.CommandLine.Lookup("feature-gates").Value.String()}); err != nil { + errs = append(errs, fmt.Errorf("failed to parse --feature-gates flag: %w", err)) + } + return utilerrors.NewAggregate(errs) } @@ -78,6 +92,12 @@ func (c *Config) AddFlags(fs *flag.FlagSet) { // TODO: get rid of this variable by bundling required files as part of test suite fs.StringVar(&c.RepoRoot, "repo-root", "", "Path to the root of the repository, used for access to repo-homed test fixtures.") + // Register own feature gates flag since component-base uses pflag and we are + // using flag stdlib. + fs.StringVar(&featureGates, "feature-gates", "", + "A set of key=value pairs that describe feature gates for alpha/experimental features. "+ + "Options are:\n"+strings.Join(utilfeature.DefaultMutableFeatureGate.KnownFeatures(), ", ")+"\n") + c.Ginkgo.AddFlags(fs) c.Addons.AddFlags(fs) c.Suite.AddFlags(fs) diff --git a/test/e2e/suite/conformance/certificatesigningrequests/BUILD.bazel b/test/e2e/suite/conformance/certificatesigningrequests/BUILD.bazel index e24f793f0..2e79d68c1 100644 --- a/test/e2e/suite/conformance/certificatesigningrequests/BUILD.bazel +++ b/test/e2e/suite/conformance/certificatesigningrequests/BUILD.bazel @@ -12,6 +12,7 @@ go_library( "//pkg/apis/experimental/v1alpha1:go_default_library", "//pkg/feature:go_default_library", "//pkg/util:go_default_library", + "//pkg/util/feature:go_default_library", "//test/e2e/framework:go_default_library", "//test/e2e/framework/helper/featureset:go_default_library", "//test/e2e/framework/helper/validation:go_default_library", diff --git a/test/e2e/suite/conformance/certificatesigningrequests/suite.go b/test/e2e/suite/conformance/certificatesigningrequests/suite.go index 7eed0d9b7..da3acae3c 100644 --- a/test/e2e/suite/conformance/certificatesigningrequests/suite.go +++ b/test/e2e/suite/conformance/certificatesigningrequests/suite.go @@ -19,14 +19,12 @@ package certificatesigningrequests import ( "crypto" "fmt" - "os" - "strings" . "github.com/onsi/ginkgo" certificatesv1 "k8s.io/api/certificates/v1" "github.com/jetstack/cert-manager/pkg/feature" - "github.com/jetstack/cert-manager/pkg/util" + utilfeature "github.com/jetstack/cert-manager/pkg/util/feature" "github.com/jetstack/cert-manager/test/e2e/framework" "github.com/jetstack/cert-manager/test/e2e/framework/helper/featureset" ) @@ -111,8 +109,7 @@ func (s *Suite) it(f *framework.Framework, name string, fn func(string), require return } It(name, func() { - fgs := os.Getenv("FEATURE_GATES") - if !util.Contains(strings.Split(fgs, ","), string(feature.ExperimentalCertificateSigningRequestControllers)+"=true") { + if !utilfeature.DefaultFeatureGate.Enabled(feature.ExperimentalCertificateSigningRequestControllers) { framework.Skipf("skipping CertificateSigningRequest controller test since FEATURE_GATE %s is not enabled", feature.ExperimentalCertificateSigningRequestControllers) }