mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-05 00:15:44 +00:00
test/e2e: rework GetHostDistributionInfo
First check for errors and assert them via gomega to make the test fails which called this. Then stop calling this for each test spec, most will never access this so stop reading the file over and over. Callers should just call the function directly. Then remove the arch field from it, that is not related to the OS file. Callers should just access runtime.GOARCH directly. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
9a3bf9986f
commit
d9465ea2bf
15 changed files with 43 additions and 44 deletions
|
|
@ -9,6 +9,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -1049,7 +1050,7 @@ var _ = Describe("Podman checkpoint", func() {
|
|||
})
|
||||
|
||||
It("podman checkpoint container with --pre-checkpoint", func() {
|
||||
if podmanTest.Host.Arch == "arm64" {
|
||||
if runtime.GOARCH == "arm64" {
|
||||
Skip("skip on arm64/aarch64, https://github.com/checkpoint-restore/criu/issues/2676")
|
||||
}
|
||||
SkipIfContainerized("FIXME: #24230 - no longer works in container testing")
|
||||
|
|
@ -1085,7 +1086,7 @@ var _ = Describe("Podman checkpoint", func() {
|
|||
})
|
||||
|
||||
It("podman checkpoint container with --pre-checkpoint and export (migration)", func() {
|
||||
if podmanTest.Host.Arch == "arm64" {
|
||||
if runtime.GOARCH == "arm64" {
|
||||
Skip("skip on arm64/aarch64, https://github.com/checkpoint-restore/criu/issues/2676")
|
||||
}
|
||||
SkipIfContainerized("FIXME: #24230 - no longer works in container testing")
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
|
@ -68,7 +69,6 @@ type PodmanTestIntegration struct {
|
|||
StorageOptions string
|
||||
SignaturePolicyPath string
|
||||
CgroupManager string
|
||||
Host HostOS
|
||||
CliTmpDir string // value of podman --tmpdir
|
||||
}
|
||||
|
||||
|
|
@ -296,7 +296,6 @@ const (
|
|||
|
||||
// PodmanTestCreateUtil creates a PodmanTestIntegration instance for the tests
|
||||
func PodmanTestCreateUtil(tempDir string, target PodmanTestCreateUtilTarget) *PodmanTestIntegration {
|
||||
host := GetHostDistributionInfo()
|
||||
cwd, _ := os.Getwd()
|
||||
|
||||
root := filepath.Join(tempDir, "root")
|
||||
|
|
@ -387,7 +386,6 @@ func PodmanTestCreateUtil(tempDir string, target PodmanTestCreateUtilTarget) *Po
|
|||
StorageOptions: storageOptions,
|
||||
SignaturePolicyPath: filepath.Join(INTEGRATION_ROOT, "test/policy.json"),
|
||||
CgroupManager: cgroupManager,
|
||||
Host: host,
|
||||
}
|
||||
|
||||
var pathPrefix string
|
||||
|
|
@ -1828,7 +1826,7 @@ func skipWithoutDevNullb0() {
|
|||
}
|
||||
|
||||
func SkipIfNotAMD64() {
|
||||
if podmanTest.Host.Arch != "amd64" {
|
||||
if runtime.GOARCH != "amd64" {
|
||||
Skip("test only valid on amd64")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ var _ = Describe("Podman create", func() {
|
|||
})
|
||||
|
||||
It("podman create with --mount flag", func() {
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("skip failing test on ppc64le")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
package integration
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
. "go.podman.io/podman/v6/test/utils"
|
||||
|
|
@ -66,7 +68,7 @@ var _ = Describe("Podman history", func() {
|
|||
Expect(len(lines[1])).To(BeNumerically(">", 45))
|
||||
|
||||
// Size is different on other architectures
|
||||
if podmanTest.Host.Arch == "amd64" {
|
||||
if runtime.GOARCH == "amd64" {
|
||||
session = podmanTest.Podman([]string{"history", "--no-trunc", "--format", "{{.Size}}", ALPINE})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package integration
|
|||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
|
@ -145,7 +146,7 @@ var _ = Describe("Podman load", func() {
|
|||
})
|
||||
|
||||
It("podman load multiple tags", func() {
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("skip on ppc64le")
|
||||
}
|
||||
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
|
|
@ -196,7 +197,7 @@ var _ = Describe("Podman manifest", func() {
|
|||
})
|
||||
|
||||
It("push with --add-compression and --force-compression", func() {
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("No registry image for ppc64le")
|
||||
}
|
||||
if isRootless() {
|
||||
|
|
|
|||
|
|
@ -666,7 +666,7 @@ var _ = Describe("Podman pull", func() {
|
|||
It("From local registry", func() {
|
||||
SkipIfRemote("Remote pull does not support decryption")
|
||||
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("No registry image for ppc64le")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
|
|
@ -95,7 +96,7 @@ var _ = Describe("Podman push", func() {
|
|||
})
|
||||
|
||||
It("push test --force-compression", func() {
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("No registry image for ppc64le")
|
||||
}
|
||||
if isRootless() {
|
||||
|
|
@ -152,7 +153,7 @@ var _ = Describe("Podman push", func() {
|
|||
})
|
||||
|
||||
It("push test --force-compression --format=v2s2", func() {
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("No registry image for ppc64le")
|
||||
}
|
||||
if isRootless() {
|
||||
|
|
@ -193,7 +194,7 @@ var _ = Describe("Podman push", func() {
|
|||
})
|
||||
|
||||
It("podman push to local registry", func() {
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("No registry image for ppc64le")
|
||||
}
|
||||
if isRootless() {
|
||||
|
|
@ -358,7 +359,7 @@ var _ = Describe("Podman push", func() {
|
|||
|
||||
It("podman push to local registry with authorization", func() {
|
||||
SkipIfRootless("/etc/containers/certs.d not writable")
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("No registry image for ppc64le")
|
||||
}
|
||||
authPath := filepath.Join(podmanTest.TempDir, "auth")
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
|
@ -24,7 +25,7 @@ const (
|
|||
|
||||
var _ = Describe("Podman run with --sig-proxy", func() {
|
||||
Specify("signals are forwarded to container using sig-proxy", func() {
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("Doesn't work on ppc64le")
|
||||
}
|
||||
signal := syscall.SIGFPE
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
|
@ -459,7 +460,7 @@ var _ = Describe("Podman run", func() {
|
|||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.OutputToString()).To(Not(BeEmpty()))
|
||||
Expect(session).Should(ExitCleanly())
|
||||
if podmanTest.Host.Arch == "amd64" {
|
||||
if runtime.GOARCH == "amd64" {
|
||||
session = podmanTest.Podman([]string{"exec", "maskCtr2", "ls", "/proc/acpi"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.OutputToString()).To(Not(BeEmpty()))
|
||||
|
|
@ -495,7 +496,7 @@ var _ = Describe("Podman run", func() {
|
|||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).Should(HaveLen(1))
|
||||
|
||||
if podmanTest.Host.Arch == "amd64" {
|
||||
if runtime.GOARCH == "amd64" {
|
||||
session = podmanTest.Podman([]string{"run", "--security-opt", "unmask=/proc/a*", ALPINE, "ls", "/proc/acpi"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
|
@ -2286,7 +2287,7 @@ WORKDIR /madethis`, BB)
|
|||
It("podman run and decrypt from local registry", func() {
|
||||
SkipIfRemote("Remote run does not support decryption")
|
||||
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("No registry image for ppc64le")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"os/exec"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
|
@ -68,7 +69,7 @@ var _ = Describe("Podman run with volumes", func() {
|
|||
})
|
||||
|
||||
It("podman run with --mount flag", func() {
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("skip failing test on ppc64le")
|
||||
}
|
||||
mountPath := filepath.Join(podmanTest.TempDir, "secrets")
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
|
@ -121,7 +122,7 @@ var _ = Describe("Podman save", func() {
|
|||
It("podman save remove signature", func() {
|
||||
podmanTest.AddImageToRWStore(ALPINE)
|
||||
SkipIfRootless("FIXME: Need get in rootless push sign")
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("No registry image for ppc64le")
|
||||
}
|
||||
tempGNUPGHOME := filepath.Join(podmanTest.TempDir, "tmpGPG")
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"text/template"
|
||||
|
||||
|
|
@ -44,7 +45,7 @@ insecure = false
|
|||
registryFileBadTmpl := template.Must(template.New("registryFileBad").Parse(badRegFileContents))
|
||||
|
||||
mockFakeRegistryServerAsContainer := func(name string) endpoint {
|
||||
if podmanTest.Host.Arch == "ppc64le" {
|
||||
if runtime.GOARCH == "ppc64le" {
|
||||
Skip("No registry image for ppc64le")
|
||||
}
|
||||
port := GetPort()
|
||||
|
|
|
|||
|
|
@ -33,27 +33,20 @@ var _ = Describe("Common functions test", func() {
|
|||
})
|
||||
|
||||
DescribeTable("Test GetHostDistributionInfo",
|
||||
func(path, id, ver string, empty bool) {
|
||||
func(path, id, ver string) {
|
||||
txt := fmt.Sprintf("ID=%s\nVERSION_ID=%s", id, ver)
|
||||
if !empty {
|
||||
f, _ := os.Create(path)
|
||||
_, err := f.WriteString(txt)
|
||||
Expect(err).ToNot(HaveOccurred(), "Failed to write data.")
|
||||
f.Close()
|
||||
}
|
||||
f, _ := os.Create(path)
|
||||
_, err := f.WriteString(txt)
|
||||
Expect(err).ToNot(HaveOccurred(), "Failed to write data.")
|
||||
f.Close()
|
||||
|
||||
OSReleasePath = path
|
||||
host := GetHostDistributionInfo()
|
||||
if empty {
|
||||
Expect(host).To(Equal(HostOS{}), "HostOs should be empty.")
|
||||
} else {
|
||||
Expect(host.Distribution).To(Equal(strings.Trim(id, "\"")))
|
||||
Expect(host.Version).To(Equal(strings.Trim(ver, "\"")))
|
||||
}
|
||||
Expect(host.Distribution).To(Equal(strings.Trim(id, "\"")))
|
||||
Expect(host.Version).To(Equal(strings.Trim(ver, "\"")))
|
||||
},
|
||||
Entry("Configure file is not exist.", "/tmp/nonexistent", "", "", true),
|
||||
Entry("Item value with and without \"", "/tmp/os-release.test", "fedora", "\"28\"", false),
|
||||
Entry("Item empty with and without \"", "/tmp/os-release.test", "", "\"\"", false),
|
||||
Entry("Item value with and without \"", "/tmp/os-release.test", "fedora", "\"28\""),
|
||||
Entry("Item empty with and without \"", "/tmp/os-release.test", "", "\"\""),
|
||||
)
|
||||
|
||||
DescribeTable("Test TestIsCommandAvailable",
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import (
|
|||
"math/rand"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
|
@ -78,7 +77,6 @@ type PodmanSession struct {
|
|||
type HostOS struct {
|
||||
Distribution string
|
||||
Version string
|
||||
Arch string
|
||||
}
|
||||
|
||||
// MakeOptions assembles all podman options
|
||||
|
|
@ -397,14 +395,11 @@ func tagOutputToMap(imagesOutput []string) map[string]map[string]bool {
|
|||
// GetHostDistributionInfo returns a struct with its distribution Name and version
|
||||
func GetHostDistributionInfo() HostOS {
|
||||
f, err := os.Open(OSReleasePath)
|
||||
if err != nil {
|
||||
return HostOS{}
|
||||
}
|
||||
Expect(err).ToNot(HaveOccurred(), "open %s", OSReleasePath)
|
||||
defer f.Close()
|
||||
|
||||
l := bufio.NewScanner(f)
|
||||
host := HostOS{}
|
||||
host.Arch = runtime.GOARCH
|
||||
for l.Scan() {
|
||||
if strings.HasPrefix(l.Text(), "ID=") {
|
||||
host.Distribution = strings.ReplaceAll(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "")
|
||||
|
|
@ -413,6 +408,8 @@ func GetHostDistributionInfo() HostOS {
|
|||
host.Version = strings.ReplaceAll(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "")
|
||||
}
|
||||
}
|
||||
err = l.Err()
|
||||
Expect(err).ToNot(HaveOccurred(), "read %s", OSReleasePath)
|
||||
return host
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue