2019-01-14 19:23:13 +00:00
|
|
|
// +build !remoteclient
|
|
|
|
|
2018-01-24 14:45:55 +00:00
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
|
2019-03-14 17:03:42 +00:00
|
|
|
"github.com/onsi/ginkgo"
|
2018-01-24 14:45:55 +00:00
|
|
|
)
|
|
|
|
|
2019-03-19 08:49:34 +00:00
|
|
|
func SkipIfRemote() {
|
|
|
|
}
|
2019-01-14 21:55:00 +00:00
|
|
|
|
2019-03-14 17:03:42 +00:00
|
|
|
func SkipIfRootless() {
|
2019-03-19 08:49:34 +00:00
|
|
|
if os.Geteuid() != 0 {
|
|
|
|
ginkgo.Skip("This function is not enabled for rootless podman")
|
|
|
|
}
|
2019-03-14 17:03:42 +00:00
|
|
|
}
|
|
|
|
|
2018-06-07 09:44:52 +00:00
|
|
|
// Podman is the exec call to podman on the filesystem
|
2018-10-29 06:56:07 +00:00
|
|
|
func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration {
|
2019-07-17 19:28:40 +00:00
|
|
|
podmanSession := p.PodmanBase(args, false, false)
|
2019-05-14 19:28:50 +00:00
|
|
|
return &PodmanSessionIntegration{podmanSession}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PodmanNoCache calls the podman command with no configured imagecache
|
|
|
|
func (p *PodmanTestIntegration) PodmanNoCache(args []string) *PodmanSessionIntegration {
|
2019-09-26 14:35:16 +00:00
|
|
|
podmanSession := p.PodmanBase(args, false, true)
|
2019-07-17 19:28:40 +00:00
|
|
|
return &PodmanSessionIntegration{podmanSession}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PodmanNoEvents calls the Podman command without an imagecache and without an
|
|
|
|
// events backend. It is used mostly for caching and uncaching images.
|
|
|
|
func (p *PodmanTestIntegration) PodmanNoEvents(args []string) *PodmanSessionIntegration {
|
|
|
|
podmanSession := p.PodmanBase(args, true, true)
|
2018-10-29 06:56:07 +00:00
|
|
|
return &PodmanSessionIntegration{podmanSession}
|
2018-06-07 09:44:52 +00:00
|
|
|
}
|
|
|
|
|
2018-11-22 09:57:05 +00:00
|
|
|
// PodmanAsUser is the exec call to podman on the filesystem with the specified uid/gid and environment
|
2019-02-21 10:27:34 +00:00
|
|
|
func (p *PodmanTestIntegration) PodmanAsUser(args []string, uid, gid uint32, cwd string, env []string) *PodmanSessionIntegration {
|
2019-07-17 19:28:40 +00:00
|
|
|
podmanSession := p.PodmanAsUserBase(args, uid, gid, cwd, env, false, false)
|
2018-11-22 09:57:05 +00:00
|
|
|
return &PodmanSessionIntegration{podmanSession}
|
|
|
|
}
|
|
|
|
|
2018-10-29 06:56:07 +00:00
|
|
|
func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() {
|
2018-07-31 22:16:08 +00:00
|
|
|
defaultFile := filepath.Join(INTEGRATION_ROOT, "test/registries.conf")
|
|
|
|
os.Setenv("REGISTRIES_CONFIG_PATH", defaultFile)
|
|
|
|
}
|
|
|
|
|
2018-10-29 06:56:07 +00:00
|
|
|
func (p *PodmanTestIntegration) setRegistriesConfigEnv(b []byte) {
|
2018-07-31 22:16:08 +00:00
|
|
|
outfile := filepath.Join(p.TempDir, "registries.conf")
|
|
|
|
os.Setenv("REGISTRIES_CONFIG_PATH", outfile)
|
|
|
|
ioutil.WriteFile(outfile, b, 0644)
|
|
|
|
}
|
|
|
|
|
|
|
|
func resetRegistriesConfigEnv() {
|
|
|
|
os.Setenv("REGISTRIES_CONFIG_PATH", "")
|
2018-02-15 14:17:35 +00:00
|
|
|
}
|
2019-01-14 19:23:13 +00:00
|
|
|
|
|
|
|
func PodmanTestCreate(tempDir string) *PodmanTestIntegration {
|
|
|
|
return PodmanTestCreateUtil(tempDir, false)
|
|
|
|
}
|
|
|
|
|
2019-03-05 23:11:28 +00:00
|
|
|
// MakeOptions assembles all the podman main options
|
2019-09-26 14:35:16 +00:00
|
|
|
func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache bool) []string {
|
2019-03-05 23:11:28 +00:00
|
|
|
var debug string
|
|
|
|
if _, ok := os.LookupEnv("DEBUG"); ok {
|
|
|
|
debug = "--log-level=debug --syslog=true "
|
|
|
|
}
|
|
|
|
|
2019-07-17 19:28:40 +00:00
|
|
|
eventsType := "file"
|
|
|
|
if noEvents {
|
2019-08-01 18:57:29 +00:00
|
|
|
eventsType = "none"
|
2019-07-17 19:28:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
podmanOptions := strings.Split(fmt.Sprintf("%s--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s --tmpdir %s --events-backend %s",
|
|
|
|
debug, p.CrioRoot, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager, p.TmpDir, eventsType), " ")
|
2019-01-18 15:09:18 +00:00
|
|
|
if os.Getenv("HOOK_OPTION") != "" {
|
|
|
|
podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION"))
|
|
|
|
}
|
2019-03-05 23:11:28 +00:00
|
|
|
|
2019-01-18 15:09:18 +00:00
|
|
|
podmanOptions = append(podmanOptions, strings.Split(p.StorageOptions, " ")...)
|
2019-09-26 14:35:16 +00:00
|
|
|
if !noCache {
|
|
|
|
cacheOptions := []string{"--storage-opt",
|
|
|
|
fmt.Sprintf("%s.imagestore=%s", p.PodmanTest.ImageCacheFS, p.PodmanTest.ImageCacheDir)}
|
|
|
|
podmanOptions = append(cacheOptions, podmanOptions...)
|
|
|
|
}
|
2019-01-18 15:09:18 +00:00
|
|
|
podmanOptions = append(podmanOptions, args...)
|
|
|
|
return podmanOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
// RestoreArtifact puts the cached image into our test store
|
|
|
|
func (p *PodmanTestIntegration) RestoreArtifact(image string) error {
|
|
|
|
fmt.Printf("Restoring %s...\n", image)
|
|
|
|
dest := strings.Split(image, "/")
|
|
|
|
destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
|
2019-07-17 19:28:40 +00:00
|
|
|
restore := p.PodmanNoEvents([]string{"load", "-q", "-i", destName})
|
2019-01-18 15:09:18 +00:00
|
|
|
restore.Wait(90)
|
|
|
|
return nil
|
|
|
|
}
|
2019-05-14 19:28:50 +00:00
|
|
|
|
|
|
|
// RestoreArtifactToCache populates the imagecache from tarballs that were cached earlier
|
|
|
|
func (p *PodmanTestIntegration) RestoreArtifactToCache(image string) error {
|
|
|
|
fmt.Printf("Restoring %s...\n", image)
|
|
|
|
dest := strings.Split(image, "/")
|
|
|
|
destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
|
|
|
|
|
|
|
|
p.CrioRoot = p.ImageCacheDir
|
2019-07-17 19:28:40 +00:00
|
|
|
restore := p.PodmanNoEvents([]string{"load", "-q", "-i", destName})
|
2019-05-14 19:28:50 +00:00
|
|
|
restore.WaitWithDefaultTimeout()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-04-19 13:33:18 +00:00
|
|
|
func (p *PodmanTestIntegration) StopVarlink() {}
|
|
|
|
func (p *PodmanTestIntegration) DelayForVarlink() {}
|
2019-05-14 19:28:50 +00:00
|
|
|
|
|
|
|
func populateCache(podman *PodmanTestIntegration) {
|
|
|
|
for _, image := range CACHE_IMAGES {
|
|
|
|
podman.RestoreArtifactToCache(image)
|
|
|
|
}
|
CI: format cirrus logs
This introduces a new cirrus helper script, logformatter.
Usage is:
[commands...] | logformatter TEST-NAME
It reformats its input into a readable, highlighed, linkable
form. Some features:
- boring stuff (timestamps, standard podman options) is
deemphasized
- important stuff (warnings, errors) is emphasized
- in-page links to the actual failures
- active links to source files
- jumps to bottom of page on load, because that's where
the errors are. (All errors are linked)
Add it to select test commands (integration, system) and
add a new artifacts_html, run in the 'always' block, which
uploads generated *.log.html into Cirrus; from there we
generate a live URL that can be viewed in browser.
Unfortunately, due to security concerns in Cirrus, it is
not currently possible to make the link a live one.
Kludge: add a line of dashes after Restoring images; without this,
the first test ("systemd PID 1") has no dashes before it, so
logformatter doesn't see it.
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-02-27 15:17:37 +00:00
|
|
|
// logformatter uses this to recognize the first test
|
|
|
|
fmt.Printf("-----------------------------\n")
|
2019-05-14 19:28:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func removeCache() {
|
|
|
|
// Remove cache dirs
|
|
|
|
if err := os.RemoveAll(ImageCacheDir); err != nil {
|
|
|
|
fmt.Printf("%q\n", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SeedImages is a no-op for localized testing
|
|
|
|
func (p *PodmanTestIntegration) SeedImages() error {
|
|
|
|
return nil
|
|
|
|
}
|
2019-11-22 16:39:49 +00:00
|
|
|
|
|
|
|
// We don't support running Varlink when local
|
|
|
|
func (p *PodmanTestIntegration) StartVarlink() {
|
|
|
|
}
|