mirror of
https://github.com/containers/podman.git
synced 2025-12-02 11:08:36 +08:00
This commit gets tests working under the new local-registry system:
* amend a few image names, mostly just sticking to a consistent
list of those images in our registry cache. Mostly minor
tag updates.
* trickier: pull_test: change some error messages, and remove
a test that's now a NOP. Basically, with a local (unprotected)
registry we always get "404 manifest unknown"; with a real
registry we'll get "403 I can't tell you".
* trickiest: seccomp_test: build our own images at run time,
with our desired labels. Until now we've been pulling
prebuilt images, but those will not copy to the local
cache registry. Something about v1? Anyhow, I gave up
trying to cache them, and the workaround is straightforward.
Also took the liberty of strengthening a few error-message checks
Signed-off-by: Ed Santiago <santiago@redhat.com>
85 lines
2.6 KiB
Go
85 lines
2.6 KiB
Go
//go:build !remote_testing
|
|
|
|
package integration
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
func IsRemote() bool {
|
|
return false
|
|
}
|
|
|
|
// Podman is the exec call to podman on the filesystem
|
|
func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration {
|
|
podmanSession := p.PodmanBase(args, false, false)
|
|
return &PodmanSessionIntegration{podmanSession}
|
|
}
|
|
|
|
// PodmanSystemdScope runs the podman command in a new systemd scope
|
|
func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSessionIntegration {
|
|
wrapper := []string{"systemd-run", "--scope"}
|
|
if isRootless() {
|
|
wrapper = []string{"systemd-run", "--scope", "--user"}
|
|
}
|
|
podmanSession := p.PodmanAsUserBase(args, 0, 0, "", nil, false, false, wrapper, nil)
|
|
return &PodmanSessionIntegration{podmanSession}
|
|
}
|
|
|
|
// PodmanExtraFiles is the exec call to podman on the filesystem and passes down extra files
|
|
func (p *PodmanTestIntegration) PodmanExtraFiles(args []string, extraFiles []*os.File) *PodmanSessionIntegration {
|
|
podmanSession := p.PodmanAsUserBase(args, 0, 0, "", nil, false, false, nil, extraFiles)
|
|
return &PodmanSessionIntegration{podmanSession}
|
|
}
|
|
|
|
func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() {
|
|
defaultFile := "registries.conf"
|
|
if UsingCacheRegistry() {
|
|
defaultFile = "registries-cached.conf"
|
|
}
|
|
defaultPath := filepath.Join(INTEGRATION_ROOT, "test", defaultFile)
|
|
err := os.Setenv("CONTAINERS_REGISTRIES_CONF", defaultPath)
|
|
Expect(err).ToNot(HaveOccurred())
|
|
}
|
|
|
|
func (p *PodmanTestIntegration) setRegistriesConfigEnv(b []byte) {
|
|
outfile := filepath.Join(p.TempDir, "registries.conf")
|
|
os.Setenv("CONTAINERS_REGISTRIES_CONF", outfile)
|
|
err := os.WriteFile(outfile, b, 0644)
|
|
Expect(err).ToNot(HaveOccurred())
|
|
}
|
|
|
|
func resetRegistriesConfigEnv() {
|
|
os.Setenv("CONTAINERS_REGISTRIES_CONF", "")
|
|
}
|
|
|
|
func PodmanTestCreate(tempDir string) *PodmanTestIntegration {
|
|
return PodmanTestCreateUtil(tempDir, false)
|
|
}
|
|
|
|
// RestoreArtifact puts the cached image into our test store
|
|
func (p *PodmanTestIntegration) RestoreArtifact(image string) error {
|
|
tarball := imageTarPath(image)
|
|
if _, err := os.Stat(tarball); err == nil {
|
|
GinkgoWriter.Printf("Restoring %s...\n", image)
|
|
restore := p.PodmanNoEvents([]string{"load", "-q", "-i", tarball})
|
|
restore.Wait(90)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *PodmanTestIntegration) StopRemoteService() {}
|
|
|
|
// We don't support running API service when local
|
|
func (p *PodmanTestIntegration) StartRemoteService() {
|
|
}
|
|
|
|
// Just a stub for compiling with `!remote`.
|
|
func getRemoteOptions(p *PodmanTestIntegration, args []string) []string {
|
|
return nil
|
|
}
|