Merge pull request #63780 from pohly/csi-e2e-parameters

Automatic merge from submit-queue (batch tested with PRs 60699, 63780). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

e2e/storage: parameterize container images

**What this PR does / why we need it**:

The CSI integration test for hostpath was hard-coded to use the latest
stable release of the sidecar and hostpath container images. This
makes sense for regression testing of changes made in Kubernetes
itself, but the same test is also useful for testing the "canary"
images on quay.io before tagging them as a new release or for testing
locally produced images. Both is now possible via command line
parameters.

**Which issue(s) this PR fixes**:
Related-to: kubernetes-csi/docs#23

**Special notes for your reviewer**:

The commit message has usage instructions.

```release-note
NONE
```

/sig storage
pull/8/head
Kubernetes Submit Queue 2018-06-08 11:26:09 -07:00 committed by GitHub
commit a9d2b5eeae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 10 deletions

View File

@ -113,6 +113,8 @@ 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
@ -160,6 +162,14 @@ 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
@ -293,6 +303,11 @@ 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")
}
// ViperizeFlags sets up all flag and config processing. Future configuration info should be added to viper, not to flags. // ViperizeFlags sets up all flag and config processing. Future configuration info should be added to viper, not to flags.
func ViperizeFlags() { func ViperizeFlags() {
@ -301,6 +316,7 @@ func ViperizeFlags() {
// since go test 'flag's are sort of incompatible w/ flag, glog, etc. // since go test 'flag's are sort of incompatible w/ flag, glog, etc.
RegisterCommonFlags() RegisterCommonFlags()
RegisterClusterFlags() RegisterClusterFlags()
RegisterStorageFlags()
flag.Parse() flag.Parse()
// Part 2: Set Viper provided flags. // Part 2: Set Viper provided flags.

View File

@ -37,12 +37,23 @@ import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
) )
const ( var csiImageVersions = map[string]string{
csiHostPathPluginImage string = "quay.io/k8scsi/hostpathplugin:v0.2.0" "hostpathplugin": "v0.2.0",
csiExternalAttacherImage string = "quay.io/k8scsi/csi-attacher:v0.2.0" "csi-attacher": "v0.2.0",
csiExternalProvisionerImage string = "quay.io/k8scsi/csi-provisioner:v0.2.1" "csi-provisioner": "v0.2.1",
csiDriverRegistrarImage string = "quay.io/k8scsi/driver-registrar:v0.2.0" "driver-registrar": "v0.2.0",
) }
func csiContainerImage(image string) string {
var fullName string
fullName += framework.TestContext.CSIImageRegistry + "/" + image + ":"
if framework.TestContext.CSIImageVersion != "" {
fullName += framework.TestContext.CSIImageVersion
} else {
fullName += csiImageVersions[image]
}
return fullName
}
// Create the driver registrar cluster role if it doesn't exist, no teardown so that tests // Create the driver registrar cluster role if it doesn't exist, no teardown so that tests
// are parallelizable. This role will be shared with many of the CSI tests. // are parallelizable. This role will be shared with many of the CSI tests.
@ -207,7 +218,7 @@ func csiHostPathPod(
Containers: []v1.Container{ Containers: []v1.Container{
{ {
Name: "external-provisioner", Name: "external-provisioner",
Image: csiExternalProvisionerImage, Image: csiContainerImage("csi-provisioner"),
ImagePullPolicy: v1.PullAlways, ImagePullPolicy: v1.PullAlways,
Args: []string{ Args: []string{
"--v=5", "--v=5",
@ -223,7 +234,7 @@ func csiHostPathPod(
}, },
{ {
Name: "driver-registrar", Name: "driver-registrar",
Image: csiDriverRegistrarImage, Image: csiContainerImage("driver-registrar"),
ImagePullPolicy: v1.PullAlways, ImagePullPolicy: v1.PullAlways,
Args: []string{ Args: []string{
"--v=5", "--v=5",
@ -248,7 +259,7 @@ func csiHostPathPod(
}, },
{ {
Name: "external-attacher", Name: "external-attacher",
Image: csiExternalAttacherImage, Image: csiContainerImage("csi-attacher"),
ImagePullPolicy: v1.PullAlways, ImagePullPolicy: v1.PullAlways,
Args: []string{ Args: []string{
"--v=5", "--v=5",
@ -269,7 +280,7 @@ func csiHostPathPod(
}, },
{ {
Name: "hostpath-driver", Name: "hostpath-driver",
Image: csiHostPathPluginImage, Image: csiContainerImage("hostpathplugin"),
ImagePullPolicy: v1.PullAlways, ImagePullPolicy: v1.PullAlways,
SecurityContext: &v1.SecurityContext{ SecurityContext: &v1.SecurityContext{
Privileged: &priv, Privileged: &priv,