github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/test/e2e/libpod_suite_test.go (about)

     1  // +build !remote
     2  
     3  package integration
     4  
     5  import (
     6  	"fmt"
     7  	"io/ioutil"
     8  	"os"
     9  	"path/filepath"
    10  	"strings"
    11  )
    12  
    13  func IsRemote() bool {
    14  	return false
    15  }
    16  
    17  func SkipIfRemote(string) {
    18  }
    19  
    20  // Podman is the exec call to podman on the filesystem
    21  func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration {
    22  	podmanSession := p.PodmanBase(args, false, false)
    23  	return &PodmanSessionIntegration{podmanSession}
    24  }
    25  
    26  // PodmanExtraFiles is the exec call to podman on the filesystem and passes down extra files
    27  func (p *PodmanTestIntegration) PodmanExtraFiles(args []string, extraFiles []*os.File) *PodmanSessionIntegration {
    28  	podmanSession := p.PodmanAsUserBase(args, 0, 0, "", nil, false, false, extraFiles)
    29  	return &PodmanSessionIntegration{podmanSession}
    30  }
    31  
    32  func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() {
    33  	defaultFile := filepath.Join(INTEGRATION_ROOT, "test/registries.conf")
    34  	os.Setenv("REGISTRIES_CONFIG_PATH", defaultFile)
    35  }
    36  
    37  func (p *PodmanTestIntegration) setRegistriesConfigEnv(b []byte) {
    38  	outfile := filepath.Join(p.TempDir, "registries.conf")
    39  	os.Setenv("REGISTRIES_CONFIG_PATH", outfile)
    40  	ioutil.WriteFile(outfile, b, 0644)
    41  }
    42  
    43  func resetRegistriesConfigEnv() {
    44  	os.Setenv("REGISTRIES_CONFIG_PATH", "")
    45  }
    46  
    47  func PodmanTestCreate(tempDir string) *PodmanTestIntegration {
    48  	return PodmanTestCreateUtil(tempDir, false)
    49  }
    50  
    51  // RestoreArtifact puts the cached image into our test store
    52  func (p *PodmanTestIntegration) RestoreArtifact(image string) error {
    53  	fmt.Printf("Restoring %s...\n", image)
    54  	dest := strings.Split(image, "/")
    55  	destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
    56  	restore := p.PodmanNoEvents([]string{"load", "-q", "-i", destName})
    57  	restore.Wait(90)
    58  	return nil
    59  }
    60  
    61  func (p *PodmanTestIntegration) StopRemoteService() {}
    62  func (p *PodmanTestIntegration) DelayForVarlink()   {}
    63  
    64  // SeedImages is a no-op for localized testing
    65  func (p *PodmanTestIntegration) SeedImages() error {
    66  	return nil
    67  }
    68  
    69  // We don't support running Varlink when local
    70  func (p *PodmanTestIntegration) StartRemoteService() {
    71  }