Merge pull request #353 from xueweiz/family

Allow e2e test to pick up test VM image using image family
This commit is contained in:
Kubernetes Prow Robot
2019-09-18 23:45:00 -07:00
committed by GitHub
3 changed files with 11 additions and 1 deletions

View File

@@ -112,7 +112,7 @@ e2e-test: vet fmt build-tar
GO111MODULE=on go test -mod vendor -timeout=10m -v $(BUILD_TAGS) \
./test/e2e/metriconly/... \
-project=$(PROJECT) -zone=$(ZONE) \
-image=$(VM_IMAGE) -image-project=$(IMAGE_PROJECT) \
-image=$(VM_IMAGE) -image-family=$(IMAGE_FAMILY) -image-project=$(IMAGE_PROJECT) \
-ssh-user=$(SSH_USER) -ssh-key=$(SSH_KEY) \
-npd-build-tar=`pwd`/$(TARBALL) \
-boskos-project-type=$(BOSKOS_PROJECT_TYPE) -job-name=$(JOB_NAME) \

View File

@@ -38,6 +38,7 @@ const junitFileName = "junit.xml"
var zone = flag.String("zone", "", "gce zone the hosts live in")
var project = flag.String("project", "", "gce project the hosts live in")
var image = flag.String("image", "", "image to test")
var imageFamily = flag.String("image-family", "", "image family to pick up the test image. Ignored when -image is set.")
var imageProject = flag.String("image-project", "", "gce project of the OS image")
var jobName = flag.String("job-name", "", "name of the Prow job running the test")
var sshKey = flag.String("ssh-key", "", "path to ssh private key.")

View File

@@ -37,6 +37,15 @@ var _ = ginkgo.Describe("NPD should export Prometheus metrics.", func() {
var err error
// TODO(xueweiz): Creating instance for each test case is slow. We should either reuse the instance
// between tests, or have a way to run these tests in parallel.
if *imageFamily != "" && *image == "" {
gceImage, err := computeService.Images.GetFromFamily(*imageProject, *imageFamily).Do()
if err != nil {
ginkgo.Fail(fmt.Sprintf("Unable to get image from family %s at project %s: %v",
*imageFamily, *imageProject, err))
}
*image = gceImage.Name
fmt.Printf("Using image %s from image family %s at project %s\n", *image, *imageFamily, *imageProject)
}
instance, err = gce.CreateInstance(
gce.Instance{
Name: "npd-metrics-" + *image + "-" + uuid.NewUUID().String()[:8],