Merge pull request #116057 from bobbypage/nodee2elog

test: Add log artifact for ginkgo node e2e and tune default ginkgo flags
This commit is contained in:
Kubernetes Prow Robot 2023-03-01 16:55:16 -08:00 committed by GitHub
commit 1646ed8222
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 36 deletions

View File

@ -196,12 +196,15 @@ func (n *NodeE2ERemote) RunTest(host, workspace, results, imageDesc, junitFilePr
systemSpecFile = systemSpecName + ".yaml" systemSpecFile = systemSpecName + ".yaml"
} }
outputGinkgoFile := filepath.Join(results, fmt.Sprintf("%s-ginkgo.log", host))
// Run the tests // Run the tests
klog.V(2).Infof("Starting tests on %q", host) klog.V(2).Infof("Starting tests on %q", host)
cmd := getSSHCommand(" && ", cmd := getSSHCommand(" && ",
fmt.Sprintf("cd %s", workspace), fmt.Sprintf("cd %s", workspace),
fmt.Sprintf("timeout -k 30s %fs ./ginkgo %s ./e2e_node.test -- --system-spec-name=%s --system-spec-file=%s --extra-envs=%s --runtime-config=%s --v 4 --node-name=%s --report-dir=%s --report-prefix=%s --image-description=\"%s\" %s", // Note, we need to have set -o pipefail here to ensure we return the appriorate exit code from ginkgo; not tee
timeout.Seconds(), ginkgoArgs, systemSpecName, systemSpecFile, extraEnvs, runtimeConfig, host, results, junitFilePrefix, imageDesc, testArgs), fmt.Sprintf("set -o pipefail; timeout -k 30s %fs ./ginkgo %s ./e2e_node.test -- --system-spec-name=%s --system-spec-file=%s --extra-envs=%s --runtime-config=%s --v 4 --node-name=%s --report-dir=%s --report-prefix=%s --image-description=\"%s\" %s 2>&1 | tee -i %s",
timeout.Seconds(), ginkgoArgs, systemSpecName, systemSpecFile, extraEnvs, runtimeConfig, host, results, junitFilePrefix, imageDesc, testArgs, outputGinkgoFile),
) )
return SSH(host, "sh", "-c", cmd) return SSH(host, "/bin/bash", "-c", cmd)
} }

View File

@ -166,8 +166,6 @@ type GCEImage struct {
Metadata string `json:"metadata"` Metadata string `json:"metadata"`
Machine string `json:"machine,omitempty"` Machine string `json:"machine,omitempty"`
Resources Resources `json:"resources,omitempty"` Resources Resources `json:"resources,omitempty"`
// This test is for benchmark (no limit verification, more result log, node name has format 'machine-image-uuid') if 'Tests' is non-empty.
Tests []string `json:"tests,omitempty"`
} }
type internalImageConfig struct { type internalImageConfig struct {
@ -185,7 +183,6 @@ type internalGCEImage struct {
resources Resources resources Resources
metadata *compute.Metadata metadata *compute.Metadata
machine string machine string
tests []string
} }
func main() { func main() {
@ -225,6 +222,10 @@ func main() {
return return
} }
// Append some default ginkgo flags. We use similar defaults here as hack/ginkgo-e2e.sh
allGinkgoFlags := fmt.Sprintf("%s --no-color -v", *ginkgoFlags)
fmt.Printf("Will use ginkgo flags as: %s", allGinkgoFlags)
var gceImages *internalImageConfig var gceImages *internalImageConfig
if *mode == "gce" { if *mode == "gce" {
if *hosts == "" && *imageConfigFile == "" && *images == "" { if *hosts == "" && *imageConfigFile == "" && *images == "" {
@ -263,8 +264,9 @@ func main() {
imageConfig := gceImages.images[shortName] imageConfig := gceImages.images[shortName]
fmt.Printf("Initializing e2e tests using image %s/%s/%s.\n", shortName, imageConfig.project, imageConfig.image) fmt.Printf("Initializing e2e tests using image %s/%s/%s.\n", shortName, imageConfig.project, imageConfig.image)
running++ running++
go func(image *internalGCEImage, junitFileName string) { go func(image *internalGCEImage, junitFileName string) {
results <- testImage(image, junitFileName) results <- testImage(image, junitFileName, allGinkgoFlags)
}(&imageConfig, shortName) }(&imageConfig, shortName)
} }
} }
@ -273,7 +275,7 @@ func main() {
fmt.Printf("Initializing e2e tests using host %s.\n", host) fmt.Printf("Initializing e2e tests using host %s.\n", host)
running++ running++
go func(host string, junitFileName string) { go func(host string, junitFileName string) {
results <- testHost(host, *cleanup, "", junitFileName, *ginkgoFlags) results <- testHost(host, *cleanup, "", junitFileName, allGinkgoFlags)
}(host, host) }(host, host)
} }
} }
@ -292,9 +294,9 @@ func main() {
fmt.Printf("%s\n", tr.output) fmt.Printf("%s\n", tr.output)
if tr.err != nil { if tr.err != nil {
errCount++ errCount++
fmt.Printf("Failure Finished Test Suite on Host %s\n%v\n", host, tr.err) fmt.Printf("Failure Finished Test Suite on Host %s. Refer to artifacts directory for ginkgo log for this host.\n%v\n", host, tr.err)
} else { } else {
fmt.Printf("Success Finished Test Suite on Host %s\n", host) fmt.Printf("Success Finished Test Suite on Host %s. Refer to artifacts directory for ginkgo log for this host.\n", host)
} }
exitOk = exitOk && tr.exitOk exitOk = exitOk && tr.exitOk
fmt.Printf("%s<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<%s\n", blue, noColour) fmt.Printf("%s<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<%s\n", blue, noColour)
@ -359,7 +361,6 @@ func prepareGceImages() (*internalImageConfig, error) {
metadata: getImageMetadata(metadata), metadata: getImageMetadata(metadata),
kernelArguments: imageConfig.KernelArguments, kernelArguments: imageConfig.KernelArguments,
machine: imageConfig.Machine, machine: imageConfig.Machine,
tests: imageConfig.Tests,
resources: imageConfig.Resources, resources: imageConfig.Resources,
} }
if gceImage.imageDesc == "" { if gceImage.imageDesc == "" {
@ -536,18 +537,7 @@ func getGCEImage(imageRegex, imageFamily string, project string) (string, error)
// Provision a gce instance using image and run the tests in archive against the instance. // Provision a gce instance using image and run the tests in archive against the instance.
// Delete the instance afterward. // Delete the instance afterward.
func testImage(imageConfig *internalGCEImage, junitFileName string) *TestResult { func testImage(imageConfig *internalGCEImage, junitFileName string, ginkgoFlagsStr string) *TestResult {
ginkgoFlagsStr := *ginkgoFlags
// Check whether the test is for benchmark.
if len(imageConfig.tests) > 0 {
// Benchmark needs machine type non-empty.
if imageConfig.machine == "" {
imageConfig.machine = defaultMachine
}
// Use the Ginkgo focus in benchmark config.
ginkgoFlagsStr += (" " + testsToGinkgoFocus(imageConfig.tests))
}
host, err := createInstance(imageConfig) host, err := createInstance(imageConfig)
if *deleteInstances { if *deleteInstances {
defer deleteInstance(host) defer deleteInstance(host)
@ -963,16 +953,3 @@ func machineType(machine string) string {
} }
return fmt.Sprintf("zones/%s/machineTypes/%s", *zone, machine) return fmt.Sprintf("zones/%s/machineTypes/%s", *zone, machine)
} }
// testsToGinkgoFocus converts the test string list to Ginkgo focus
func testsToGinkgoFocus(tests []string) string {
focus := "--focus=\""
for i, test := range tests {
if i == 0 {
focus += test
} else {
focus += ("|" + test)
}
}
return focus + "\""
}