tests: use existing CRIU version check

Do not re-implement the CRIU version check in the test suite, use it
from libpod/pkg/criu.

Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
Adrian Reber
2018-10-02 14:28:46 +00:00
committed by Adrian Reber
parent 8f6fb79ba8
commit a14155917b
2 changed files with 3 additions and 41 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/containers/libpod/pkg/criu"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
@ -22,10 +23,8 @@ var _ = Describe("Podman checkpoint", func() {
} }
podmanTest = PodmanCreate(tempdir) podmanTest = PodmanCreate(tempdir)
podmanTest.RestoreAllArtifacts() podmanTest.RestoreAllArtifacts()
// At least CRIU 3.11 is needed if !criu.CheckForCriu() {
skip, err := podmanTest.isCriuAtLeast(31100) Skip("CRIU is missing or too old.")
if err != nil || skip {
Skip("CRIU missing or too old.")
} }
}) })

View File

@ -2,7 +2,6 @@ package integration
import ( import (
"bufio" "bufio"
"bytes"
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -65,7 +64,6 @@ type PodmanTest struct {
TempDir string TempDir string
CgroupManager string CgroupManager string
Host HostOS Host HostOS
CriuBinary string
} }
// HostOS is a simple struct for the test os // HostOS is a simple struct for the test os
@ -166,7 +164,6 @@ func PodmanCreate(tempDir string) PodmanTest {
runCBinary = "/usr/bin/runc" runCBinary = "/usr/bin/runc"
} }
criuBinary := "/usr/sbin/criu"
CNIConfigDir := "/etc/cni/net.d" CNIConfigDir := "/etc/cni/net.d"
p := PodmanTest{ p := PodmanTest{
@ -182,7 +179,6 @@ func PodmanCreate(tempDir string) PodmanTest {
TempDir: tempDir, TempDir: tempDir,
CgroupManager: cgroupManager, CgroupManager: cgroupManager,
Host: host, Host: host,
CriuBinary: criuBinary,
} }
// Setup registries.conf ENV variable // Setup registries.conf ENV variable
@ -682,39 +678,6 @@ func (p *PodmanTest) setRegistriesConfigEnv(b []byte) {
ioutil.WriteFile(outfile, b, 0644) ioutil.WriteFile(outfile, b, 0644)
} }
func (p *PodmanTest) isCriuAtLeast(version int) (bool, error) {
cmd := exec.Command(p.CriuBinary, "-V")
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
return false, err
}
var x int
var y int
var z int
fmt.Sscanf(out.String(), "Version: %d.%d.%d", &x, &y, &z)
if strings.Contains(out.String(), "GitID") {
// If CRIU is built from git it contains a git ID.
// If that is the case, increase minor by one as this
// could mean we are running a development version.
y = y + 1
}
parsed_version := x*10000 + y*100 + z
fmt.Println(parsed_version)
if parsed_version >= version {
return false, nil
} else {
return true, nil
}
}
func resetRegistriesConfigEnv() { func resetRegistriesConfigEnv() {
os.Setenv("REGISTRIES_CONFIG_PATH", "") os.Setenv("REGISTRIES_CONFIG_PATH", "")
} }