Skip to content

Commit 56f42d9

Browse files
authored
Merge pull request #353 from xueweiz/family
Allow e2e test to pick up test VM image using image family
2 parents 9828ab7 + 1989ab3 commit 56f42d9

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ e2e-test: vet fmt build-tar
112112
GO111MODULE=on go test -mod vendor -timeout=10m -v $(BUILD_TAGS) \
113113
./test/e2e/metriconly/... \
114114
-project=$(PROJECT) -zone=$(ZONE) \
115-
-image=$(VM_IMAGE) -image-project=$(IMAGE_PROJECT) \
115+
-image=$(VM_IMAGE) -image-family=$(IMAGE_FAMILY) -image-project=$(IMAGE_PROJECT) \
116116
-ssh-user=$(SSH_USER) -ssh-key=$(SSH_KEY) \
117117
-npd-build-tar=`pwd`/$(TARBALL) \
118118
-boskos-project-type=$(BOSKOS_PROJECT_TYPE) -job-name=$(JOB_NAME) \

test/e2e/metriconly/e2e_npd_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const junitFileName = "junit.xml"
3838
var zone = flag.String("zone", "", "gce zone the hosts live in")
3939
var project = flag.String("project", "", "gce project the hosts live in")
4040
var image = flag.String("image", "", "image to test")
41+
var imageFamily = flag.String("image-family", "", "image family to pick up the test image. Ignored when -image is set.")
4142
var imageProject = flag.String("image-project", "", "gce project of the OS image")
4243
var jobName = flag.String("job-name", "", "name of the Prow job running the test")
4344
var sshKey = flag.String("ssh-key", "", "path to ssh private key.")

test/e2e/metriconly/metrics_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ var _ = ginkgo.Describe("NPD should export Prometheus metrics.", func() {
3737
var err error
3838
// TODO(xueweiz): Creating instance for each test case is slow. We should either reuse the instance
3939
// between tests, or have a way to run these tests in parallel.
40+
if *imageFamily != "" && *image == "" {
41+
gceImage, err := computeService.Images.GetFromFamily(*imageProject, *imageFamily).Do()
42+
if err != nil {
43+
ginkgo.Fail(fmt.Sprintf("Unable to get image from family %s at project %s: %v",
44+
*imageFamily, *imageProject, err))
45+
}
46+
*image = gceImage.Name
47+
fmt.Printf("Using image %s from image family %s at project %s\n", *image, *imageFamily, *imageProject)
48+
}
4049
instance, err = gce.CreateInstance(
4150
gce.Instance{
4251
Name: "npd-metrics-" + *image + "-" + uuid.NewUUID().String()[:8],

0 commit comments

Comments
 (0)