test/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 means we should use the GinkgoWriter everywhere to make sure the output stays in sync. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
cc19091e91
commit
fb7a96638c
|
|
@ -1072,7 +1072,7 @@ var _ = Describe("Podman checkpoint", func() {
|
|||
Fail("Container failed to get ready")
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stderr, "Trying to connect to redis server at localhost:%d", randomPort)
|
||||
GinkgoWriter.Printf("Trying to connect to redis server at localhost:%d\n", randomPort)
|
||||
// Open a network connection to the redis server via initial port mapping
|
||||
conn, err := net.DialTimeout("tcp4", fmt.Sprintf("localhost:%d", randomPort), time.Duration(3)*time.Second)
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
|
|
@ -1105,7 +1105,7 @@ var _ = Describe("Podman checkpoint", func() {
|
|||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("connection refused"))
|
||||
// Open a network connection to the redis server via new port mapping
|
||||
fmt.Fprintf(os.Stderr, "Trying to reconnect to redis server at localhost:%d", newRandomPort)
|
||||
GinkgoWriter.Printf("Trying to reconnect to redis server at localhost:%d\n", newRandomPort)
|
||||
conn, err = net.DialTimeout("tcp4", fmt.Sprintf("localhost:%d", newRandomPort), time.Duration(3)*time.Second)
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
conn.Close()
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
|
|||
// make cache dir
|
||||
ImageCacheDir = filepath.Join(os.TempDir(), "imagecachedir")
|
||||
if err := os.MkdirAll(ImageCacheDir, 0700); err != nil {
|
||||
fmt.Printf("%q\n", err)
|
||||
GinkgoWriter.Printf("%q\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
|
|||
}
|
||||
|
||||
if err := os.MkdirAll(filepath.Join(ImageCacheDir, podman.ImageCacheFS+"-images"), 0777); err != nil {
|
||||
fmt.Printf("%q\n", err)
|
||||
GinkgoWriter.Printf("%q\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
podman.Root = ImageCacheDir
|
||||
|
|
@ -134,19 +134,19 @@ var _ = SynchronizedBeforeSuite(func() []byte {
|
|||
if host.Distribution == "rhel" && strings.HasPrefix(host.Version, "7") {
|
||||
f, err := os.OpenFile("/proc/sys/user/max_user_namespaces", os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
fmt.Println("Unable to enable userspace on RHEL 7")
|
||||
GinkgoWriter.Println("Unable to enable userspace on RHEL 7")
|
||||
os.Exit(1)
|
||||
}
|
||||
_, err = f.WriteString("15000")
|
||||
if err != nil {
|
||||
fmt.Println("Unable to enable userspace on RHEL 7")
|
||||
GinkgoWriter.Println("Unable to enable userspace on RHEL 7")
|
||||
os.Exit(1)
|
||||
}
|
||||
f.Close()
|
||||
}
|
||||
path, err := os.MkdirTemp("", "libpodlock")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
GinkgoWriter.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
|
@ -170,9 +170,9 @@ func (p *PodmanTestIntegration) Setup() {
|
|||
var _ = SynchronizedAfterSuite(func() {},
|
||||
func() {
|
||||
sort.Sort(testResultsSortedLength{testResults})
|
||||
fmt.Println("integration timing results")
|
||||
GinkgoWriter.Println("integration timing results")
|
||||
for _, result := range testResults {
|
||||
fmt.Printf("%s\t\t%f\n", result.name, result.length)
|
||||
GinkgoWriter.Printf("%s\t\t%f\n", result.name, result.length)
|
||||
}
|
||||
|
||||
// previous runroot
|
||||
|
|
@ -184,7 +184,7 @@ var _ = SynchronizedAfterSuite(func() {},
|
|||
defer os.RemoveAll(tempdir)
|
||||
|
||||
if err := os.RemoveAll(podmanTest.Root); err != nil {
|
||||
fmt.Printf("%q\n", err)
|
||||
GinkgoWriter.Printf("%q\n", err)
|
||||
}
|
||||
|
||||
// If running remote, we need to stop the associated podman system service
|
||||
|
|
@ -376,7 +376,7 @@ func (p *PodmanTestIntegration) createArtifact(image string) {
|
|||
}
|
||||
destName := imageTarPath(image)
|
||||
if _, err := os.Stat(destName); os.IsNotExist(err) {
|
||||
fmt.Printf("Caching %s at %s...\n", image, destName)
|
||||
GinkgoWriter.Printf("Caching %s at %s...\n", image, destName)
|
||||
pull := p.PodmanNoCache([]string{"pull", image})
|
||||
pull.Wait(440)
|
||||
Expect(pull).Should(Exit(0))
|
||||
|
|
@ -384,9 +384,9 @@ func (p *PodmanTestIntegration) createArtifact(image string) {
|
|||
save := p.PodmanNoCache([]string{"save", "-o", destName, image})
|
||||
save.Wait(90)
|
||||
Expect(save).Should(Exit(0))
|
||||
fmt.Printf("\n")
|
||||
GinkgoWriter.Printf("\n")
|
||||
} else {
|
||||
fmt.Printf("[image already cached: %s]\n", destName)
|
||||
GinkgoWriter.Printf("[image already cached: %s]\n", destName)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -419,7 +419,7 @@ func GetPortLock(port string) *lockfile.LockFile {
|
|||
lockFile := filepath.Join(LockTmpDir, port)
|
||||
lock, err := lockfile.GetLockFile(lockFile)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
GinkgoWriter.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
lock.Lock()
|
||||
|
|
@ -534,7 +534,7 @@ func (p *PodmanTestIntegration) BuildImageWithLabel(dockerfile, imageName string
|
|||
// PodmanPID execs podman and returns its PID
|
||||
func (p *PodmanTestIntegration) PodmanPID(args []string) (*PodmanSessionIntegration, int) {
|
||||
podmanOptions := p.MakeOptions(args, false, false)
|
||||
fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
|
||||
GinkgoWriter.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
|
||||
|
||||
command := exec.Command(p.PodmanBinary, podmanOptions...)
|
||||
session, err := Start(command, GinkgoWriter, GinkgoWriter)
|
||||
|
|
@ -546,7 +546,7 @@ func (p *PodmanTestIntegration) PodmanPID(args []string) (*PodmanSessionIntegrat
|
|||
}
|
||||
|
||||
func (p *PodmanTestIntegration) Quadlet(args []string, sourceDir string) *PodmanSessionIntegration {
|
||||
fmt.Printf("Running: %s %s with QUADLET_UNIT_DIRS=%s\n", p.QuadletBinary, strings.Join(args, " "), sourceDir)
|
||||
GinkgoWriter.Printf("Running: %s %s with QUADLET_UNIT_DIRS=%s\n", p.QuadletBinary, strings.Join(args, " "), sourceDir)
|
||||
|
||||
// quadlet uses PODMAN env to get a stable podman path
|
||||
podmanPath, found := os.LookupEnv("PODMAN")
|
||||
|
|
@ -616,7 +616,7 @@ func (p *PodmanTestIntegration) CleanupSecrets() {
|
|||
|
||||
// Nuke tempdir
|
||||
if err := os.RemoveAll(p.TempDir); err != nil {
|
||||
fmt.Printf("%q\n", err)
|
||||
GinkgoWriter.Printf("%q\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -676,7 +676,7 @@ func (p *PodmanTestIntegration) RunHealthCheck(cid string) error {
|
|||
ps.WaitWithDefaultTimeout()
|
||||
if ps.ExitCode() == 0 {
|
||||
if !strings.Contains(ps.OutputToString(), cid) {
|
||||
fmt.Printf("Container %s is not running, restarting", cid)
|
||||
GinkgoWriter.Printf("Container %s is not running, restarting", cid)
|
||||
restart := p.Podman([]string{"restart", cid})
|
||||
restart.WaitWithDefaultTimeout()
|
||||
if restart.ExitCode() != 0 {
|
||||
|
|
@ -684,7 +684,7 @@ func (p *PodmanTestIntegration) RunHealthCheck(cid string) error {
|
|||
}
|
||||
}
|
||||
}
|
||||
fmt.Printf("Waiting for %s to pass healthcheck\n", cid)
|
||||
GinkgoWriter.Printf("Waiting for %s to pass healthcheck\n", cid)
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
return fmt.Errorf("unable to detect %s as running", cid)
|
||||
|
|
@ -896,7 +896,7 @@ func (p *PodmanTestIntegration) RestartRemoteService() {
|
|||
func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error {
|
||||
tarball := imageTarPath(image)
|
||||
if _, err := os.Stat(tarball); err == nil {
|
||||
fmt.Printf("Restoring %s...\n", image)
|
||||
GinkgoWriter.Printf("Restoring %s...\n", image)
|
||||
p.Root = p.ImageCacheDir
|
||||
restore := p.PodmanNoEvents([]string{"load", "-q", "-i", tarball})
|
||||
restore.WaitWithDefaultTimeout()
|
||||
|
|
@ -910,7 +910,7 @@ func populateCache(podman *PodmanTestIntegration) {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
// logformatter uses this to recognize the first test
|
||||
fmt.Printf("-----------------------------\n")
|
||||
GinkgoWriter.Printf("-----------------------------\n")
|
||||
}
|
||||
|
||||
func (p *PodmanTestIntegration) removeCache(path string) {
|
||||
|
|
@ -918,14 +918,14 @@ func (p *PodmanTestIntegration) removeCache(path string) {
|
|||
if isRootless() {
|
||||
// If rootless, os.RemoveAll() is failed due to permission denied
|
||||
cmd := exec.Command(p.PodmanBinary, "unshare", "rm", "-rf", path)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = GinkgoWriter
|
||||
cmd.Stderr = GinkgoWriter
|
||||
if err := cmd.Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
GinkgoWriter.Printf("%v\n", err)
|
||||
}
|
||||
} else {
|
||||
if err := os.RemoveAll(path); err != nil {
|
||||
fmt.Printf("%q\n", err)
|
||||
GinkgoWriter.Printf("%q\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -982,17 +982,17 @@ func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache boo
|
|||
func writeConf(conf []byte, confPath string) {
|
||||
if _, err := os.Stat(filepath.Dir(confPath)); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(filepath.Dir(confPath), 0o777); err != nil {
|
||||
fmt.Println(err)
|
||||
GinkgoWriter.Println(err)
|
||||
}
|
||||
}
|
||||
if err := os.WriteFile(confPath, conf, 0o777); err != nil {
|
||||
fmt.Println(err)
|
||||
GinkgoWriter.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
func removeConf(confPath string) {
|
||||
if err := os.Remove(confPath); err != nil {
|
||||
fmt.Println(err)
|
||||
GinkgoWriter.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1169,7 +1169,7 @@ func ncz(port int) bool {
|
|||
timeout := 500 * time.Millisecond
|
||||
for i := 0; i < 5; i++ {
|
||||
ncCmd := []string{"-z", "localhost", fmt.Sprintf("%d", port)}
|
||||
fmt.Printf("Running: nc %s\n", strings.Join(ncCmd, " "))
|
||||
GinkgoWriter.Printf("Running: nc %s\n", strings.Join(ncCmd, " "))
|
||||
check := SystemExec("nc", ncCmd)
|
||||
if check.ExitCode() == 0 {
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ var _ = Describe("Podman events", func() {
|
|||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(0))
|
||||
events := result.OutputToStringArray()
|
||||
fmt.Println(events)
|
||||
GinkgoWriter.Println(events)
|
||||
Expect(len(events)).To(BeNumerically(">=", 2), "Number of events")
|
||||
Expect(events).To(ContainElement(ContainSubstring(" pod create ")))
|
||||
Expect(events).To(ContainElement(ContainSubstring(" pod stop ")))
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ var _ = Describe("Podman image sign", func() {
|
|||
|
||||
It("podman sign image", func() {
|
||||
cmd := exec.Command("gpg", "--import", "sign/secret-key.asc")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = GinkgoWriter
|
||||
cmd.Stderr = GinkgoWriter
|
||||
err := cmd.Run()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
sigDir := filepath.Join(podmanTest.TempDir, "test-sign")
|
||||
|
|
@ -62,8 +62,8 @@ var _ = Describe("Podman image sign", func() {
|
|||
|
||||
It("podman sign --all multi-arch image", func() {
|
||||
cmd := exec.Command("gpg", "--import", "sign/secret-key.asc")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = GinkgoWriter
|
||||
cmd.Stderr = GinkgoWriter
|
||||
err := cmd.Run()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
sigDir := filepath.Join(podmanTest.TempDir, "test-sign-multi")
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
@ -85,9 +86,9 @@ func (p *PodmanTestIntegration) StartRemoteService() {
|
|||
fmt.Sprintf("%s.imagestore=%s", p.PodmanTest.ImageCacheFS, p.PodmanTest.ImageCacheDir)}
|
||||
podmanOptions = append(cacheOptions, podmanOptions...)
|
||||
command := exec.Command(p.PodmanBinary, podmanOptions...)
|
||||
command.Stdout = os.Stdout
|
||||
command.Stderr = os.Stderr
|
||||
fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
|
||||
command.Stdout = GinkgoWriter
|
||||
command.Stderr = GinkgoWriter
|
||||
GinkgoWriter.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
|
||||
err := command.Start()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
command.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||
|
|
@ -98,18 +99,18 @@ func (p *PodmanTestIntegration) StartRemoteService() {
|
|||
|
||||
func (p *PodmanTestIntegration) StopRemoteService() {
|
||||
if err := p.RemoteSession.Kill(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unable to clean up service %d, %v\n", p.RemoteSession.Pid, err)
|
||||
GinkgoWriter.Printf("unable to clean up service %d, %v\n", p.RemoteSession.Pid, err)
|
||||
}
|
||||
if _, err := p.RemoteSession.Wait(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error on remote stop-wait %q", err)
|
||||
GinkgoWriter.Printf("error on remote stop-wait %q", err)
|
||||
}
|
||||
socket := strings.Split(p.RemoteSocket, ":")[1]
|
||||
if err := os.Remove(socket); err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
GinkgoWriter.Printf("%v\n", err)
|
||||
}
|
||||
if p.RemoteSocketLock != "" {
|
||||
if err := os.Remove(p.RemoteSocketLock); err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
GinkgoWriter.Printf("%v\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -128,11 +129,11 @@ func getRemoteOptions(p *PodmanTestIntegration, args []string) []string {
|
|||
func (p *PodmanTestIntegration) RestoreArtifact(image string) error {
|
||||
tarball := imageTarPath(image)
|
||||
if _, err := os.Stat(tarball); err == nil {
|
||||
fmt.Printf("Restoring %s...\n", image)
|
||||
GinkgoWriter.Printf("Restoring %s...\n", image)
|
||||
args := []string{"load", "-q", "-i", tarball}
|
||||
podmanOptions := getRemoteOptions(p, args)
|
||||
command := exec.Command(p.PodmanBinary, podmanOptions...)
|
||||
fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
|
||||
GinkgoWriter.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
|
||||
if err := command.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@
|
|||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ func PodmanTestCreate(tempDir string) *PodmanTestIntegration {
|
|||
func (p *PodmanTestIntegration) RestoreArtifact(image string) error {
|
||||
tarball := imageTarPath(image)
|
||||
if _, err := os.Stat(tarball); err == nil {
|
||||
fmt.Printf("Restoring %s...\n", image)
|
||||
GinkgoWriter.Printf("Restoring %s...\n", image)
|
||||
restore := p.PodmanNoEvents([]string{"load", "-q", "-i", tarball})
|
||||
restore.Wait(90)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ var _ = Describe("Podman load", func() {
|
|||
|
||||
images := podmanTest.Podman([]string{"images"})
|
||||
images.WaitWithDefaultTimeout()
|
||||
fmt.Println(images.OutputToStringArray())
|
||||
GinkgoWriter.Println(images.OutputToStringArray())
|
||||
|
||||
save := podmanTest.Podman([]string{"save", "-o", outfile, ALPINE})
|
||||
save.WaitWithDefaultTimeout()
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ var _ = Describe("Podman login and logout", func() {
|
|||
var authInfo map[string]interface{}
|
||||
err = json.Unmarshal(authBytes, &authInfo)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
fmt.Println(authInfo)
|
||||
GinkgoWriter.Println(authInfo)
|
||||
|
||||
const authsKey = "auths"
|
||||
Expect(authInfo).To(HaveKey(authsKey))
|
||||
|
|
|
|||
|
|
@ -2781,7 +2781,7 @@ var _ = Describe("Podman play kube", func() {
|
|||
// expect play kube is expected to set a seccomp label if it's applied as an annotation
|
||||
jsonFile, err := podmanTest.CreateSeccompJSON(seccompPwdEPERM)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
GinkgoWriter.Println(err)
|
||||
Skip("Failed to prepare seccomp.json for test.")
|
||||
}
|
||||
|
||||
|
|
@ -2808,7 +2808,7 @@ var _ = Describe("Podman play kube", func() {
|
|||
// expect play kube is expected to set a seccomp label if it's applied as an annotation
|
||||
jsonFile, err := podmanTest.CreateSeccompJSON(seccompPwdEPERM)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
GinkgoWriter.Println(err)
|
||||
Skip("Failed to prepare seccomp.json for test.")
|
||||
}
|
||||
defer os.Remove(jsonFile)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
. "github.com/containers/podman/v4/test/utils"
|
||||
|
|
@ -148,7 +147,7 @@ var _ = Describe("Podman pod kill", func() {
|
|||
|
||||
result := podmanTest.Podman([]string{"pod", "kill", "-a"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
fmt.Println(result.OutputToString(), result.ErrorToString())
|
||||
GinkgoWriter.Println(result.OutputToString(), result.ErrorToString())
|
||||
Expect(result).Should(Exit(0))
|
||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
. "github.com/containers/podman/v4/test/utils"
|
||||
|
|
@ -54,9 +53,9 @@ var _ = Describe("Podman pod create", func() {
|
|||
Expect(outputArray).To(HaveLen(2))
|
||||
|
||||
NAMESPACE1 := outputArray[0]
|
||||
fmt.Println("NAMESPACE1:", NAMESPACE1)
|
||||
GinkgoWriter.Println("NAMESPACE1:", NAMESPACE1)
|
||||
NAMESPACE2 := outputArray[1]
|
||||
fmt.Println("NAMESPACE2:", NAMESPACE2)
|
||||
GinkgoWriter.Println("NAMESPACE2:", NAMESPACE2)
|
||||
Expect(NAMESPACE1).To(Equal(NAMESPACE2))
|
||||
})
|
||||
|
||||
|
|
@ -100,9 +99,9 @@ var _ = Describe("Podman pod create", func() {
|
|||
Expect(outputArray).To(HaveLen(2))
|
||||
|
||||
NAMESPACE1 := outputArray[0]
|
||||
fmt.Println("NAMESPACE1:", NAMESPACE1)
|
||||
GinkgoWriter.Println("NAMESPACE1:", NAMESPACE1)
|
||||
NAMESPACE2 := outputArray[1]
|
||||
fmt.Println("NAMESPACE2:", NAMESPACE2)
|
||||
GinkgoWriter.Println("NAMESPACE2:", NAMESPACE2)
|
||||
Expect(NAMESPACE1).To(Not(Equal(NAMESPACE2)))
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -119,28 +119,28 @@ var _ = Describe("Podman pod rm", func() {
|
|||
})
|
||||
|
||||
It("podman pod rm -a doesn't remove a running container", func() {
|
||||
fmt.Printf("To start, there are %d pods\n", podmanTest.NumberOfPods())
|
||||
GinkgoWriter.Printf("To start, there are %d pods\n", podmanTest.NumberOfPods())
|
||||
_, ec, podid1 := podmanTest.CreatePod(nil)
|
||||
Expect(ec).To(Equal(0))
|
||||
|
||||
_, ec, _ = podmanTest.CreatePod(nil)
|
||||
Expect(ec).To(Equal(0))
|
||||
fmt.Printf("Started %d pods\n", podmanTest.NumberOfPods())
|
||||
GinkgoWriter.Printf("Started %d pods\n", podmanTest.NumberOfPods())
|
||||
|
||||
session := podmanTest.RunTopContainerInPod("", podid1)
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
podmanTest.WaitForContainer()
|
||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
|
||||
fmt.Printf("Started container running in one pod")
|
||||
GinkgoWriter.Printf("Started container running in one pod")
|
||||
|
||||
numPods := podmanTest.NumberOfPods()
|
||||
Expect(numPods).To(Equal(2))
|
||||
ps := podmanTest.Podman([]string{"pod", "ps"})
|
||||
ps.WaitWithDefaultTimeout()
|
||||
fmt.Printf("Current %d pod(s):\n%s\n", numPods, ps.OutputToString())
|
||||
GinkgoWriter.Printf("Current %d pod(s):\n%s\n", numPods, ps.OutputToString())
|
||||
|
||||
fmt.Printf("Removing all empty pods\n")
|
||||
GinkgoWriter.Printf("Removing all empty pods\n")
|
||||
result := podmanTest.Podman([]string{"pod", "rm", "-a"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).To(ExitWithError())
|
||||
|
|
@ -150,7 +150,7 @@ var _ = Describe("Podman pod rm", func() {
|
|||
numPods = podmanTest.NumberOfPods()
|
||||
ps = podmanTest.Podman([]string{"pod", "ps"})
|
||||
ps.WaitWithDefaultTimeout()
|
||||
fmt.Printf("Final %d pod(s):\n%s\n", numPods, ps.OutputToString())
|
||||
GinkgoWriter.Printf("Final %d pod(s):\n%s\n", numPods, ps.OutputToString())
|
||||
Expect(numPods).To(Equal(1))
|
||||
// Confirm top container still running inside remaining pod
|
||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ var _ = Describe("Podman top", func() {
|
|||
Expect(session).Should(Exit(0))
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
fmt.Println("Waiting for containers to be running .... ")
|
||||
GinkgoWriter.Println("Waiting for containers to be running .... ")
|
||||
if podmanTest.NumberOfContainersRunning() == 2 {
|
||||
break
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ var _ = Describe("Podman push", func() {
|
|||
cmd := exec.Command("cp", "testdata/sigstore-registries.d-fragment.yaml", systemRegistriesDAddition)
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Skipping sigstore tests because /etc/containers/registries.d isn’t writable: %s", string(output))
|
||||
GinkgoWriter.Printf("Skipping sigstore tests because /etc/containers/registries.d isn’t writable: %s\n", string(output))
|
||||
} else {
|
||||
defer func() {
|
||||
err := os.Remove(systemRegistriesDAddition)
|
||||
|
|
|
|||
|
|
@ -524,7 +524,7 @@ var _ = Describe("quadlet system generator", func() {
|
|||
// Print any stderr output
|
||||
errs := session.ErrorToString()
|
||||
if errs != "" {
|
||||
fmt.Println("error:", session.ErrorToString())
|
||||
GinkgoWriter.Println("error:", session.ErrorToString())
|
||||
}
|
||||
|
||||
testcase.check(generatedDir, session)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
|
|||
buf := make([]byte, 1024)
|
||||
n, err := uds.Read(buf)
|
||||
if err != nil && err != io.EOF {
|
||||
fmt.Println(err)
|
||||
GinkgoWriter.Println(err)
|
||||
return
|
||||
}
|
||||
data := string(buf[0:n])
|
||||
|
|
@ -95,7 +95,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
|
|||
buf := make([]byte, 1024)
|
||||
n, err := uds.Read(buf)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
GinkgoWriter.Println(err)
|
||||
return
|
||||
}
|
||||
data := string(buf[0:n])
|
||||
|
|
|
|||
|
|
@ -126,9 +126,9 @@ var _ = Describe("Podman run with --ip flag", func() {
|
|||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("nginx not ready yet; error=%v; %d retries left...\n", err, retries)
|
||||
GinkgoWriter.Printf("nginx not ready yet; error=%v; %d retries left...\n", err, retries)
|
||||
} else {
|
||||
fmt.Printf("nginx not ready yet; response=%v; %d retries left...\n", response.StatusCode, retries)
|
||||
GinkgoWriter.Printf("nginx not ready yet; response=%v; %d retries left...\n", response.StatusCode, retries)
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ var _ = Describe("Podman run", func() {
|
|||
Expect(tarball).Should(BeARegularFile())
|
||||
|
||||
// N/B: This will loose any extended attributes like SELinux types
|
||||
fmt.Fprintf(os.Stderr, "Extracting container root tarball\n")
|
||||
GinkgoWriter.Printf("Extracting container root tarball\n")
|
||||
tarsession := SystemExec("tar", []string{"xf", tarball, "-C", rootfs})
|
||||
Expect(tarsession).Should(Exit(0))
|
||||
Expect(filepath.Join(rootfs, uls)).Should(BeADirectory())
|
||||
|
|
@ -371,7 +371,7 @@ var _ = Describe("Podman run", func() {
|
|||
in := []byte(`{"defaultAction":"SCMP_ACT_ALLOW","syscalls":[{"name":"getcwd","action":"SCMP_ACT_ERRNO"}]}`)
|
||||
jsonFile, err := podmanTest.CreateSeccompJSON(in)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
GinkgoWriter.Println(err)
|
||||
Skip("Failed to prepare seccomp.json for test.")
|
||||
}
|
||||
return jsonFile
|
||||
|
|
@ -1516,7 +1516,7 @@ USER mail`, BB)
|
|||
curCgroupsBytes, err := os.ReadFile("/proc/self/cgroup")
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
curCgroups := trim(string(curCgroupsBytes))
|
||||
fmt.Printf("Output:\n%s\n", curCgroups)
|
||||
GinkgoWriter.Printf("Output:\n%s\n", curCgroups)
|
||||
Expect(curCgroups).ToNot(Equal(""))
|
||||
|
||||
container := podmanTest.Podman([]string{"run", "--cgroupns=host", "--cgroups=disabled", ALPINE, "cat", "/proc/self/cgroup"})
|
||||
|
|
@ -1524,7 +1524,7 @@ USER mail`, BB)
|
|||
Expect(container).Should(Exit(0))
|
||||
|
||||
ctrCgroups := trim(container.OutputToString())
|
||||
fmt.Printf("Output\n:%s\n", ctrCgroups)
|
||||
GinkgoWriter.Printf("Output\n:%s\n", ctrCgroups)
|
||||
|
||||
Expect(ctrCgroups).To(Equal(curCgroups))
|
||||
})
|
||||
|
|
@ -1539,7 +1539,7 @@ USER mail`, BB)
|
|||
curCgroupsBytes, err := os.ReadFile("/proc/self/cgroup")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
var curCgroups string = string(curCgroupsBytes)
|
||||
fmt.Printf("Output:\n%s\n", curCgroups)
|
||||
GinkgoWriter.Printf("Output:\n%s\n", curCgroups)
|
||||
Expect(curCgroups).To(Not(Equal("")))
|
||||
|
||||
ctrName := "testctr"
|
||||
|
|
@ -1556,7 +1556,7 @@ USER mail`, BB)
|
|||
ctrCgroupsBytes, err := os.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
var ctrCgroups string = string(ctrCgroupsBytes)
|
||||
fmt.Printf("Output\n:%s\n", ctrCgroups)
|
||||
GinkgoWriter.Printf("Output\n:%s\n", ctrCgroups)
|
||||
Expect(curCgroups).To(Not(Equal(ctrCgroups)))
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -387,10 +387,8 @@ var _ = Describe("Podman run with volumes", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
mountCmd1.Wait(90)
|
||||
Expect(mountCmd1).Should(Exit(0))
|
||||
os.Stdout.Sync()
|
||||
os.Stderr.Sync()
|
||||
mountOut1 := strings.Join(strings.Fields(string(mountCmd1.Out.Contents())), " ")
|
||||
fmt.Printf("Output: %s", mountOut1)
|
||||
GinkgoWriter.Printf("Output: %s", mountOut1)
|
||||
Expect(mountOut1).To(Not(ContainSubstring(volName)))
|
||||
|
||||
ctrName := "testctr"
|
||||
|
|
@ -403,10 +401,8 @@ var _ = Describe("Podman run with volumes", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
mountCmd2.Wait(90)
|
||||
Expect(mountCmd2).Should(Exit(0))
|
||||
os.Stdout.Sync()
|
||||
os.Stderr.Sync()
|
||||
mountOut2 := strings.Join(strings.Fields(string(mountCmd2.Out.Contents())), " ")
|
||||
fmt.Printf("Output: %s", mountOut2)
|
||||
GinkgoWriter.Printf("Output: %s", mountOut2)
|
||||
Expect(mountOut2).To(ContainSubstring(volName))
|
||||
|
||||
// Stop the container to unmount
|
||||
|
|
@ -424,10 +420,8 @@ var _ = Describe("Podman run with volumes", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
mountCmd3.Wait(90)
|
||||
Expect(mountCmd3).Should(Exit(0))
|
||||
os.Stdout.Sync()
|
||||
os.Stderr.Sync()
|
||||
mountOut3 := strings.Join(strings.Fields(string(mountCmd3.Out.Contents())), " ")
|
||||
fmt.Printf("Output: %s", mountOut3)
|
||||
GinkgoWriter.Printf("Output: %s", mountOut3)
|
||||
Expect(mountOut3).To(Not(ContainSubstring(volName)))
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -171,8 +171,8 @@ var _ = Describe("Podman save", func() {
|
|||
}
|
||||
|
||||
cmd := exec.Command("gpg", "--import", "sign/secret-key.asc")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = GinkgoWriter
|
||||
cmd.Stderr = GinkgoWriter
|
||||
err = cmd.Run()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package integration
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net"
|
||||
"os"
|
||||
|
|
@ -30,7 +29,7 @@ var _ = Describe("Systemd activate", func() {
|
|||
|
||||
tempDir, err = testUtils.CreateTempDirInTempDir()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
GinkgoWriter.Printf("%v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ var _ = Describe("Toolbox-specific testing", func() {
|
|||
|
||||
err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlimit)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
fmt.Printf("Expected value: %d", rlimit.Max)
|
||||
GinkgoWriter.Printf("Expected value: %d", rlimit.Max)
|
||||
|
||||
session = podmanTest.Podman([]string{"create", "--name", "test", "--ulimit", "host", ALPINE,
|
||||
"sleep", "1000"})
|
||||
|
|
|
|||
|
|
@ -117,9 +117,9 @@ func (p *PodmanTest) PodmanAsUserBase(args []string, uid, gid uint32, cwd string
|
|||
runCmd = append(runCmd, podmanBinary)
|
||||
|
||||
if env == nil {
|
||||
fmt.Printf("Running: %s %s\n", strings.Join(runCmd, " "), strings.Join(podmanOptions, " "))
|
||||
GinkgoWriter.Printf("Running: %s %s\n", strings.Join(runCmd, " "), strings.Join(podmanOptions, " "))
|
||||
} else {
|
||||
fmt.Printf("Running: (env: %v) %s %s\n", env, strings.Join(runCmd, " "), strings.Join(podmanOptions, " "))
|
||||
GinkgoWriter.Printf("Running: (env: %v) %s %s\n", env, strings.Join(runCmd, " "), strings.Join(podmanOptions, " "))
|
||||
}
|
||||
if uid != 0 || gid != 0 {
|
||||
pythonCmd := fmt.Sprintf("import os; import sys; uid = %d; gid = %d; cwd = '%s'; os.setgid(gid); os.setuid(uid); os.chdir(cwd) if len(cwd)>0 else True; os.execv(sys.argv[1], sys.argv[1:])", gid, uid, cwd)
|
||||
|
|
@ -159,7 +159,7 @@ func (p *PodmanTest) WaitForContainer() bool {
|
|||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
fmt.Printf("WaitForContainer(): timed out\n")
|
||||
GinkgoWriter.Printf("WaitForContainer(): timed out\n")
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ func (p *PodmanTest) WaitContainerReady(id string, expStr string, timeout int, s
|
|||
|
||||
for {
|
||||
if time.Since(startTime) >= time.Duration(timeout)*time.Second {
|
||||
fmt.Printf("Container %s is not ready in %ds", id, timeout)
|
||||
GinkgoWriter.Printf("Container %s is not ready in %ds", id, timeout)
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ func (s *PodmanSession) LineInOutputContainsTag(repo, tag string) bool {
|
|||
func (s *PodmanSession) IsJSONOutputValid() bool {
|
||||
var i interface{}
|
||||
if err := json.Unmarshal(s.Out.Contents(), &i); err != nil {
|
||||
fmt.Println(err)
|
||||
GinkgoWriter.Println(err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
|
@ -374,7 +374,6 @@ func (s *PodmanSession) WaitWithTimeout(timeout int) {
|
|||
})
|
||||
os.Stdout.Sync()
|
||||
os.Stderr.Sync()
|
||||
fmt.Println("output:", s.OutputToString())
|
||||
}
|
||||
|
||||
// CreateTempDirInTempDir create a temp dir with prefix podman_test
|
||||
|
|
@ -385,7 +384,7 @@ func CreateTempDirInTempDir() (string, error) {
|
|||
// SystemExec is used to exec a system command to check its exit code or output
|
||||
func SystemExec(command string, args []string) *PodmanSession {
|
||||
c := exec.Command(command, args...)
|
||||
fmt.Println("Execing " + c.String() + "\n")
|
||||
GinkgoWriter.Println("Execing " + c.String() + "\n")
|
||||
session, err := Start(c, GinkgoWriter, GinkgoWriter)
|
||||
if err != nil {
|
||||
Fail(fmt.Sprintf("unable to run command: %s %s", command, strings.Join(args, " ")))
|
||||
|
|
@ -397,7 +396,7 @@ func SystemExec(command string, args []string) *PodmanSession {
|
|||
// StartSystemExec is used to start exec a system command
|
||||
func StartSystemExec(command string, args []string) *PodmanSession {
|
||||
c := exec.Command(command, args...)
|
||||
fmt.Println("Execing " + c.String() + "\n")
|
||||
GinkgoWriter.Println("Execing " + c.String() + "\n")
|
||||
session, err := Start(c, GinkgoWriter, GinkgoWriter)
|
||||
if err != nil {
|
||||
Fail(fmt.Sprintf("unable to run command: %s %s", command, strings.Join(args, " ")))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package utils_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
|
@ -41,7 +40,7 @@ func StartFakeCmdSession(args []string) *PodmanSession {
|
|||
command := exec.Command(GoechoPath, args...)
|
||||
session, err := gexec.Start(command, outWriter, errWriter)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
GinkgoWriter.Println(err)
|
||||
}
|
||||
return &PodmanSession{session}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue