Skip to content

Commit

Permalink
pkg/machine/e2e: switch to GinkgoWriter
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Luap99 committed May 2, 2023
1 parent c4b9f4b commit 5af4339
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 1 addition & 4 deletions pkg/machine/e2e/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
9 changes: 3 additions & 6 deletions pkg/machine/e2e/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5af4339

Please sign in to comment.