Merge pull request #4703 from JoshVanL/test-e2e-feature-gate-piping
Pipes in the feature gates from environment to e2e binary
This commit is contained in:
commit
59c0b40721
@ -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"} \
|
||||
"$@"
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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",
|
||||
],
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user