github.com/containers/podman/v4@v4.9.4/test/e2e/libpod_suite_test.go (about)

     1  //go:build !remote_testing
     2  // +build !remote_testing
     3  
     4  package integration
     5  
     6  import (
     7  	"os"
     8  	"path/filepath"
     9  
    10  	. "github.com/onsi/ginkgo/v2"
    11  	. "github.com/onsi/gomega"
    12  )
    13  
    14  func IsRemote() bool {
    15  	return false
    16  }
    17  
    18  // Podman is the exec call to podman on the filesystem
    19  func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration {
    20  	podmanSession := p.PodmanBase(args, false, false)
    21  	return &PodmanSessionIntegration{podmanSession}
    22  }
    23  
    24  // PodmanSystemdScope runs the podman command in a new systemd scope
    25  func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSessionIntegration {
    26  	wrapper := []string{"systemd-run", "--scope"}
    27  	if isRootless() {
    28  		wrapper = []string{"systemd-run", "--scope", "--user"}
    29  	}
    30  	podmanSession := p.PodmanAsUserBase(args, 0, 0, "", nil, false, false, wrapper, nil)
    31  	return &PodmanSessionIntegration{podmanSession}
    32  }
    33  
    34  // PodmanExtraFiles is the exec call to podman on the filesystem and passes down extra files
    35  func (p *PodmanTestIntegration) PodmanExtraFiles(args []string, extraFiles []*os.File) *PodmanSessionIntegration {
    36  	podmanSession := p.PodmanAsUserBase(args, 0, 0, "", nil, false, false, nil, extraFiles)
    37  	return &PodmanSessionIntegration{podmanSession}
    38  }
    39  
    40  func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() {
    41  	defaultFile := filepath.Join(INTEGRATION_ROOT, "test/registries.conf")
    42  	err := os.Setenv("CONTAINERS_REGISTRIES_CONF", defaultFile)
    43  	Expect(err).ToNot(HaveOccurred())
    44  }
    45  
    46  func (p *PodmanTestIntegration) setRegistriesConfigEnv(b []byte) {
    47  	outfile := filepath.Join(p.TempDir, "registries.conf")
    48  	os.Setenv("CONTAINERS_REGISTRIES_CONF", outfile)
    49  	err := os.WriteFile(outfile, b, 0644)
    50  	Expect(err).ToNot(HaveOccurred())
    51  }
    52  
    53  func resetRegistriesConfigEnv() {
    54  	os.Setenv("CONTAINERS_REGISTRIES_CONF", "")
    55  }
    56  
    57  func PodmanTestCreate(tempDir string) *PodmanTestIntegration {
    58  	return PodmanTestCreateUtil(tempDir, false)
    59  }
    60  
    61  // RestoreArtifact puts the cached image into our test store
    62  func (p *PodmanTestIntegration) RestoreArtifact(image string) error {
    63  	tarball := imageTarPath(image)
    64  	if _, err := os.Stat(tarball); err == nil {
    65  		GinkgoWriter.Printf("Restoring %s...\n", image)
    66  		restore := p.PodmanNoEvents([]string{"load", "-q", "-i", tarball})
    67  		restore.Wait(90)
    68  	}
    69  	return nil
    70  }
    71  
    72  func (p *PodmanTestIntegration) StopRemoteService() {}
    73  
    74  // We don't support running API service when local
    75  func (p *PodmanTestIntegration) StartRemoteService() {
    76  }
    77  
    78  // Just a stub for compiling with `!remote`.
    79  func getRemoteOptions(p *PodmanTestIntegration, args []string) []string {
    80  	return nil
    81  }