From 5af433923799dab9724f16c8b7af370c4dac2211 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 2 May 2023 12:05:56 +0200 Subject: [PATCH] pkg/machine/e2e: switch to GinkgoWriter Directly writing to stdout/err is not safe when run in parallel. Ginkgo v2 fixed this buffering the output and syncing the output so it is not mangled between tests. This is the same as for the podman integration tests. Signed-off-by: Paul Holzinger --- pkg/machine/e2e/config_test.go | 5 +---- pkg/machine/e2e/machine_test.go | 9 +++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/pkg/machine/e2e/config_test.go b/pkg/machine/e2e/config_test.go index b9d75567b9..157bfc57f7 100644 --- a/pkg/machine/e2e/config_test.go +++ b/pkg/machine/e2e/config_test.go @@ -50,8 +50,6 @@ type machineTestBuilder struct { // number of seconds func (ms *machineSession) waitWithTimeout(timeout time.Duration) { Eventually(ms, timeout).Should(Exit()) - os.Stdout.Sync() - os.Stderr.Sync() } func (ms *machineSession) Bytes() []byte { @@ -154,7 +152,7 @@ func runWrapper(podmanBinary string, cmdArgs []string, timeout time.Duration, wa if len(os.Getenv("DEBUG")) > 0 { cmdArgs = append([]string{"--log-level=debug"}, cmdArgs...) } - fmt.Println(podmanBinary + " " + strings.Join(cmdArgs, " ")) + GinkgoWriter.Println(podmanBinary + " " + strings.Join(cmdArgs, " ")) c := exec.Command(podmanBinary, cmdArgs...) session, err := Start(c, GinkgoWriter, GinkgoWriter) if err != nil { @@ -164,7 +162,6 @@ func runWrapper(podmanBinary string, cmdArgs []string, timeout time.Duration, wa ms := machineSession{session} if wait { ms.waitWithTimeout(timeout) - fmt.Println("output:", ms.outputToString()) } return &ms, nil } diff --git a/pkg/machine/e2e/machine_test.go b/pkg/machine/e2e/machine_test.go index 1bd2f70c51..76f5dfe049 100644 --- a/pkg/machine/e2e/machine_test.go +++ b/pkg/machine/e2e/machine_test.go @@ -61,7 +61,7 @@ var _ = BeforeSuite(func() { if err := machine.DownloadVMImage(getMe, suiteImageName, fqImageName+".xz"); err != nil { Fail(fmt.Sprintf("unable to download machine image: %q", err)) } - fmt.Println("Download took: ", time.Since(now).String()) + GinkgoWriter.Println("Download took: ", time.Since(now).String()) if err := machine.Decompress(fqImageName+".xz", fqImageName); err != nil { Fail(fmt.Sprintf("unable to decompress image file: %q", err)) } @@ -71,10 +71,7 @@ var _ = BeforeSuite(func() { } }) -var _ = SynchronizedAfterSuite(func() {}, - func() { - fmt.Println("After") - }) +var _ = SynchronizedAfterSuite(func() {}, func() {}) func setup() (string, *machineTestBuilder) { // Set TMPDIR if this needs a new directory @@ -127,7 +124,7 @@ func teardown(origHomeDir string, testDir string, mb *machineTestBuilder) { r := new(rmMachine) for _, name := range mb.names { if _, err := mb.setName(name).setCmd(r.withForce()).run(); err != nil { - fmt.Printf("error occurred rm'ing machine: %q\n", err) + GinkgoWriter.Printf("error occurred rm'ing machine: %q\n", err) } } if err := machine.GuardedRemoveAll(testDir); err != nil {