e2e/storage: parameterize container images

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.

Testing "canary" images on quay.io:

  go run hack/e2e.go -- --provider=local --test \
     --test_args="--ginkgo.focus=CSI.plugin.test.using.CSI.driver..hostPath -csiImageVersion=canary"

Testing local container images:

  # https://docs.docker.com/registry/deploying/
  docker run -d -p 5000:5000 --restart=always --name registry registry:2
  for i in driver-registrar drivers external-attacher external-provisioner; do
     make -C $i REGISTRY_NAME=localhost:5000 push
  done
  go run hack/e2e.go -- --provider=local --test \
     --test_args="--ginkgo.focus=CSI.plugin.test.using.CSI.driver..hostPath -csiImageVersion=canary -csiImageRegistry=localhost:5000"
This commit is contained in:
Patrick Ohly 2018-05-09 11:00:41 +02:00
parent 82abc961b9
commit 54d9c4ea25

View File

@ -20,6 +20,7 @@ limitations under the License.
package storage
import (
"flag"
"fmt"
"time"
@ -37,12 +38,30 @@ import (
. "github.com/onsi/ginkgo"
)
const (
csiHostPathPluginImage string = "quay.io/k8scsi/hostpathplugin:v0.2.0"
csiExternalAttacherImage string = "quay.io/k8scsi/csi-attacher:v0.2.0"
csiExternalProvisionerImage string = "quay.io/k8scsi/csi-provisioner:v0.2.1"
csiDriverRegistrarImage string = "quay.io/k8scsi/driver-registrar:v0.2.0"
)
var csiImageVersions = map[string]string{
"hostpathplugin": "v0.2.0",
"csi-attacher": "v0.2.0",
"csi-provisioner": "v0.2.1",
"driver-registrar": "v0.2.0",
}
var csiImageVersion string
var csiImageRegistry string
func init() {
flag.StringVar(&csiImageVersion, "csiImageVersion", "", "overrides the default tag used for hostpathplugin/csi-attacher/csi-provisioner/driver-registrar images")
flag.StringVar(&csiImageRegistry, "csiImageRegistry", "quay.io/k8scsi", "overrides the default repository used for hostpathplugin/csi-attacher/csi-provisioner/driver-registrar images")
}
func csiContainerImage(image string) string {
var fullName string
fullName += csiImageRegistry + "/" + image + ":"
if csiImageVersion != "" {
fullName += csiImageVersion
} else {
fullName += csiImageVersions[image]
}
return fullName
}
// 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.
@ -207,7 +226,7 @@ func csiHostPathPod(
Containers: []v1.Container{
{
Name: "external-provisioner",
Image: csiExternalProvisionerImage,
Image: csiContainerImage("csi-provisioner"),
ImagePullPolicy: v1.PullAlways,
Args: []string{
"--v=5",
@ -223,7 +242,7 @@ func csiHostPathPod(
},
{
Name: "driver-registrar",
Image: csiDriverRegistrarImage,
Image: csiContainerImage("driver-registrar"),
ImagePullPolicy: v1.PullAlways,
Args: []string{
"--v=5",
@ -248,7 +267,7 @@ func csiHostPathPod(
},
{
Name: "external-attacher",
Image: csiExternalAttacherImage,
Image: csiContainerImage("csi-attacher"),
ImagePullPolicy: v1.PullAlways,
Args: []string{
"--v=5",
@ -269,7 +288,7 @@ func csiHostPathPod(
},
{
Name: "hostpath-driver",
Image: csiHostPathPluginImage,
Image: csiContainerImage("hostpathplugin"),
ImagePullPolicy: v1.PullAlways,
SecurityContext: &v1.SecurityContext{
Privileged: &priv,