mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-08-28 01:47:20 +00:00
Allow e2e test to pick up test VM image using image family
This commit is contained in:
@@ -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.")
|
||||
|
||||
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user