mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
enable gce pd driver via a flag rather than an env var
Change-Id: Ib7c99083ad334e5f6dd152e376a303de794e0bf1
This commit is contained in:
parent
bdd2e47695
commit
738b458f8e
@ -189,6 +189,9 @@ type TestContextType struct {
|
||||
// RequireDevices makes mandatory on the environment on which tests are run 1+ devices exposed through device plugins.
|
||||
// With this enabled The e2e tests requiring devices for their operation can assume that if devices aren't reported, the test can fail
|
||||
RequireDevices bool
|
||||
|
||||
// Enable volume drivers which are disabled by default. See test/e2e/storage/in_tree_volumes.go for details.
|
||||
EnabledVolumeDrivers []string
|
||||
}
|
||||
|
||||
// NodeKillerConfig describes configuration of NodeKiller -- a utility to
|
||||
@ -262,6 +265,27 @@ type CloudConfig struct {
|
||||
// TestContext should be used by all tests to access common context data.
|
||||
var TestContext TestContextType
|
||||
|
||||
// StringArrayValue is used with flag.Var for a comma-separated list of strings placed into a string array.
|
||||
type stringArrayValue struct {
|
||||
stringArray *[]string
|
||||
}
|
||||
|
||||
func (v stringArrayValue) String() string {
|
||||
if v.stringArray != nil {
|
||||
return strings.Join(*v.stringArray, ",")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (v stringArrayValue) Set(s string) error {
|
||||
if len(s) == 0 {
|
||||
*v.stringArray = []string{}
|
||||
} else {
|
||||
*v.stringArray = strings.Split(s, ",")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ClusterIsIPv6 returns true if the cluster is IPv6
|
||||
func (tc TestContextType) ClusterIsIPv6() bool {
|
||||
return tc.IPFamily == "ipv6"
|
||||
@ -319,6 +343,8 @@ func RegisterCommonFlags(flags *flag.FlagSet) {
|
||||
|
||||
flags.StringVar(&TestContext.SnapshotControllerPodName, "snapshot-controller-pod-name", "", "The pod name to use for identifying the snapshot controller in the kube-system namespace.")
|
||||
flags.IntVar(&TestContext.SnapshotControllerHTTPPort, "snapshot-controller-http-port", 0, "The port to use for snapshot controller HTTP communication.")
|
||||
|
||||
flags.Var(&stringArrayValue{&TestContext.EnabledVolumeDrivers}, "enabled-volume-drivers", "Comma-separated list of in-tree volume drivers to enable for testing. This is only needed for in-tree drivers disabled by default. An example is gcepd; see test/e2e/storage/in_tree_volumes.go for full details.")
|
||||
}
|
||||
|
||||
func CreateGinkgoConfig() (types.SuiteConfig, types.ReporterConfig) {
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
"k8s.io/kubernetes/test/e2e/storage/drivers"
|
||||
storageframework "k8s.io/kubernetes/test/e2e/storage/framework"
|
||||
"k8s.io/kubernetes/test/e2e/storage/testsuites"
|
||||
@ -53,10 +54,32 @@ var testDrivers = []func() storageframework.TestDriver{
|
||||
|
||||
// This executes testSuites for in-tree volumes.
|
||||
var _ = utils.SIGDescribe("In-tree Volumes", func() {
|
||||
if enableGcePD := os.Getenv("ENABLE_STORAGE_GCE_PD_DRIVER"); enableGcePD == "yes" {
|
||||
framework.Logf("Enabling in-tree volume drivers")
|
||||
|
||||
gceEnabled := false
|
||||
for _, driver := range framework.TestContext.EnabledVolumeDrivers {
|
||||
switch driver {
|
||||
case "gcepd":
|
||||
testDrivers = append(testDrivers, drivers.InitGcePdDriver)
|
||||
testDrivers = append(testDrivers, drivers.InitWindowsGcePdDriver)
|
||||
gceEnabled = true
|
||||
default:
|
||||
framework.Failf("Invalid volume type %s in %v", driver, framework.TestContext.EnabledVolumeDrivers)
|
||||
}
|
||||
}
|
||||
|
||||
// Support the legacy env var for gcepd.
|
||||
if enableGcePD := os.Getenv("ENABLE_STORAGE_GCE_PD_DRIVER"); enableGcePD == "yes" && !gceEnabled {
|
||||
framework.Logf("Warning: deprecated ENABLE_STORAGE_GCE_PD_DRIVER used. This will be removed in a future release. Use --enabled-volume-drivers=gcepd instead")
|
||||
testDrivers = append(testDrivers, drivers.InitGcePdDriver)
|
||||
testDrivers = append(testDrivers, drivers.InitWindowsGcePdDriver)
|
||||
gceEnabled = true
|
||||
}
|
||||
|
||||
if gceEnabled {
|
||||
framework.Logf("Enabled gcepd and windows-gcepd in-tree volume drivers")
|
||||
}
|
||||
|
||||
for _, initDriver := range testDrivers {
|
||||
curDriver := initDriver()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user