e2e/storage: decentralized settings

Tests shouldn't have to use the central context for their settings,
because conceptually tests and framework get developed independently.

This does not yet use the new framework/config utility code because
that code still needs to be reviewed.

Besides moving the flags, they also get renamed from the top-level
"--csiImage{Version|Registry}" to
"--storage.csi.image.{version|registry}". These flags were introduced
fairly recently and shouldn't be in use much, so now is a good time to
introduce a hierarchical naming for storage flags, in particular
because more flags will be added soon.
This commit is contained in:
Patrick Ohly 2018-07-27 17:21:54 +02:00
parent cf0dcc6ab2
commit 8cde9c08f0
2 changed files with 14 additions and 25 deletions

View File

@ -142,8 +142,6 @@ type TestContextType struct {
FeatureGates map[string]bool FeatureGates map[string]bool
// Node e2e specific test context // Node e2e specific test context
NodeTestContextType NodeTestContextType
// Storage e2e specific test context
StorageTestContextType
// Monitoring solution that is used in current cluster. // Monitoring solution that is used in current cluster.
ClusterMonitoringMode string ClusterMonitoringMode string
// Separate Prometheus monitoring deployed in cluster // Separate Prometheus monitoring deployed in cluster
@ -185,14 +183,6 @@ type NodeTestContextType struct {
SystemSpecName string SystemSpecName string
} }
// StorageConfig contains the shared settings for storage 2e2 tests.
type StorageTestContextType struct {
// CSIImageVersion overrides the builtin stable version numbers if set.
CSIImageVersion string
// CSIImageRegistry defines the image registry hosting the CSI container images.
CSIImageRegistry string
}
type CloudConfig struct { type CloudConfig struct {
ApiEndpoint string ApiEndpoint string
ProjectID string ProjectID string
@ -326,16 +316,10 @@ func RegisterNodeFlags() {
flag.StringVar(&TestContext.SystemSpecName, "system-spec-name", "", "The name of the system spec (e.g., gke) that's used in the node e2e test. The system specs are in test/e2e_node/system/specs/. This is used by the test framework to determine which tests to run for validating the system requirements.") flag.StringVar(&TestContext.SystemSpecName, "system-spec-name", "", "The name of the system spec (e.g., gke) that's used in the node e2e test. The system specs are in test/e2e_node/system/specs/. This is used by the test framework to determine which tests to run for validating the system requirements.")
} }
func RegisterStorageFlags() {
flag.StringVar(&TestContext.CSIImageVersion, "csiImageVersion", "", "overrides the default tag used for hostpathplugin/csi-attacher/csi-provisioner/driver-registrar images")
flag.StringVar(&TestContext.CSIImageRegistry, "csiImageRegistry", "quay.io/k8scsi", "overrides the default repository used for hostpathplugin/csi-attacher/csi-provisioner/driver-registrar images")
}
// HandleFlags sets up all flags and parses the command line. // HandleFlags sets up all flags and parses the command line.
func HandleFlags() { func HandleFlags() {
RegisterCommonFlags() RegisterCommonFlags()
RegisterClusterFlags() RegisterClusterFlags()
RegisterStorageFlags()
flag.Parse() flag.Parse()
} }

View File

@ -20,6 +20,7 @@ limitations under the License.
package storage package storage
import ( import (
"flag"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
@ -46,18 +47,22 @@ import (
csicrd "k8s.io/csi-api/pkg/crd" csicrd "k8s.io/csi-api/pkg/crd"
) )
var csiImageVersions = map[string]string{ var (
"hostpathplugin": "v0.4.0", csiImageVersion = flag.String("storage.csi.image.version", "", "overrides the default tag used for hostpathplugin/csi-attacher/csi-provisioner/driver-registrar images")
"csi-attacher": "v0.4.0", csiImageRegistry = flag.String("storage.csi.image.registry", "quay.io/k8scsi", "overrides the default repository used for hostpathplugin/csi-attacher/csi-provisioner/driver-registrar images")
"csi-provisioner": "v0.4.0", csiImageVersions = map[string]string{
"driver-registrar": "v0.4.0", "hostpathplugin": "v0.4.0",
} "csi-attacher": "v0.4.0",
"csi-provisioner": "v0.4.0",
"driver-registrar": "v0.4.0",
}
)
func csiContainerImage(image string) string { func csiContainerImage(image string) string {
var fullName string var fullName string
fullName += framework.TestContext.CSIImageRegistry + "/" + image + ":" fullName += *csiImageRegistry + "/" + image + ":"
if framework.TestContext.CSIImageVersion != "" { if *csiImageVersion != "" {
fullName += framework.TestContext.CSIImageVersion fullName += *csiImageVersion
} else { } else {
fullName += csiImageVersions[image] fullName += csiImageVersions[image]
} }