mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
e2e tests: enable golint
...and fix problems found therewith. Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
@ -6,7 +6,6 @@ run:
|
|||||||
skip-dirs:
|
skip-dirs:
|
||||||
- contrib
|
- contrib
|
||||||
- dependencies
|
- dependencies
|
||||||
- test
|
|
||||||
skip-files:
|
skip-files:
|
||||||
- swagger.go
|
- swagger.go
|
||||||
modules-download-mode: readonly
|
modules-download-mode: readonly
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -51,7 +51,7 @@ var (
|
|||||||
shortName: "busybox",
|
shortName: "busybox",
|
||||||
tarballName: "busybox.tar",
|
tarballName: "busybox.tar",
|
||||||
}
|
}
|
||||||
CACHE_IMAGES = []testImage{alpine, busybox}
|
CACHE_IMAGES = []testImage{alpine, busybox} //nolint:golint,stylecheck
|
||||||
)
|
)
|
||||||
|
|
||||||
type bindingTest struct {
|
type bindingTest struct {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -103,6 +103,7 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
// Pause by name
|
// Pause by name
|
||||||
err = containers.Pause(bt.conn, name, nil)
|
err = containers.Pause(bt.conn, name, nil)
|
||||||
|
Expect(err).To(BeNil(), "error from containers.Pause()")
|
||||||
//paused := "paused"
|
//paused := "paused"
|
||||||
//_, err = containers.Wait(bt.conn, cid, &paused)
|
//_, err = containers.Wait(bt.conn, cid, &paused)
|
||||||
//Expect(err).To(BeNil())
|
//Expect(err).To(BeNil())
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/containers/podman/v3/pkg/bindings/containers"
|
"github.com/containers/podman/v3/pkg/bindings/containers"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -89,6 +89,10 @@ var _ = Describe("Podman images", func() {
|
|||||||
response, errs := images.Remove(bt.conn, []string{"foobar5000"}, nil)
|
response, errs := images.Remove(bt.conn, []string{"foobar5000"}, nil)
|
||||||
Expect(len(errs)).To(BeNumerically(">", 0))
|
Expect(len(errs)).To(BeNumerically(">", 0))
|
||||||
code, _ := bindings.CheckResponseCode(errs[0])
|
code, _ := bindings.CheckResponseCode(errs[0])
|
||||||
|
// FIXME FIXME FIXME: #12441: THIS IS BROKEN
|
||||||
|
// FIXME FIXME FIXME: we get msg: "foobar5000: image not known"
|
||||||
|
// FIXME FIXME FIXME: ...with no ResponseCode
|
||||||
|
Expect(code).To(BeNumerically("==", -1))
|
||||||
|
|
||||||
// Remove an image by name, validate image is removed and error is nil
|
// Remove an image by name, validate image is removed and error is nil
|
||||||
inspectData, err := images.GetImage(bt.conn, busybox.shortName, nil)
|
inspectData, err := images.GetImage(bt.conn, busybox.shortName, nil)
|
||||||
@ -99,6 +103,7 @@ var _ = Describe("Podman images", func() {
|
|||||||
Expect(inspectData.ID).To(Equal(response.Deleted[0]))
|
Expect(inspectData.ID).To(Equal(response.Deleted[0]))
|
||||||
inspectData, err = images.GetImage(bt.conn, busybox.shortName, nil)
|
inspectData, err = images.GetImage(bt.conn, busybox.shortName, nil)
|
||||||
code, _ = bindings.CheckResponseCode(err)
|
code, _ = bindings.CheckResponseCode(err)
|
||||||
|
Expect(code).To(BeNumerically("==", http.StatusNotFound))
|
||||||
|
|
||||||
// Start a container with alpine image
|
// Start a container with alpine image
|
||||||
var top string = "top"
|
var top string = "top"
|
||||||
@ -113,6 +118,9 @@ var _ = Describe("Podman images", func() {
|
|||||||
// deleting hence image cannot be deleted until the container is deleted.
|
// deleting hence image cannot be deleted until the container is deleted.
|
||||||
response, errs = images.Remove(bt.conn, []string{alpine.shortName}, nil)
|
response, errs = images.Remove(bt.conn, []string{alpine.shortName}, nil)
|
||||||
code, _ = bindings.CheckResponseCode(errs[0])
|
code, _ = bindings.CheckResponseCode(errs[0])
|
||||||
|
// FIXME FIXME FIXME: #12441: another invalid error
|
||||||
|
// FIXME FIXME FIXME: this time msg="Image used by SHA: ..."
|
||||||
|
Expect(code).To(BeNumerically("==", -1))
|
||||||
|
|
||||||
// Removing the image "alpine" where force = true
|
// Removing the image "alpine" where force = true
|
||||||
options := new(images.RemoveOptions).WithForce(true)
|
options := new(images.RemoveOptions).WithForce(true)
|
||||||
@ -122,10 +130,12 @@ var _ = Describe("Podman images", func() {
|
|||||||
// is gone as well.
|
// is gone as well.
|
||||||
_, err = containers.Inspect(bt.conn, "top", nil)
|
_, err = containers.Inspect(bt.conn, "top", nil)
|
||||||
code, _ = bindings.CheckResponseCode(err)
|
code, _ = bindings.CheckResponseCode(err)
|
||||||
|
Expect(code).To(BeNumerically("==", http.StatusNotFound))
|
||||||
|
|
||||||
// Now make sure both images are gone.
|
// Now make sure both images are gone.
|
||||||
inspectData, err = images.GetImage(bt.conn, busybox.shortName, nil)
|
inspectData, err = images.GetImage(bt.conn, busybox.shortName, nil)
|
||||||
code, _ = bindings.CheckResponseCode(err)
|
code, _ = bindings.CheckResponseCode(err)
|
||||||
|
Expect(code).To(BeNumerically("==", http.StatusNotFound))
|
||||||
|
|
||||||
inspectData, err = images.GetImage(bt.conn, alpine.shortName, nil)
|
inspectData, err = images.GetImage(bt.conn, alpine.shortName, nil)
|
||||||
code, _ = bindings.CheckResponseCode(err)
|
code, _ = bindings.CheckResponseCode(err)
|
||||||
@ -339,6 +349,7 @@ var _ = Describe("Podman images", func() {
|
|||||||
|
|
||||||
// Search with a fqdn
|
// Search with a fqdn
|
||||||
reports, err = images.Search(bt.conn, "quay.io/libpod/alpine_nginx", nil)
|
reports, err = images.Search(bt.conn, "quay.io/libpod/alpine_nginx", nil)
|
||||||
|
Expect(err).To(BeNil(), "Error in images.Search()")
|
||||||
Expect(len(reports)).To(BeNumerically(">=", 1))
|
Expect(len(reports)).To(BeNumerically(">=", 1))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -79,6 +79,7 @@ var _ = Describe("Podman pods", func() {
|
|||||||
var newpod2 string = "newpod2"
|
var newpod2 string = "newpod2"
|
||||||
bt.Podcreate(&newpod2)
|
bt.Podcreate(&newpod2)
|
||||||
podSummary, err = pods.List(bt.conn, nil)
|
podSummary, err = pods.List(bt.conn, nil)
|
||||||
|
Expect(err).To(BeNil(), "Error from pods.List")
|
||||||
Expect(len(podSummary)).To(Equal(2))
|
Expect(len(podSummary)).To(Equal(2))
|
||||||
var names []string
|
var names []string
|
||||||
for _, i := range podSummary {
|
for _, i := range podSummary {
|
||||||
@ -106,6 +107,7 @@ var _ = Describe("Podman pods", func() {
|
|||||||
options := new(pods.ListOptions).WithFilters(filters)
|
options := new(pods.ListOptions).WithFilters(filters)
|
||||||
filteredPods, err := pods.List(bt.conn, options)
|
filteredPods, err := pods.List(bt.conn, options)
|
||||||
Expect(err).ToNot(BeNil())
|
Expect(err).ToNot(BeNil())
|
||||||
|
Expect(len(filteredPods)).To(Equal(0), "len(filteredPods)")
|
||||||
code, _ := bindings.CheckResponseCode(err)
|
code, _ := bindings.CheckResponseCode(err)
|
||||||
Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
|
Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
|
||||||
|
|
||||||
@ -301,6 +303,7 @@ var _ = Describe("Podman pods", func() {
|
|||||||
// No pods pruned since no pod in exited state
|
// No pods pruned since no pod in exited state
|
||||||
pruneResponse, err := pods.Prune(bt.conn, nil)
|
pruneResponse, err := pods.Prune(bt.conn, nil)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(len(pruneResponse)).To(Equal(0), "len(pruneResponse)")
|
||||||
podSummary, err := pods.List(bt.conn, nil)
|
podSummary, err := pods.List(bt.conn, nil)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(len(podSummary)).To(Equal(2))
|
Expect(len(podSummary)).To(Equal(2))
|
||||||
@ -317,6 +320,7 @@ var _ = Describe("Podman pods", func() {
|
|||||||
Expect(response.State).To(Equal(define.PodStateExited))
|
Expect(response.State).To(Equal(define.PodStateExited))
|
||||||
pruneResponse, err = pods.Prune(bt.conn, nil)
|
pruneResponse, err = pods.Prune(bt.conn, nil)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(len(pruneResponse)).To(Equal(1), "len(pruneResponse)")
|
||||||
// Validate status and record pod id of pod to be pruned
|
// Validate status and record pod id of pod to be pruned
|
||||||
Expect(response.State).To(Equal(define.PodStateExited))
|
Expect(response.State).To(Equal(define.PodStateExited))
|
||||||
podID := response.ID
|
podID := response.ID
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings_test
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package test_bindings
|
package bindings_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -1019,6 +1019,9 @@ var _ = Describe("Podman checkpoint", func() {
|
|||||||
"podman checkpoint and restore container out of and into pod (%s)",
|
"podman checkpoint and restore container out of and into pod (%s)",
|
||||||
share,
|
share,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
share := share // copy into local scope, for use inside function
|
||||||
|
|
||||||
It(testName, func() {
|
It(testName, func() {
|
||||||
if !criu.CheckForCriu(criu.PodCriuVersion) {
|
if !criu.CheckForCriu(criu.PodCriuVersion) {
|
||||||
Skip("CRIU is missing or too old.")
|
Skip("CRIU is missing or too old.")
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/containers/storage/pkg/reexec"
|
"github.com/containers/storage/pkg/reexec"
|
||||||
"github.com/containers/storage/pkg/stringid"
|
"github.com/containers/storage/pkg/stringid"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/onsi/ginkgo"
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
. "github.com/onsi/gomega/gexec"
|
. "github.com/onsi/gomega/gexec"
|
||||||
@ -33,16 +32,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
PODMAN_BINARY string
|
//lint:ignore ST1003
|
||||||
CONMON_BINARY string
|
PODMAN_BINARY string //nolint:golint,stylecheck
|
||||||
CNI_CONFIG_DIR string
|
INTEGRATION_ROOT string //nolint:golint,stylecheck
|
||||||
RUNC_BINARY string
|
CGROUP_MANAGER = "systemd" //nolint:golint,stylecheck
|
||||||
INTEGRATION_ROOT string
|
ARTIFACT_DIR = "/tmp/.artifacts" //nolint:golint,stylecheck
|
||||||
CGROUP_MANAGER = "systemd"
|
RESTORE_IMAGES = []string{ALPINE, BB, nginx} //nolint:golint,stylecheck
|
||||||
ARTIFACT_DIR = "/tmp/.artifacts"
|
|
||||||
RESTORE_IMAGES = []string{ALPINE, BB, nginx}
|
|
||||||
defaultWaitTimeout = 90
|
defaultWaitTimeout = 90
|
||||||
CGROUPSV2, _ = cgroups.IsCgroup2UnifiedMode()
|
CGROUPSV2, _ = cgroups.IsCgroup2UnifiedMode() //nolint:golint,stylecheck
|
||||||
)
|
)
|
||||||
|
|
||||||
// PodmanTestIntegration struct for command line options
|
// PodmanTestIntegration struct for command line options
|
||||||
@ -74,8 +71,6 @@ type testResult struct {
|
|||||||
length float64
|
length float64
|
||||||
}
|
}
|
||||||
|
|
||||||
var noCache = "Cannot run nocache with remote"
|
|
||||||
|
|
||||||
type testResultsSorted []testResult
|
type testResultsSorted []testResult
|
||||||
|
|
||||||
func (a testResultsSorted) Len() int { return len(a) }
|
func (a testResultsSorted) Len() int { return len(a) }
|
||||||
@ -475,7 +470,7 @@ func (p *PodmanTestIntegration) PodmanPID(args []string) (*PodmanSessionIntegrat
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
Fail(fmt.Sprintf("unable to run podman command: %s", strings.Join(podmanOptions, " ")))
|
Fail(fmt.Sprintf("unable to run podman command: %s", strings.Join(podmanOptions, " ")))
|
||||||
}
|
}
|
||||||
podmanSession := &PodmanSession{session}
|
podmanSession := &PodmanSession{Session: session}
|
||||||
return &PodmanSessionIntegration{podmanSession}, command.Process.Pid
|
return &PodmanSessionIntegration{podmanSession}, command.Process.Pid
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,9 +592,9 @@ func (p *PodmanTestIntegration) RunHealthCheck(cid string) error {
|
|||||||
return errors.Errorf("unable to detect %s as running", cid)
|
return errors.Errorf("unable to detect %s as running", cid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PodmanTestIntegration) CreateSeccompJson(in []byte) (string, error) {
|
func (p *PodmanTestIntegration) CreateSeccompJSON(in []byte) (string, error) {
|
||||||
jsonFile := filepath.Join(p.TempDir, "seccomp.json")
|
jsonFile := filepath.Join(p.TempDir, "seccomp.json")
|
||||||
err := WriteJsonFile(in, jsonFile)
|
err := WriteJSONFile(in, jsonFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -622,14 +617,14 @@ func SkipIfRootlessCgroupsV1(reason string) {
|
|||||||
func SkipIfRootless(reason string) {
|
func SkipIfRootless(reason string) {
|
||||||
checkReason(reason)
|
checkReason(reason)
|
||||||
if os.Geteuid() != 0 {
|
if os.Geteuid() != 0 {
|
||||||
ginkgo.Skip("[rootless]: " + reason)
|
Skip("[rootless]: " + reason)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SkipIfNotRootless(reason string) {
|
func SkipIfNotRootless(reason string) {
|
||||||
checkReason(reason)
|
checkReason(reason)
|
||||||
if os.Geteuid() == 0 {
|
if os.Geteuid() == 0 {
|
||||||
ginkgo.Skip("[notRootless]: " + reason)
|
Skip("[notRootless]: " + reason)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,7 +635,7 @@ func SkipIfSystemdNotRunning(reason string) {
|
|||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(*exec.Error); ok {
|
if _, ok := err.(*exec.Error); ok {
|
||||||
ginkgo.Skip("[notSystemd]: not running " + reason)
|
Skip("[notSystemd]: not running " + reason)
|
||||||
}
|
}
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}
|
}
|
||||||
@ -649,14 +644,14 @@ func SkipIfSystemdNotRunning(reason string) {
|
|||||||
func SkipIfNotSystemd(manager, reason string) {
|
func SkipIfNotSystemd(manager, reason string) {
|
||||||
checkReason(reason)
|
checkReason(reason)
|
||||||
if manager != "systemd" {
|
if manager != "systemd" {
|
||||||
ginkgo.Skip("[notSystemd]: " + reason)
|
Skip("[notSystemd]: " + reason)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SkipIfNotFedora() {
|
func SkipIfNotFedora() {
|
||||||
info := GetHostDistributionInfo()
|
info := GetHostDistributionInfo()
|
||||||
if info.Distribution != "fedora" {
|
if info.Distribution != "fedora" {
|
||||||
ginkgo.Skip("Test can only run on Fedora")
|
Skip("Test can only run on Fedora")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,10 +679,7 @@ func SkipIfCgroupV2(reason string) {
|
|||||||
|
|
||||||
func isContainerized() bool {
|
func isContainerized() bool {
|
||||||
// This is set to "podman" by podman automatically
|
// This is set to "podman" by podman automatically
|
||||||
if os.Getenv("container") != "" {
|
return os.Getenv("container") != ""
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func SkipIfContainerized(reason string) {
|
func SkipIfContainerized(reason string) {
|
||||||
@ -702,7 +694,7 @@ func SkipIfRemote(reason string) {
|
|||||||
if !IsRemote() {
|
if !IsRemote() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ginkgo.Skip("[remote]: " + reason)
|
Skip("[remote]: " + reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SkipIfInContainer skips a test if the test is run inside a container
|
// SkipIfInContainer skips a test if the test is run inside a container
|
||||||
@ -872,10 +864,10 @@ func (p *PodmanTestIntegration) removeCNINetwork(name string) {
|
|||||||
Expect(session.ExitCode()).To(BeNumerically("<=", 1), "Exit code must be 0 or 1")
|
Expect(session.ExitCode()).To(BeNumerically("<=", 1), "Exit code must be 0 or 1")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PodmanSessionIntegration) jq(jqCommand string) (string, error) {
|
func (s *PodmanSessionIntegration) jq(jqCommand string) (string, error) {
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
cmd := exec.Command("jq", jqCommand)
|
cmd := exec.Command("jq", jqCommand)
|
||||||
cmd.Stdin = strings.NewReader(p.OutputToString())
|
cmd.Stdin = strings.NewReader(s.OutputToString())
|
||||||
cmd.Stdout = &out
|
cmd.Stdout = &out
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
return strings.TrimRight(out.String(), "\n"), err
|
return strings.TrimRight(out.String(), "\n"), err
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package integration
|
package integration
|
||||||
|
|
||||||
var (
|
var (
|
||||||
STORAGE_FS = "vfs"
|
STORAGE_FS = "vfs" //nolint:golint,stylecheck
|
||||||
STORAGE_OPTIONS = "--storage-driver vfs"
|
STORAGE_OPTIONS = "--storage-driver vfs" //nolint:golint,stylecheck
|
||||||
ROOTLESS_STORAGE_FS = "vfs"
|
ROOTLESS_STORAGE_FS = "vfs" //nolint:golint,stylecheck
|
||||||
ROOTLESS_STORAGE_OPTIONS = "--storage-driver vfs"
|
ROOTLESS_STORAGE_OPTIONS = "--storage-driver vfs" //nolint:golint,stylecheck
|
||||||
CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, infra, labels, healthcheck, ubi_init, ubi_minimal, fedoraToolbox}
|
CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, infra, labels, healthcheck, UBI_INIT, UBI_MINIMAL, fedoraToolbox} //nolint:golint,stylecheck
|
||||||
nginx = "quay.io/libpod/alpine_nginx:latest"
|
nginx = "quay.io/libpod/alpine_nginx:latest"
|
||||||
BB_GLIBC = "docker.io/library/busybox:glibc"
|
BB_GLIBC = "docker.io/library/busybox:glibc" //nolint:golint,stylecheck
|
||||||
registry = "quay.io/libpod/registry:2.6"
|
registry = "quay.io/libpod/registry:2.6"
|
||||||
labels = "quay.io/libpod/alpine_labels:latest"
|
labels = "quay.io/libpod/alpine_labels:latest"
|
||||||
ubi_minimal = "registry.access.redhat.com/ubi8-minimal"
|
UBI_MINIMAL = "registry.access.redhat.com/ubi8-minimal" //nolint:golint,stylecheck
|
||||||
ubi_init = "registry.access.redhat.com/ubi8-init"
|
UBI_INIT = "registry.access.redhat.com/ubi8-init" //nolint:golint,stylecheck
|
||||||
cirros = "quay.io/libpod/cirros:latest"
|
cirros = "quay.io/libpod/cirros:latest"
|
||||||
)
|
)
|
||||||
|
@ -28,7 +28,7 @@ VOLUME %s/`, data, dest, dest)
|
|||||||
|
|
||||||
func createContainersConfFile(pTest *PodmanTestIntegration) {
|
func createContainersConfFile(pTest *PodmanTestIntegration) {
|
||||||
configPath := filepath.Join(pTest.TempDir, "containers.conf")
|
configPath := filepath.Join(pTest.TempDir, "containers.conf")
|
||||||
containersConf := []byte(fmt.Sprintf("[containers]\nprepare_volume_on_create = true\n"))
|
containersConf := []byte("[containers]\nprepare_volume_on_create = true\n")
|
||||||
err := ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
err := ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ var _ = Describe("Podman run", func() {
|
|||||||
configPath := filepath.Join(podmanTest.TempDir, "containers.conf")
|
configPath := filepath.Join(podmanTest.TempDir, "containers.conf")
|
||||||
os.Setenv("CONTAINERS_CONF", configPath)
|
os.Setenv("CONTAINERS_CONF", configPath)
|
||||||
|
|
||||||
containersConf := []byte(fmt.Sprintf("[engine]\nimage_copy_tmp_dir=\"/foobar\""))
|
containersConf := []byte("[engine]\nimage_copy_tmp_dir=\"/foobar\"")
|
||||||
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
@ -420,7 +420,7 @@ var _ = Describe("Podman run", func() {
|
|||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(Equal("/foobar"))
|
Expect(session.OutputToString()).To(Equal("/foobar"))
|
||||||
|
|
||||||
containersConf = []byte(fmt.Sprintf("[engine]\nimage_copy_tmp_dir=\"storage\""))
|
containersConf = []byte("[engine]\nimage_copy_tmp_dir=\"storage\"")
|
||||||
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
@ -432,7 +432,7 @@ var _ = Describe("Podman run", func() {
|
|||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("containers/storage/tmp"))
|
Expect(session.OutputToString()).To(ContainSubstring("containers/storage/tmp"))
|
||||||
|
|
||||||
containersConf = []byte(fmt.Sprintf("[engine]\nimage_copy_tmp_dir=\"storage1\""))
|
containersConf = []byte("[engine]\nimage_copy_tmp_dir=\"storage1\"")
|
||||||
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
|
@ -62,7 +62,7 @@ var _ = Describe("podman image scp", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman image scp root to rootless transfer", func() {
|
It("podman image scp root to rootless transfer", func() {
|
||||||
SkipIfNotRootless("this is a rootless only test, transfering from root to rootless using PodmanAsUser")
|
SkipIfNotRootless("this is a rootless only test, transferring from root to rootless using PodmanAsUser")
|
||||||
if IsRemote() {
|
if IsRemote() {
|
||||||
Skip("this test is only for non-remote")
|
Skip("this test is only for non-remote")
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,6 @@ func (p *PodmanTestIntegration) StopRemoteService() {
|
|||||||
if _, err := remoteSession.Wait(); err != nil {
|
if _, err := remoteSession.Wait(); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error on remote stop-wait %q", err)
|
fmt.Fprintf(os.Stderr, "error on remote stop-wait %q", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
parentPid := fmt.Sprintf("%d", p.RemoteSession.Pid)
|
parentPid := fmt.Sprintf("%d", p.RemoteSession.Pid)
|
||||||
pgrep := exec.Command("pgrep", "-P", parentPid)
|
pgrep := exec.Command("pgrep", "-P", parentPid)
|
||||||
|
@ -20,10 +20,7 @@ func isEventBackendJournald(podmanTest *PodmanTestIntegration) bool {
|
|||||||
}
|
}
|
||||||
info := podmanTest.Podman([]string{"info", "--format", "{{.Host.EventLogger}}"})
|
info := podmanTest.Podman([]string{"info", "--format", "{{.Host.EventLogger}}"})
|
||||||
info.WaitWithDefaultTimeout()
|
info.WaitWithDefaultTimeout()
|
||||||
if info.OutputToString() == "journald" {
|
return info.OutputToString() == "journald"
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = Describe("Podman logs", func() {
|
var _ = Describe("Podman logs", func() {
|
||||||
|
@ -185,7 +185,7 @@ var _ = Describe("Podman network", func() {
|
|||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
rm_func := func(rm string) {
|
rmFunc := func(rm string) {
|
||||||
It(fmt.Sprintf("podman network %s no args", rm), func() {
|
It(fmt.Sprintf("podman network %s no args", rm), func() {
|
||||||
session := podmanTest.Podman([]string{"network", rm})
|
session := podmanTest.Podman([]string{"network", rm})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
@ -213,8 +213,8 @@ var _ = Describe("Podman network", func() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
rm_func("rm")
|
rmFunc("rm")
|
||||||
rm_func("remove")
|
rmFunc("remove")
|
||||||
|
|
||||||
It("podman network inspect no args", func() {
|
It("podman network inspect no args", func() {
|
||||||
session := podmanTest.Podman([]string{"network", "inspect"})
|
session := podmanTest.Podman([]string{"network", "inspect"})
|
||||||
|
@ -95,6 +95,7 @@ LABEL marge=mom
|
|||||||
// Setup
|
// Setup
|
||||||
yamlDir := filepath.Join(tempdir, RandomString(12))
|
yamlDir := filepath.Join(tempdir, RandomString(12))
|
||||||
err := os.Mkdir(yamlDir, 0755)
|
err := os.Mkdir(yamlDir, 0755)
|
||||||
|
Expect(err).To(BeNil(), "mkdir "+yamlDir)
|
||||||
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
|
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
app1Dir := filepath.Join(yamlDir, "foobar")
|
app1Dir := filepath.Join(yamlDir, "foobar")
|
||||||
@ -131,6 +132,7 @@ LABEL marge=mom
|
|||||||
// Setup
|
// Setup
|
||||||
yamlDir := filepath.Join(tempdir, RandomString(12))
|
yamlDir := filepath.Join(tempdir, RandomString(12))
|
||||||
err := os.Mkdir(yamlDir, 0755)
|
err := os.Mkdir(yamlDir, 0755)
|
||||||
|
Expect(err).To(BeNil(), "mkdir "+yamlDir)
|
||||||
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
|
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
app1Dir := filepath.Join(yamlDir, "foobar")
|
app1Dir := filepath.Join(yamlDir, "foobar")
|
||||||
@ -167,6 +169,7 @@ LABEL marge=mom
|
|||||||
// Setup
|
// Setup
|
||||||
yamlDir := filepath.Join(tempdir, RandomString(12))
|
yamlDir := filepath.Join(tempdir, RandomString(12))
|
||||||
err := os.Mkdir(yamlDir, 0755)
|
err := os.Mkdir(yamlDir, 0755)
|
||||||
|
Expect(err).To(BeNil(), "mkdir "+yamlDir)
|
||||||
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
|
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
@ -213,6 +216,7 @@ LABEL marge=mom
|
|||||||
// Setup
|
// Setup
|
||||||
yamlDir := filepath.Join(tempdir, RandomString(12))
|
yamlDir := filepath.Join(tempdir, RandomString(12))
|
||||||
err := os.Mkdir(yamlDir, 0755)
|
err := os.Mkdir(yamlDir, 0755)
|
||||||
|
Expect(err).To(BeNil(), "os.Mkdir "+yamlDir)
|
||||||
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
|
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/containers/podman/v3/pkg/bindings"
|
|
||||||
"github.com/containers/podman/v3/pkg/bindings/play"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -17,6 +15,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/podman/v3/libpod/define"
|
"github.com/containers/podman/v3/libpod/define"
|
||||||
|
"github.com/containers/podman/v3/pkg/bindings"
|
||||||
|
"github.com/containers/podman/v3/pkg/bindings/play"
|
||||||
"github.com/containers/podman/v3/pkg/util"
|
"github.com/containers/podman/v3/pkg/util"
|
||||||
. "github.com/containers/podman/v3/test/utils"
|
. "github.com/containers/podman/v3/test/utils"
|
||||||
"github.com/containers/storage/pkg/stringid"
|
"github.com/containers/storage/pkg/stringid"
|
||||||
@ -319,16 +319,16 @@ spec:
|
|||||||
image: {{ .Image }}
|
image: {{ .Image }}
|
||||||
name: {{ .Name }}
|
name: {{ .Name }}
|
||||||
imagePullPolicy: {{ .PullPolicy }}
|
imagePullPolicy: {{ .PullPolicy }}
|
||||||
{{- if or .CpuRequest .CpuLimit .MemoryRequest .MemoryLimit }}
|
{{- if or .CPURequest .CPULimit .MemoryRequest .MemoryLimit }}
|
||||||
resources:
|
resources:
|
||||||
{{- if or .CpuRequest .MemoryRequest }}
|
{{- if or .CPURequest .MemoryRequest }}
|
||||||
requests:
|
requests:
|
||||||
{{if .CpuRequest }}cpu: {{ .CpuRequest }}{{ end }}
|
{{if .CPURequest }}cpu: {{ .CPURequest }}{{ end }}
|
||||||
{{if .MemoryRequest }}memory: {{ .MemoryRequest }}{{ end }}
|
{{if .MemoryRequest }}memory: {{ .MemoryRequest }}{{ end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if or .CpuLimit .MemoryLimit }}
|
{{- if or .CPULimit .MemoryLimit }}
|
||||||
limits:
|
limits:
|
||||||
{{if .CpuLimit }}cpu: {{ .CpuLimit }}{{ end }}
|
{{if .CPULimit }}cpu: {{ .CPULimit }}{{ end }}
|
||||||
{{if .MemoryLimit }}memory: {{ .MemoryLimit }}{{ end }}
|
{{if .MemoryLimit }}memory: {{ .MemoryLimit }}{{ end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@ -479,16 +479,16 @@ spec:
|
|||||||
image: {{ .Image }}
|
image: {{ .Image }}
|
||||||
name: {{ .Name }}
|
name: {{ .Name }}
|
||||||
imagePullPolicy: {{ .PullPolicy }}
|
imagePullPolicy: {{ .PullPolicy }}
|
||||||
{{- if or .CpuRequest .CpuLimit .MemoryRequest .MemoryLimit }}
|
{{- if or .CPURequest .CPULimit .MemoryRequest .MemoryLimit }}
|
||||||
resources:
|
resources:
|
||||||
{{- if or .CpuRequest .MemoryRequest }}
|
{{- if or .CPURequest .MemoryRequest }}
|
||||||
requests:
|
requests:
|
||||||
{{if .CpuRequest }}cpu: {{ .CpuRequest }}{{ end }}
|
{{if .CPURequest }}cpu: {{ .CPURequest }}{{ end }}
|
||||||
{{if .MemoryRequest }}memory: {{ .MemoryRequest }}{{ end }}
|
{{if .MemoryRequest }}memory: {{ .MemoryRequest }}{{ end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if or .CpuLimit .MemoryLimit }}
|
{{- if or .CPULimit .MemoryLimit }}
|
||||||
limits:
|
limits:
|
||||||
{{if .CpuLimit }}cpu: {{ .CpuLimit }}{{ end }}
|
{{if .CPULimit }}cpu: {{ .CPULimit }}{{ end }}
|
||||||
{{if .MemoryLimit }}memory: {{ .MemoryLimit }}{{ end }}
|
{{if .MemoryLimit }}memory: {{ .MemoryLimit }}{{ end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@ -820,12 +820,6 @@ func getDeployment(options ...deploymentOption) *Deployment {
|
|||||||
|
|
||||||
type deploymentOption func(*Deployment)
|
type deploymentOption func(*Deployment)
|
||||||
|
|
||||||
func withDeploymentLabel(k, v string) deploymentOption {
|
|
||||||
return func(deployment *Deployment) {
|
|
||||||
deployment.Labels[k] = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func withDeploymentAnnotation(k, v string) deploymentOption {
|
func withDeploymentAnnotation(k, v string) deploymentOption {
|
||||||
return func(deployment *Deployment) {
|
return func(deployment *Deployment) {
|
||||||
deployment.Annotations[k] = v
|
deployment.Annotations[k] = v
|
||||||
@ -866,8 +860,8 @@ type Ctr struct {
|
|||||||
Image string
|
Image string
|
||||||
Cmd []string
|
Cmd []string
|
||||||
Arg []string
|
Arg []string
|
||||||
CpuRequest string
|
CPURequest string
|
||||||
CpuLimit string
|
CPULimit string
|
||||||
MemoryRequest string
|
MemoryRequest string
|
||||||
MemoryLimit string
|
MemoryLimit string
|
||||||
SecurityContext bool
|
SecurityContext bool
|
||||||
@ -947,15 +941,15 @@ func withImage(img string) ctrOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func withCpuRequest(request string) ctrOption {
|
func withCPURequest(request string) ctrOption {
|
||||||
return func(c *Ctr) {
|
return func(c *Ctr) {
|
||||||
c.CpuRequest = request
|
c.CPURequest = request
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func withCpuLimit(limit string) ctrOption {
|
func withCPULimit(limit string) ctrOption {
|
||||||
return func(c *Ctr) {
|
return func(c *Ctr) {
|
||||||
c.CpuLimit = limit
|
c.CPULimit = limit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1848,7 +1842,7 @@ var _ = Describe("Podman play kube", func() {
|
|||||||
It("podman play kube seccomp container level", func() {
|
It("podman play kube seccomp container level", func() {
|
||||||
SkipIfRemote("podman-remote does not support --seccomp-profile-root flag")
|
SkipIfRemote("podman-remote does not support --seccomp-profile-root flag")
|
||||||
// expect play kube is expected to set a seccomp label if it's applied as an annotation
|
// expect play kube is expected to set a seccomp label if it's applied as an annotation
|
||||||
jsonFile, err := podmanTest.CreateSeccompJson(seccompPwdEPERM)
|
jsonFile, err := podmanTest.CreateSeccompJSON(seccompPwdEPERM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
Skip("Failed to prepare seccomp.json for test.")
|
Skip("Failed to prepare seccomp.json for test.")
|
||||||
@ -1861,7 +1855,7 @@ var _ = Describe("Podman play kube", func() {
|
|||||||
err = generateKubeYaml("pod", pod, kubeYaml)
|
err = generateKubeYaml("pod", pod, kubeYaml)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
// CreateSeccompJson will put the profile into podmanTest.TempDir. Use --seccomp-profile-root to tell play kube where to look
|
// CreateSeccompJSON will put the profile into podmanTest.TempDir. Use --seccomp-profile-root to tell play kube where to look
|
||||||
kube := podmanTest.Podman([]string{"play", "kube", "--seccomp-profile-root", podmanTest.TempDir, kubeYaml})
|
kube := podmanTest.Podman([]string{"play", "kube", "--seccomp-profile-root", podmanTest.TempDir, kubeYaml})
|
||||||
kube.WaitWithDefaultTimeout()
|
kube.WaitWithDefaultTimeout()
|
||||||
Expect(kube).Should(Exit(0))
|
Expect(kube).Should(Exit(0))
|
||||||
@ -1875,7 +1869,7 @@ var _ = Describe("Podman play kube", func() {
|
|||||||
It("podman play kube seccomp pod level", func() {
|
It("podman play kube seccomp pod level", func() {
|
||||||
SkipIfRemote("podman-remote does not support --seccomp-profile-root flag")
|
SkipIfRemote("podman-remote does not support --seccomp-profile-root flag")
|
||||||
// expect play kube is expected to set a seccomp label if it's applied as an annotation
|
// expect play kube is expected to set a seccomp label if it's applied as an annotation
|
||||||
jsonFile, err := podmanTest.CreateSeccompJson(seccompPwdEPERM)
|
jsonFile, err := podmanTest.CreateSeccompJSON(seccompPwdEPERM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
Skip("Failed to prepare seccomp.json for test.")
|
Skip("Failed to prepare seccomp.json for test.")
|
||||||
@ -1888,7 +1882,7 @@ var _ = Describe("Podman play kube", func() {
|
|||||||
err = generateKubeYaml("pod", pod, kubeYaml)
|
err = generateKubeYaml("pod", pod, kubeYaml)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
// CreateSeccompJson will put the profile into podmanTest.TempDir. Use --seccomp-profile-root to tell play kube where to look
|
// CreateSeccompJSON will put the profile into podmanTest.TempDir. Use --seccomp-profile-root to tell play kube where to look
|
||||||
kube := podmanTest.Podman([]string{"play", "kube", "--seccomp-profile-root", podmanTest.TempDir, kubeYaml})
|
kube := podmanTest.Podman([]string{"play", "kube", "--seccomp-profile-root", podmanTest.TempDir, kubeYaml})
|
||||||
kube.WaitWithDefaultTimeout()
|
kube.WaitWithDefaultTimeout()
|
||||||
Expect(kube).Should(Exit(0))
|
Expect(kube).Should(Exit(0))
|
||||||
@ -2348,19 +2342,19 @@ VOLUME %s`, ALPINE, hostPathDir+"/")
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
numReplicas int32 = 3
|
numReplicas int32 = 3
|
||||||
expectedCpuRequest string = "100m"
|
expectedCPURequest string = "100m"
|
||||||
expectedCpuLimit string = "200m"
|
expectedCPULimit string = "200m"
|
||||||
expectedMemoryRequest string = "10000000"
|
expectedMemoryRequest string = "10000000"
|
||||||
expectedMemoryLimit string = "20000000"
|
expectedMemoryLimit string = "20000000"
|
||||||
)
|
)
|
||||||
|
|
||||||
expectedCpuQuota := milliCPUToQuota(expectedCpuLimit)
|
expectedCPUQuota := milliCPUToQuota(expectedCPULimit)
|
||||||
|
|
||||||
deployment := getDeployment(
|
deployment := getDeployment(
|
||||||
withReplicas(numReplicas),
|
withReplicas(numReplicas),
|
||||||
withPod(getPod(withCtr(getCtr(
|
withPod(getPod(withCtr(getCtr(
|
||||||
withCpuRequest(expectedCpuRequest),
|
withCPURequest(expectedCPURequest),
|
||||||
withCpuLimit(expectedCpuLimit),
|
withCPULimit(expectedCPULimit),
|
||||||
withMemoryRequest(expectedMemoryRequest),
|
withMemoryRequest(expectedMemoryRequest),
|
||||||
withMemoryLimit(expectedMemoryLimit),
|
withMemoryLimit(expectedMemoryLimit),
|
||||||
)))))
|
)))))
|
||||||
@ -2372,6 +2366,7 @@ VOLUME %s`, ALPINE, hostPathDir+"/")
|
|||||||
Expect(kube).Should(Exit(0))
|
Expect(kube).Should(Exit(0))
|
||||||
|
|
||||||
for _, pod := range getPodNamesInDeployment(deployment) {
|
for _, pod := range getPodNamesInDeployment(deployment) {
|
||||||
|
pod := pod // copy into local scope
|
||||||
inspect := podmanTest.Podman([]string{"inspect", getCtrNameInPod(&pod), "--format", `
|
inspect := podmanTest.Podman([]string{"inspect", getCtrNameInPod(&pod), "--format", `
|
||||||
CpuPeriod: {{ .HostConfig.CpuPeriod }}
|
CpuPeriod: {{ .HostConfig.CpuPeriod }}
|
||||||
CpuQuota: {{ .HostConfig.CpuQuota }}
|
CpuQuota: {{ .HostConfig.CpuQuota }}
|
||||||
@ -2379,7 +2374,7 @@ Memory: {{ .HostConfig.Memory }}
|
|||||||
MemoryReservation: {{ .HostConfig.MemoryReservation }}`})
|
MemoryReservation: {{ .HostConfig.MemoryReservation }}`})
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
Expect(inspect).Should(Exit(0))
|
Expect(inspect).Should(Exit(0))
|
||||||
Expect(inspect.OutputToString()).To(ContainSubstring(fmt.Sprintf("%s: %d", "CpuQuota", expectedCpuQuota)))
|
Expect(inspect.OutputToString()).To(ContainSubstring(fmt.Sprintf("%s: %d", "CpuQuota", expectedCPUQuota)))
|
||||||
Expect(inspect.OutputToString()).To(ContainSubstring("MemoryReservation: " + expectedMemoryRequest))
|
Expect(inspect.OutputToString()).To(ContainSubstring("MemoryReservation: " + expectedMemoryRequest))
|
||||||
Expect(inspect.OutputToString()).To(ContainSubstring("Memory: " + expectedMemoryLimit))
|
Expect(inspect.OutputToString()).To(ContainSubstring("Memory: " + expectedMemoryLimit))
|
||||||
}
|
}
|
||||||
@ -2391,12 +2386,12 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`})
|
|||||||
podmanTest.CgroupManager = "systemd"
|
podmanTest.CgroupManager = "systemd"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
expectedCpuLimit string = "1"
|
expectedCPULimit string = "1"
|
||||||
)
|
)
|
||||||
|
|
||||||
deployment := getDeployment(
|
deployment := getDeployment(
|
||||||
withPod(getPod(withCtr(getCtr(
|
withPod(getPod(withCtr(getCtr(
|
||||||
withCpuLimit(expectedCpuLimit),
|
withCPULimit(expectedCPULimit),
|
||||||
)))))
|
)))))
|
||||||
err := generateKubeYaml("deployment", deployment, kubeYaml)
|
err := generateKubeYaml("deployment", deployment, kubeYaml)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
@ -2406,6 +2401,7 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`})
|
|||||||
Expect(kube).Should(Exit(0))
|
Expect(kube).Should(Exit(0))
|
||||||
|
|
||||||
for _, pod := range getPodNamesInDeployment(deployment) {
|
for _, pod := range getPodNamesInDeployment(deployment) {
|
||||||
|
pod := pod // copy into local scope
|
||||||
inspect := podmanTest.Podman([]string{"inspect", getCtrNameInPod(&pod), "--format", `{{ .HostConfig.CpuPeriod }}:{{ .HostConfig.CpuQuota }}`})
|
inspect := podmanTest.Podman([]string{"inspect", getCtrNameInPod(&pod), "--format", `{{ .HostConfig.CpuPeriod }}:{{ .HostConfig.CpuQuota }}`})
|
||||||
|
|
||||||
inspect.WaitWithDefaultTimeout()
|
inspect.WaitWithDefaultTimeout()
|
||||||
@ -3054,6 +3050,7 @@ ENV OPENJ9_JAVA_OPTIONS=%q
|
|||||||
|
|
||||||
deployment := getDeployment(withPod(pod))
|
deployment := getDeployment(withPod(pod))
|
||||||
deploymentYaml, err := getKubeYaml("deployment", deployment)
|
deploymentYaml, err := getKubeYaml("deployment", deployment)
|
||||||
|
Expect(err).To(BeNil(), "getKubeYaml(deployment)")
|
||||||
yamls := []string{cmYaml, deploymentYaml}
|
yamls := []string{cmYaml, deploymentYaml}
|
||||||
err = generateMultiDocKubeYaml(yamls, kubeYaml)
|
err = generateMultiDocKubeYaml(yamls, kubeYaml)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
@ -132,11 +132,11 @@ var _ = Describe("Podman pod rm", func() {
|
|||||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
|
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
|
||||||
fmt.Printf("Started container running in one pod")
|
fmt.Printf("Started container running in one pod")
|
||||||
|
|
||||||
num_pods := podmanTest.NumberOfPods()
|
numPods := podmanTest.NumberOfPods()
|
||||||
Expect(num_pods).To(Equal(2))
|
Expect(numPods).To(Equal(2))
|
||||||
ps := podmanTest.Podman([]string{"pod", "ps"})
|
ps := podmanTest.Podman([]string{"pod", "ps"})
|
||||||
ps.WaitWithDefaultTimeout()
|
ps.WaitWithDefaultTimeout()
|
||||||
fmt.Printf("Current %d pod(s):\n%s\n", num_pods, ps.OutputToString())
|
fmt.Printf("Current %d pod(s):\n%s\n", numPods, ps.OutputToString())
|
||||||
|
|
||||||
fmt.Printf("Removing all empty pods\n")
|
fmt.Printf("Removing all empty pods\n")
|
||||||
result := podmanTest.Podman([]string{"pod", "rm", "-a"})
|
result := podmanTest.Podman([]string{"pod", "rm", "-a"})
|
||||||
@ -145,11 +145,11 @@ var _ = Describe("Podman pod rm", func() {
|
|||||||
foundExpectedError, _ := result.ErrorGrepString("cannot be removed")
|
foundExpectedError, _ := result.ErrorGrepString("cannot be removed")
|
||||||
Expect(foundExpectedError).To(Equal(true))
|
Expect(foundExpectedError).To(Equal(true))
|
||||||
|
|
||||||
num_pods = podmanTest.NumberOfPods()
|
numPods = podmanTest.NumberOfPods()
|
||||||
ps = podmanTest.Podman([]string{"pod", "ps"})
|
ps = podmanTest.Podman([]string{"pod", "ps"})
|
||||||
ps.WaitWithDefaultTimeout()
|
ps.WaitWithDefaultTimeout()
|
||||||
fmt.Printf("Final %d pod(s):\n%s\n", num_pods, ps.OutputToString())
|
fmt.Printf("Final %d pod(s):\n%s\n", numPods, ps.OutputToString())
|
||||||
Expect(num_pods).To(Equal(1))
|
Expect(numPods).To(Equal(1))
|
||||||
// Confirm top container still running inside remaining pod
|
// Confirm top container still running inside remaining pod
|
||||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
|
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
|
||||||
})
|
})
|
||||||
|
@ -443,11 +443,10 @@ var _ = Describe("Podman ps", func() {
|
|||||||
// sanity check in case an oddly formatted size appears
|
// sanity check in case an oddly formatted size appears
|
||||||
if len(matches1) < 2 || len(matches2) < 2 {
|
if len(matches1) < 2 || len(matches2) < 2 {
|
||||||
return sortedArr[i] < sortedArr[j]
|
return sortedArr[i] < sortedArr[j]
|
||||||
} else {
|
}
|
||||||
size1, _ := units.FromHumanSize(matches1[1])
|
size1, _ := units.FromHumanSize(matches1[1])
|
||||||
size2, _ := units.FromHumanSize(matches2[1])
|
size2, _ := units.FromHumanSize(matches2[1])
|
||||||
return size1 < size2
|
return size1 < size2
|
||||||
}
|
|
||||||
})).To(BeTrue())
|
})).To(BeTrue())
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -279,7 +279,7 @@ var _ = Describe("Podman pull", func() {
|
|||||||
// Pulling a multi-image archive without further specifying
|
// Pulling a multi-image archive without further specifying
|
||||||
// which image _must_ error out. Pulling is restricted to one
|
// which image _must_ error out. Pulling is restricted to one
|
||||||
// image.
|
// image.
|
||||||
session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz")})
|
session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(125))
|
Expect(session).Should(Exit(125))
|
||||||
expectedError := "Unexpected tar manifest.json: expected 1 item, got 2"
|
expectedError := "Unexpected tar manifest.json: expected 1 item, got 2"
|
||||||
@ -288,31 +288,31 @@ var _ = Describe("Podman pull", func() {
|
|||||||
|
|
||||||
// Now pull _one_ image from a multi-image archive via the name
|
// Now pull _one_ image from a multi-image archive via the name
|
||||||
// and index syntax.
|
// and index syntax.
|
||||||
session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz:@0")})
|
session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:@0"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz:example.com/empty:latest")})
|
session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:example.com/empty:latest"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz:@1")})
|
session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:@1"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz:example.com/empty/but:different")})
|
session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:example.com/empty/but:different"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
||||||
// Now check for some errors.
|
// Now check for some errors.
|
||||||
session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz:foo.com/does/not/exist:latest")})
|
session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:foo.com/does/not/exist:latest"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(125))
|
Expect(session).Should(Exit(125))
|
||||||
expectedError = "Tag \"foo.com/does/not/exist:latest\" not found"
|
expectedError = "Tag \"foo.com/does/not/exist:latest\" not found"
|
||||||
found, _ = session.ErrorGrepString(expectedError)
|
found, _ = session.ErrorGrepString(expectedError)
|
||||||
Expect(found).To(Equal(true))
|
Expect(found).To(Equal(true))
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz:@2")})
|
session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:@2"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(125))
|
Expect(session).Should(Exit(125))
|
||||||
expectedError = "Invalid source index @2, only 2 manifest items available"
|
expectedError = "Invalid source index @2, only 2 manifest items available"
|
||||||
@ -391,7 +391,7 @@ var _ = Describe("Podman pull", func() {
|
|||||||
setup := podmanTest.Podman([]string{"images", ALPINE, "-q", "--no-trunc"})
|
setup := podmanTest.Podman([]string{"images", ALPINE, "-q", "--no-trunc"})
|
||||||
setup.WaitWithDefaultTimeout()
|
setup.WaitWithDefaultTimeout()
|
||||||
Expect(setup).Should(Exit(0))
|
Expect(setup).Should(Exit(0))
|
||||||
shortImageId := strings.Split(setup.OutputToString(), ":")[1]
|
shortImageID := strings.Split(setup.OutputToString(), ":")[1]
|
||||||
|
|
||||||
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
|
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
|
||||||
rmi.WaitWithDefaultTimeout()
|
rmi.WaitWithDefaultTimeout()
|
||||||
@ -401,7 +401,7 @@ var _ = Describe("Podman pull", func() {
|
|||||||
pull.WaitWithDefaultTimeout()
|
pull.WaitWithDefaultTimeout()
|
||||||
Expect(pull).Should(Exit(0))
|
Expect(pull).Should(Exit(0))
|
||||||
|
|
||||||
Expect(pull.OutputToString()).To(ContainSubstring(shortImageId))
|
Expect(pull.OutputToString()).To(ContainSubstring(shortImageID))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman pull check all tags", func() {
|
It("podman pull check all tags", func() {
|
||||||
|
@ -97,19 +97,19 @@ var _ = Describe("Podman rmi", func() {
|
|||||||
setup := podmanTest.Podman([]string{"images", "-q", cirros})
|
setup := podmanTest.Podman([]string{"images", "-q", cirros})
|
||||||
setup.WaitWithDefaultTimeout()
|
setup.WaitWithDefaultTimeout()
|
||||||
Expect(setup).Should(Exit(0))
|
Expect(setup).Should(Exit(0))
|
||||||
cirrosId := setup.OutputToString()
|
cirrosID := setup.OutputToString()
|
||||||
|
|
||||||
session := podmanTest.Podman([]string{"tag", "cirros", "foo:bar", "foo"})
|
session := podmanTest.Podman([]string{"tag", "cirros", "foo:bar", "foo"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
||||||
// Trying without --force should fail
|
// Trying without --force should fail
|
||||||
result := podmanTest.Podman([]string{"rmi", cirrosId})
|
result := podmanTest.Podman([]string{"rmi", cirrosID})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).To(ExitWithError())
|
Expect(result).To(ExitWithError())
|
||||||
|
|
||||||
// With --force it should work
|
// With --force it should work
|
||||||
resultForce := podmanTest.Podman([]string{"rmi", "-f", cirrosId})
|
resultForce := podmanTest.Podman([]string{"rmi", "-f", cirrosID})
|
||||||
resultForce.WaitWithDefaultTimeout()
|
resultForce.WaitWithDefaultTimeout()
|
||||||
Expect(resultForce).Should(Exit(0))
|
Expect(resultForce).Should(Exit(0))
|
||||||
})
|
})
|
||||||
|
@ -789,7 +789,7 @@ EXPOSE 2004-2005/tcp`, ALPINE)
|
|||||||
Expect(run.OutputToString()).ToNot(ContainSubstring("127.0.0.1 %s", hostname))
|
Expect(run.OutputToString()).ToNot(ContainSubstring("127.0.0.1 %s", hostname))
|
||||||
})
|
})
|
||||||
|
|
||||||
ping_test := func(netns string) {
|
pingTest := func(netns string) {
|
||||||
hostname := "testctr"
|
hostname := "testctr"
|
||||||
run := podmanTest.Podman([]string{"run", netns, "--hostname", hostname, ALPINE, "ping", "-c", "1", hostname})
|
run := podmanTest.Podman([]string{"run", netns, "--hostname", hostname, ALPINE, "ping", "-c", "1", hostname})
|
||||||
run.WaitWithDefaultTimeout()
|
run.WaitWithDefaultTimeout()
|
||||||
@ -801,11 +801,11 @@ EXPOSE 2004-2005/tcp`, ALPINE)
|
|||||||
}
|
}
|
||||||
|
|
||||||
It("podman attempt to ping container name and hostname --net=none", func() {
|
It("podman attempt to ping container name and hostname --net=none", func() {
|
||||||
ping_test("--net=none")
|
pingTest("--net=none")
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman attempt to ping container name and hostname --net=private", func() {
|
It("podman attempt to ping container name and hostname --net=private", func() {
|
||||||
ping_test("--net=private")
|
pingTest("--net=private")
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman run check dnsname plugin", func() {
|
It("podman run check dnsname plugin", func() {
|
||||||
|
@ -21,18 +21,18 @@ func containerCapMatchesHost(ctrCap string, hostCap string) {
|
|||||||
if isRootless() {
|
if isRootless() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctrCap_n, err := strconv.ParseUint(ctrCap, 16, 64)
|
ctrCapN, err := strconv.ParseUint(ctrCap, 16, 64)
|
||||||
Expect(err).NotTo(HaveOccurred(), "Error parsing %q as hex", ctrCap)
|
Expect(err).NotTo(HaveOccurred(), "Error parsing %q as hex", ctrCap)
|
||||||
|
|
||||||
hostCap_n, err := strconv.ParseUint(hostCap, 16, 64)
|
hostCapN, err := strconv.ParseUint(hostCap, 16, 64)
|
||||||
Expect(err).NotTo(HaveOccurred(), "Error parsing %q as hex", hostCap)
|
Expect(err).NotTo(HaveOccurred(), "Error parsing %q as hex", hostCap)
|
||||||
|
|
||||||
// host caps can never be zero (except rootless).
|
// host caps can never be zero (except rootless).
|
||||||
// and host caps must always be a superset (inclusive) of container
|
// and host caps must always be a superset (inclusive) of container
|
||||||
Expect(hostCap_n).To(BeNumerically(">", 0), "host cap %q should be nonzero", hostCap)
|
Expect(hostCapN).To(BeNumerically(">", 0), "host cap %q should be nonzero", hostCap)
|
||||||
Expect(hostCap_n).To(BeNumerically(">=", ctrCap_n), "host cap %q should never be less than container cap %q", hostCap, ctrCap)
|
Expect(hostCapN).To(BeNumerically(">=", ctrCapN), "host cap %q should never be less than container cap %q", hostCap, ctrCap)
|
||||||
hostCap_masked := hostCap_n & (1<<len(capability.List()) - 1)
|
hostCapMasked := hostCapN & (1<<len(capability.List()) - 1)
|
||||||
Expect(ctrCap_n).To(Equal(hostCap_masked), "container cap %q is not a subset of host cap %q", ctrCap, hostCap)
|
Expect(ctrCapN).To(Equal(hostCapMasked), "container cap %q is not a subset of host cap %q", ctrCap, hostCap)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = Describe("Podman privileged container tests", func() {
|
var _ = Describe("Podman privileged container tests", func() {
|
||||||
|
@ -320,7 +320,7 @@ var _ = Describe("Podman run", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman test init labels", func() {
|
It("podman test init labels", func() {
|
||||||
session := podmanTest.Podman([]string{"create", ubi_init, "/sbin/init"})
|
session := podmanTest.Podman([]string{"create", UBI_INIT, "/sbin/init"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
cid := session.OutputToString()
|
cid := session.OutputToString()
|
||||||
|
@ -318,7 +318,7 @@ var _ = Describe("Podman run", func() {
|
|||||||
|
|
||||||
forbidGetCWDSeccompProfile := func() string {
|
forbidGetCWDSeccompProfile := func() string {
|
||||||
in := []byte(`{"defaultAction":"SCMP_ACT_ALLOW","syscalls":[{"name":"getcwd","action":"SCMP_ACT_ERRNO"}]}`)
|
in := []byte(`{"defaultAction":"SCMP_ACT_ALLOW","syscalls":[{"name":"getcwd","action":"SCMP_ACT_ERRNO"}]}`)
|
||||||
jsonFile, err := podmanTest.CreateSeccompJson(in)
|
jsonFile, err := podmanTest.CreateSeccompJSON(in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
Skip("Failed to prepare seccomp.json for test.")
|
Skip("Failed to prepare seccomp.json for test.")
|
||||||
|
@ -151,6 +151,7 @@ var _ = Describe("Podman run with volumes", func() {
|
|||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
testFile := filepath.Join(mountPath, "test1")
|
testFile := filepath.Join(mountPath, "test1")
|
||||||
f, err := os.Create(testFile)
|
f, err := os.Create(testFile)
|
||||||
|
Expect(err).To(BeNil(), "os.Create(testfile)")
|
||||||
f.Close()
|
f.Close()
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
session := podmanTest.Podman([]string{"run", "-v", fmt.Sprintf("%s:/data", mountPath), redis, "ls", "/data/test1"})
|
session := podmanTest.Podman([]string{"run", "-v", fmt.Sprintf("%s:/data", mountPath), redis, "ls", "/data/test1"})
|
||||||
@ -550,6 +551,7 @@ VOLUME /test/`, ALPINE)
|
|||||||
os.Mkdir(mountPath, 0755)
|
os.Mkdir(mountPath, 0755)
|
||||||
testFile := filepath.Join(mountPath, "test1")
|
testFile := filepath.Join(mountPath, "test1")
|
||||||
f, err := os.Create(testFile)
|
f, err := os.Create(testFile)
|
||||||
|
Expect(err).To(BeNil(), "os.Create "+testFile)
|
||||||
f.Close()
|
f.Close()
|
||||||
|
|
||||||
// Make sure host directory gets mounted in to container as overlay
|
// Make sure host directory gets mounted in to container as overlay
|
||||||
|
@ -105,7 +105,8 @@ var _ = Describe("podman container runlabel", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman container runlabel global options", func() {
|
It("podman container runlabel global options", func() {
|
||||||
Skip("Test nonfunctional for podman-in-podman testing")
|
fmt.Printf("FIXME: for lint. Remove when you fix this test: %s", GlobalDockerfile)
|
||||||
|
Skip("FIXME: $GLOBAL_OPTS does not work at all, #12436")
|
||||||
image := "podman-global-test:ls"
|
image := "podman-global-test:ls"
|
||||||
podmanTest.BuildImage(GlobalDockerfile, image, "false")
|
podmanTest.BuildImage(GlobalDockerfile, image, "false")
|
||||||
result := podmanTest.Podman([]string{"--syslog", "--log-level", "debug", "container", "runlabel", "RUN", image})
|
result := podmanTest.Podman([]string{"--syslog", "--log-level", "debug", "container", "runlabel", "RUN", image})
|
||||||
|
@ -208,7 +208,6 @@ var _ = Describe("Podman secret", func() {
|
|||||||
// no env variable set, should fail
|
// no env variable set, should fail
|
||||||
session := podmanTest.Podman([]string{"secret", "create", "--env", "a", "MYENVVAR"})
|
session := podmanTest.Podman([]string{"secret", "create", "--env", "a", "MYENVVAR"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
secrID := session.OutputToString()
|
|
||||||
Expect(session).To(ExitWithError())
|
Expect(session).To(ExitWithError())
|
||||||
|
|
||||||
os.Setenv("MYENVVAR", "somedata")
|
os.Setenv("MYENVVAR", "somedata")
|
||||||
@ -218,7 +217,7 @@ var _ = Describe("Podman secret", func() {
|
|||||||
|
|
||||||
session = podmanTest.Podman([]string{"secret", "create", "--env", "a", "MYENVVAR"})
|
session = podmanTest.Podman([]string{"secret", "create", "--env", "a", "MYENVVAR"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
secrID = session.OutputToString()
|
secrID := session.OutputToString()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
||||||
inspect := podmanTest.Podman([]string{"secret", "inspect", "--format", "{{.ID}}", secrID})
|
inspect := podmanTest.Podman([]string{"secret", "inspect", "--format", "{{.ID}}", secrID})
|
||||||
|
@ -50,8 +50,8 @@ WantedBy=multi-user.target
|
|||||||
SkipIfRootless("rootless can not write to /etc")
|
SkipIfRootless("rootless can not write to /etc")
|
||||||
SkipIfContainerized("test does not have systemd as pid 1")
|
SkipIfContainerized("test does not have systemd as pid 1")
|
||||||
|
|
||||||
sys_file := ioutil.WriteFile("/etc/systemd/system/redis.service", []byte(systemdUnitFile), 0644)
|
sysFile := ioutil.WriteFile("/etc/systemd/system/redis.service", []byte(systemdUnitFile), 0644)
|
||||||
Expect(sys_file).To(BeNil())
|
Expect(sysFile).To(BeNil())
|
||||||
defer func() {
|
defer func() {
|
||||||
stop := SystemExec("bash", []string{"-c", "systemctl stop redis"})
|
stop := SystemExec("bash", []string{"-c", "systemctl stop redis"})
|
||||||
os.Remove("/etc/systemd/system/redis.service")
|
os.Remove("/etc/systemd/system/redis.service")
|
||||||
@ -78,7 +78,7 @@ WantedBy=multi-user.target
|
|||||||
|
|
||||||
It("podman run container with systemd PID1", func() {
|
It("podman run container with systemd PID1", func() {
|
||||||
ctrName := "testSystemd"
|
ctrName := "testSystemd"
|
||||||
run := podmanTest.Podman([]string{"run", "--name", ctrName, "-t", "-i", "-d", ubi_init, "/sbin/init"})
|
run := podmanTest.Podman([]string{"run", "--name", ctrName, "-t", "-i", "-d", UBI_INIT, "/sbin/init"})
|
||||||
run.WaitWithDefaultTimeout()
|
run.WaitWithDefaultTimeout()
|
||||||
Expect(run).Should(Exit(0))
|
Expect(run).Should(Exit(0))
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ WantedBy=multi-user.target
|
|||||||
|
|
||||||
It("podman create container with systemd entrypoint triggers systemd mode", func() {
|
It("podman create container with systemd entrypoint triggers systemd mode", func() {
|
||||||
ctrName := "testCtr"
|
ctrName := "testCtr"
|
||||||
run := podmanTest.Podman([]string{"create", "--name", ctrName, "--entrypoint", "/sbin/init", ubi_init})
|
run := podmanTest.Podman([]string{"create", "--name", ctrName, "--entrypoint", "/sbin/init", UBI_INIT})
|
||||||
run.WaitWithDefaultTimeout()
|
run.WaitWithDefaultTimeout()
|
||||||
Expect(run).Should(Exit(0))
|
Expect(run).Should(Exit(0))
|
||||||
|
|
||||||
|
@ -66,9 +66,7 @@ var _ = Describe("Toolbox-specific testing", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman run --dns=none - allows self-management of /etc/resolv.conf", func() {
|
It("podman run --dns=none - allows self-management of /etc/resolv.conf", func() {
|
||||||
var session *PodmanSessionIntegration
|
session := podmanTest.Podman([]string{"run", "--dns", "none", ALPINE, "sh", "-c",
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"run", "--dns", "none", ALPINE, "sh", "-c",
|
|
||||||
"rm -f /etc/resolv.conf; touch -d '1970-01-01 00:02:03' /etc/resolv.conf; stat -c %s:%Y /etc/resolv.conf"})
|
"rm -f /etc/resolv.conf; touch -d '1970-01-01 00:02:03' /etc/resolv.conf; stat -c %s:%Y /etc/resolv.conf"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
@ -76,9 +74,7 @@ var _ = Describe("Toolbox-specific testing", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman run --no-hosts - allows self-management of /etc/hosts", func() {
|
It("podman run --no-hosts - allows self-management of /etc/hosts", func() {
|
||||||
var session *PodmanSessionIntegration
|
session := podmanTest.Podman([]string{"run", "--no-hosts", ALPINE, "sh", "-c",
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"run", "--no-hosts", ALPINE, "sh", "-c",
|
|
||||||
"rm -f /etc/hosts; touch -d '1970-01-01 00:02:03' /etc/hosts; stat -c %s:%Y /etc/hosts"})
|
"rm -f /etc/hosts; touch -d '1970-01-01 00:02:03' /etc/hosts; stat -c %s:%Y /etc/hosts"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
@ -164,9 +160,7 @@ var _ = Describe("Toolbox-specific testing", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman create --userns=keep-id --user root:root - entrypoint - entrypoint is executed as root", func() {
|
It("podman create --userns=keep-id --user root:root - entrypoint - entrypoint is executed as root", func() {
|
||||||
var session *PodmanSessionIntegration
|
session := podmanTest.Podman([]string{"run", "--userns=keep-id", "--user", "root:root", ALPINE,
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"run", "--userns=keep-id", "--user", "root:root", ALPINE,
|
|
||||||
"id"})
|
"id"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
@ -97,13 +97,12 @@ var _ = Describe("Podman volume create", func() {
|
|||||||
|
|
||||||
session = podmanTest.Podman([]string{"volume", "create", "my_vol2"})
|
session = podmanTest.Podman([]string{"volume", "create", "my_vol2"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
volName = session.OutputToString()
|
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"volume", "import", "my_vol2", "hello.tar"})
|
session = podmanTest.Podman([]string{"volume", "import", "my_vol2", "hello.tar"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
volName = session.OutputToString()
|
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
Expect(session.OutputToString()).To(Equal(""), "output of volume import")
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"run", "--volume", "my_vol2:/data", ALPINE, "cat", "/data/test"})
|
session = podmanTest.Podman([]string{"run", "--volume", "my_vol2:/data", ALPINE, "cat", "/data/test"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
@ -129,8 +129,8 @@ func (d *DirDriver) Capabilities() *volume.CapabilitiesResponse {
|
|||||||
logrus.Infof("Hit Capabilities() endpoint")
|
logrus.Infof("Hit Capabilities() endpoint")
|
||||||
|
|
||||||
return &volume.CapabilitiesResponse{
|
return &volume.CapabilitiesResponse{
|
||||||
volume.Capability{
|
Capabilities: volume.Capability{
|
||||||
"local",
|
Scope: "local",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,7 +260,7 @@ func (d *DirDriver) Path(req *volume.PathRequest) (*volume.PathResponse, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &volume.PathResponse{
|
return &volume.PathResponse{
|
||||||
vol.path,
|
Mountpoint: vol.path,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ func (d *DirDriver) Mount(req *volume.MountRequest) (*volume.MountResponse, erro
|
|||||||
vol.mounts[req.ID] = true
|
vol.mounts[req.ID] = true
|
||||||
|
|
||||||
return &volume.MountResponse{
|
return &volume.MountResponse{
|
||||||
vol.path,
|
Mountpoint: vol.path,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,24 +90,24 @@ var _ = Describe("Common functions test", func() {
|
|||||||
Entry("Command exist", "Fakecmd", false),
|
Entry("Command exist", "Fakecmd", false),
|
||||||
)
|
)
|
||||||
|
|
||||||
It("Test WriteJsonFile", func() {
|
It("Test WriteJSONFile", func() {
|
||||||
type testJson struct {
|
type testJSON struct {
|
||||||
Item1 int
|
Item1 int
|
||||||
Item2 []string
|
Item2 []string
|
||||||
}
|
}
|
||||||
compareData := &testJson{}
|
compareData := &testJSON{}
|
||||||
|
|
||||||
testData := &testJson{
|
testData := &testJSON{
|
||||||
Item1: 5,
|
Item1: 5,
|
||||||
Item2: []string{"test"},
|
Item2: []string{"test"},
|
||||||
}
|
}
|
||||||
|
|
||||||
testByte, _ := json.Marshal(testData)
|
testByte, _ := json.Marshal(testData)
|
||||||
err := WriteJsonFile(testByte, "/tmp/testJson")
|
err := WriteJSONFile(testByte, "/tmp/testJSON")
|
||||||
|
|
||||||
Expect(err).To(BeNil(), "Failed to write JSON to file.")
|
Expect(err).To(BeNil(), "Failed to write JSON to file.")
|
||||||
|
|
||||||
read, err := os.Open("/tmp/testJson")
|
read, err := os.Open("/tmp/testJSON")
|
||||||
defer read.Close()
|
defer read.Close()
|
||||||
|
|
||||||
Expect(err).To(BeNil(), "Can not find the JSON file after we write it.")
|
Expect(err).To(BeNil(), "Can not find the JSON file after we write it.")
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/config"
|
"github.com/containers/common/pkg/config"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega" //nolint:golint,stylecheck
|
||||||
"github.com/onsi/gomega/format"
|
"github.com/onsi/gomega/format"
|
||||||
"github.com/onsi/gomega/gexec"
|
"github.com/onsi/gomega/gexec"
|
||||||
"github.com/onsi/gomega/matchers"
|
"github.com/onsi/gomega/matchers"
|
||||||
@ -95,7 +95,7 @@ func (matcher *URLMatcher) Match(actual interface{}) (bool, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("VerifyURL requires string inputs %T is not supported", matcher.Expected)
|
return false, fmt.Errorf("VerifyURL requires string inputs %T is not supported", matcher.Expected)
|
||||||
}
|
}
|
||||||
e_uri, err := url.Parse(e)
|
eURI, err := url.Parse(e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@ -104,12 +104,12 @@ func (matcher *URLMatcher) Match(actual interface{}) (bool, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("VerifyURL requires string inputs %T is not supported", actual)
|
return false, fmt.Errorf("VerifyURL requires string inputs %T is not supported", actual)
|
||||||
}
|
}
|
||||||
a_uri, err := url.Parse(a)
|
aURI, err := url.Parse(a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return (&matchers.EqualMatcher{Expected: e_uri}).Match(a_uri)
|
return (&matchers.EqualMatcher{Expected: eURI}).Match(aURI)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExitMatcher struct {
|
type ExitMatcher struct {
|
||||||
|
@ -13,9 +13,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/storage/pkg/parsers/kernel"
|
"github.com/containers/storage/pkg/parsers/kernel"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo" //nolint:golint,stylecheck
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega" //nolint:golint,stylecheck
|
||||||
. "github.com/onsi/gomega/gexec"
|
. "github.com/onsi/gomega/gexec" //nolint:golint,stylecheck
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -439,25 +439,21 @@ func IsKernelNewerThan(version string) (bool, error) {
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsCommandAvailable check if command exist
|
// IsCommandAvailable check if command exist
|
||||||
func IsCommandAvailable(command string) bool {
|
func IsCommandAvailable(command string) bool {
|
||||||
check := exec.Command("bash", "-c", strings.Join([]string{"command -v", command}, " "))
|
check := exec.Command("bash", "-c", strings.Join([]string{"command -v", command}, " "))
|
||||||
err := check.Run()
|
err := check.Run()
|
||||||
if err != nil {
|
return err == nil
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteJsonFile write json format data to a json file
|
// WriteJSONFile write json format data to a json file
|
||||||
func WriteJsonFile(data []byte, filePath string) error {
|
func WriteJSONFile(data []byte, filePath string) error {
|
||||||
var jsonData map[string]interface{}
|
var jsonData map[string]interface{}
|
||||||
json.Unmarshal(data, &jsonData)
|
json.Unmarshal(data, &jsonData)
|
||||||
formatJson, _ := json.MarshalIndent(jsonData, "", " ")
|
formatJSON, _ := json.MarshalIndent(jsonData, "", " ")
|
||||||
return ioutil.WriteFile(filePath, formatJson, 0644)
|
return ioutil.WriteFile(filePath, formatJSON, 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Containerized check the podman command run inside container
|
// Containerized check the podman command run inside container
|
||||||
@ -471,10 +467,7 @@ func Containerized() bool {
|
|||||||
// shrug, if we cannot read that file, return false
|
// shrug, if we cannot read that file, return false
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if strings.Index(string(b), "docker") > -1 {
|
return strings.Contains(string(b), "docker")
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -485,7 +478,6 @@ var randomLetters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
|
|||||||
|
|
||||||
// RandomString returns a string of given length composed of random characters
|
// RandomString returns a string of given length composed of random characters
|
||||||
func RandomString(n int) string {
|
func RandomString(n int) string {
|
||||||
|
|
||||||
b := make([]rune, n)
|
b := make([]rune, n)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
b[i] = randomLetters[rand.Intn(len(randomLetters))]
|
b[i] = randomLetters[rand.Intn(len(randomLetters))]
|
||||||
|
Reference in New Issue
Block a user