Report StatusConflict on Pod opt partial failures

- When one or more containers in the Pod reports an error on an operation
report StatusConflict and report the error(s)

- jsoniter type encoding used to marshal error as string using error.Error()

- Update test framework to allow setting any flag when creating pods

- Fix test_resize() result check

Fixes #8865

Signed-off-by: Jhon Honce <jhonce@redhat.com>
This commit is contained in:
Jhon Honce
2021-01-19 09:16:01 -07:00
parent d66a18cb11
commit 7e4d696d94
23 changed files with 352 additions and 199 deletions

View File

@ -84,5 +84,5 @@ func ResizeTTY(w http.ResponseWriter, r *http.Request) {
// reasons. // reasons.
status = http.StatusCreated status = http.StatusCreated
} }
utils.WriteResponse(w, status, "") w.WriteHeader(status)
} }

View File

@ -139,19 +139,20 @@ func PodStop(w http.ResponseWriter, r *http.Request) {
logrus.Errorf("Error cleaning up pod %s container %s: %v", pod.ID(), id, err) logrus.Errorf("Error cleaning up pod %s container %s: %v", pod.ID(), id, err)
} }
} }
var errs []error //nolint
report := entities.PodStopReport{Id: pod.ID()}
for id, err := range responses { for id, err := range responses {
errs = append(errs, errors.Wrapf(err, "error stopping container %s", id)) report.Errs = append(report.Errs, errors.Wrapf(err, "error stopping container %s", id))
} }
report := entities.PodStopReport{
Errs: errs, code := http.StatusOK
Id: pod.ID(), if len(report.Errs) > 0 {
code = http.StatusConflict
} }
utils.WriteResponse(w, http.StatusOK, report) utils.WriteResponse(w, code, report)
} }
func PodStart(w http.ResponseWriter, r *http.Request) { func PodStart(w http.ResponseWriter, r *http.Request) {
var errs []error //nolint
runtime := r.Context().Value("runtime").(*libpod.Runtime) runtime := r.Context().Value("runtime").(*libpod.Runtime)
name := utils.GetName(r) name := utils.GetName(r)
pod, err := runtime.LookupPod(name) pod, err := runtime.LookupPod(name)
@ -168,19 +169,23 @@ func PodStart(w http.ResponseWriter, r *http.Request) {
utils.WriteResponse(w, http.StatusNotModified, "") utils.WriteResponse(w, http.StatusNotModified, "")
return return
} }
responses, err := pod.Start(r.Context()) responses, err := pod.Start(r.Context())
if err != nil && errors.Cause(err) != define.ErrPodPartialFail { if err != nil && errors.Cause(err) != define.ErrPodPartialFail {
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err) utils.Error(w, "Something went wrong", http.StatusConflict, err)
return return
} }
report := entities.PodStartReport{Id: pod.ID()}
for id, err := range responses { for id, err := range responses {
errs = append(errs, errors.Wrapf(err, "error starting container %s", id)) report.Errs = append(report.Errs, errors.Wrapf(err, "error starting container "+id))
} }
report := entities.PodStartReport{
Errs: errs, code := http.StatusOK
Id: pod.ID(), if len(report.Errs) > 0 {
code = http.StatusConflict
} }
utils.WriteResponse(w, http.StatusOK, report) utils.WriteResponse(w, code, report)
} }
func PodDelete(w http.ResponseWriter, r *http.Request) { func PodDelete(w http.ResponseWriter, r *http.Request) {
@ -209,14 +214,11 @@ func PodDelete(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err) utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
return return
} }
report := entities.PodRmReport{ report := entities.PodRmReport{Id: pod.ID()}
Id: pod.ID(),
}
utils.WriteResponse(w, http.StatusOK, report) utils.WriteResponse(w, http.StatusOK, report)
} }
func PodRestart(w http.ResponseWriter, r *http.Request) { func PodRestart(w http.ResponseWriter, r *http.Request) {
var errs []error //nolint
runtime := r.Context().Value("runtime").(*libpod.Runtime) runtime := r.Context().Value("runtime").(*libpod.Runtime)
name := utils.GetName(r) name := utils.GetName(r)
pod, err := runtime.LookupPod(name) pod, err := runtime.LookupPod(name)
@ -229,14 +231,17 @@ func PodRestart(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err) utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
return return
} }
report := entities.PodRestartReport{Id: pod.ID()}
for id, err := range responses { for id, err := range responses {
errs = append(errs, errors.Wrapf(err, "error restarting container %s", id)) report.Errs = append(report.Errs, errors.Wrapf(err, "error restarting container %s", id))
} }
report := entities.PodRestartReport{
Errs: errs, code := http.StatusOK
Id: pod.ID(), if len(report.Errs) > 0 {
code = http.StatusConflict
} }
utils.WriteResponse(w, http.StatusOK, report) utils.WriteResponse(w, code, report)
} }
func PodPrune(w http.ResponseWriter, r *http.Request) { func PodPrune(w http.ResponseWriter, r *http.Request) {
@ -267,7 +272,6 @@ func PodPruneHelper(r *http.Request) ([]*entities.PodPruneReport, error) {
} }
func PodPause(w http.ResponseWriter, r *http.Request) { func PodPause(w http.ResponseWriter, r *http.Request) {
var errs []error //nolint
runtime := r.Context().Value("runtime").(*libpod.Runtime) runtime := r.Context().Value("runtime").(*libpod.Runtime)
name := utils.GetName(r) name := utils.GetName(r)
pod, err := runtime.LookupPod(name) pod, err := runtime.LookupPod(name)
@ -280,18 +284,20 @@ func PodPause(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err) utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
return return
} }
report := entities.PodPauseReport{Id: pod.ID()}
for id, v := range responses { for id, v := range responses {
errs = append(errs, errors.Wrapf(v, "error pausing container %s", id)) report.Errs = append(report.Errs, errors.Wrapf(v, "error pausing container %s", id))
} }
report := entities.PodPauseReport{
Errs: errs, code := http.StatusOK
Id: pod.ID(), if len(report.Errs) > 0 {
code = http.StatusConflict
} }
utils.WriteResponse(w, http.StatusOK, report) utils.WriteResponse(w, code, report)
} }
func PodUnpause(w http.ResponseWriter, r *http.Request) { func PodUnpause(w http.ResponseWriter, r *http.Request) {
var errs []error //nolint
runtime := r.Context().Value("runtime").(*libpod.Runtime) runtime := r.Context().Value("runtime").(*libpod.Runtime)
name := utils.GetName(r) name := utils.GetName(r)
pod, err := runtime.LookupPod(name) pod, err := runtime.LookupPod(name)
@ -304,14 +310,17 @@ func PodUnpause(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "failed to pause pod", http.StatusInternalServerError, err) utils.Error(w, "failed to pause pod", http.StatusInternalServerError, err)
return return
} }
report := entities.PodUnpauseReport{Id: pod.ID()}
for id, v := range responses { for id, v := range responses {
errs = append(errs, errors.Wrapf(v, "error unpausing container %s", id)) report.Errs = append(report.Errs, errors.Wrapf(v, "error unpausing container %s", id))
} }
report := entities.PodUnpauseReport{
Errs: errs, code := http.StatusOK
Id: pod.ID(), if len(report.Errs) > 0 {
code = http.StatusConflict
} }
utils.WriteResponse(w, http.StatusOK, &report) utils.WriteResponse(w, code, &report)
} }
func PodTop(w http.ResponseWriter, r *http.Request) { func PodTop(w http.ResponseWriter, r *http.Request) {
@ -361,7 +370,6 @@ func PodKill(w http.ResponseWriter, r *http.Request) {
runtime = r.Context().Value("runtime").(*libpod.Runtime) runtime = r.Context().Value("runtime").(*libpod.Runtime)
decoder = r.Context().Value("decoder").(*schema.Decoder) decoder = r.Context().Value("decoder").(*schema.Decoder)
signal = "SIGKILL" signal = "SIGKILL"
errs []error //nolint
) )
query := struct { query := struct {
Signal string `schema:"signal"` Signal string `schema:"signal"`
@ -413,16 +421,18 @@ func PodKill(w http.ResponseWriter, r *http.Request) {
return return
} }
report := &entities.PodKillReport{Id: pod.ID()}
for _, v := range responses { for _, v := range responses {
if v != nil { if v != nil {
errs = append(errs, v) report.Errs = append(report.Errs, v)
} }
} }
report := &entities.PodKillReport{
Errs: errs, code := http.StatusOK
Id: pod.ID(), if len(report.Errs) > 0 {
code = http.StatusConflict
} }
utils.WriteResponse(w, http.StatusOK, report) utils.WriteResponse(w, code, report)
} }
func PodExists(w http.ResponseWriter, r *http.Request) { func PodExists(w http.ResponseWriter, r *http.Request) {

View File

@ -1,16 +1,17 @@
package utils package utils
import ( import (
"encoding/json"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
"strings" "strings"
"unsafe"
"github.com/blang/semver" "github.com/blang/semver"
"github.com/gorilla/mux" "github.com/gorilla/mux"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -144,6 +145,50 @@ func WriteResponse(w http.ResponseWriter, code int, value interface{}) {
} }
} }
func init() {
jsoniter.RegisterTypeEncoderFunc("error", MarshalErrorJSON, MarshalErrorJSONIsEmpty)
jsoniter.RegisterTypeEncoderFunc("[]error", MarshalErrorSliceJSON, MarshalErrorSliceJSONIsEmpty)
}
var json = jsoniter.ConfigCompatibleWithStandardLibrary
// MarshalErrorJSON writes error to stream as string
func MarshalErrorJSON(ptr unsafe.Pointer, stream *jsoniter.Stream) {
p := *((*error)(ptr))
if p == nil {
stream.WriteNil()
} else {
stream.WriteString(p.Error())
}
}
// MarshalErrorSliceJSON writes []error to stream as []string JSON blob
func MarshalErrorSliceJSON(ptr unsafe.Pointer, stream *jsoniter.Stream) {
a := *((*[]error)(ptr))
switch {
case len(a) == 0:
stream.WriteNil()
default:
stream.WriteArrayStart()
for i, e := range a {
if i > 0 {
stream.WriteMore()
}
stream.WriteString(e.Error())
}
stream.WriteArrayEnd()
}
}
func MarshalErrorJSONIsEmpty(_ unsafe.Pointer) bool {
return false
}
func MarshalErrorSliceJSONIsEmpty(_ unsafe.Pointer) bool {
return false
}
// WriteJSON writes an interface value encoded as JSON to w
func WriteJSON(w http.ResponseWriter, code int, value interface{}) { func WriteJSON(w http.ResponseWriter, code int, value interface{}) {
// FIXME: we don't need to write the header in all/some circumstances. // FIXME: we don't need to write the header in all/some circumstances.
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")

View File

@ -43,6 +43,11 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error {
// $ref: "#/definitions/IdResponse" // $ref: "#/definitions/IdResponse"
// 400: // 400:
// $ref: "#/responses/BadParamError" // $ref: "#/responses/BadParamError"
// 409:
// description: status conflict
// schema:
// type: string
// description: message describing error
// 500: // 500:
// $ref: "#/responses/InternalError" // $ref: "#/responses/InternalError"
r.Handle(VersionedPath("/libpod/pods/create"), s.APIHandler(libpod.PodCreate)).Methods(http.MethodPost) r.Handle(VersionedPath("/libpod/pods/create"), s.APIHandler(libpod.PodCreate)).Methods(http.MethodPost)
@ -149,7 +154,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error {
// 404: // 404:
// $ref: "#/responses/NoSuchPod" // $ref: "#/responses/NoSuchPod"
// 409: // 409:
// $ref: "#/responses/ConflictError" // $ref: "#/responses/PodKillReport"
// 500: // 500:
// $ref: "#/responses/InternalError" // $ref: "#/responses/InternalError"
r.Handle(VersionedPath("/libpod/pods/{name}/kill"), s.APIHandler(libpod.PodKill)).Methods(http.MethodPost) r.Handle(VersionedPath("/libpod/pods/{name}/kill"), s.APIHandler(libpod.PodKill)).Methods(http.MethodPost)
@ -170,6 +175,8 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error {
// $ref: '#/responses/PodPauseReport' // $ref: '#/responses/PodPauseReport'
// 404: // 404:
// $ref: "#/responses/NoSuchPod" // $ref: "#/responses/NoSuchPod"
// 409:
// $ref: '#/responses/PodPauseReport'
// 500: // 500:
// $ref: "#/responses/InternalError" // $ref: "#/responses/InternalError"
r.Handle(VersionedPath("/libpod/pods/{name}/pause"), s.APIHandler(libpod.PodPause)).Methods(http.MethodPost) r.Handle(VersionedPath("/libpod/pods/{name}/pause"), s.APIHandler(libpod.PodPause)).Methods(http.MethodPost)
@ -189,6 +196,8 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error {
// $ref: '#/responses/PodRestartReport' // $ref: '#/responses/PodRestartReport'
// 404: // 404:
// $ref: "#/responses/NoSuchPod" // $ref: "#/responses/NoSuchPod"
// 409:
// $ref: "#/responses/PodRestartReport"
// 500: // 500:
// $ref: "#/responses/InternalError" // $ref: "#/responses/InternalError"
r.Handle(VersionedPath("/libpod/pods/{name}/restart"), s.APIHandler(libpod.PodRestart)).Methods(http.MethodPost) r.Handle(VersionedPath("/libpod/pods/{name}/restart"), s.APIHandler(libpod.PodRestart)).Methods(http.MethodPost)
@ -210,6 +219,8 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error {
// $ref: "#/responses/PodAlreadyStartedError" // $ref: "#/responses/PodAlreadyStartedError"
// 404: // 404:
// $ref: "#/responses/NoSuchPod" // $ref: "#/responses/NoSuchPod"
// 409:
// $ref: '#/responses/PodStartReport'
// 500: // 500:
// $ref: "#/responses/InternalError" // $ref: "#/responses/InternalError"
r.Handle(VersionedPath("/libpod/pods/{name}/start"), s.APIHandler(libpod.PodStart)).Methods(http.MethodPost) r.Handle(VersionedPath("/libpod/pods/{name}/start"), s.APIHandler(libpod.PodStart)).Methods(http.MethodPost)
@ -237,6 +248,8 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error {
// $ref: "#/responses/BadParamError" // $ref: "#/responses/BadParamError"
// 404: // 404:
// $ref: "#/responses/NoSuchPod" // $ref: "#/responses/NoSuchPod"
// 409:
// $ref: "#/responses/PodStopReport"
// 500: // 500:
// $ref: "#/responses/InternalError" // $ref: "#/responses/InternalError"
r.Handle(VersionedPath("/libpod/pods/{name}/stop"), s.APIHandler(libpod.PodStop)).Methods(http.MethodPost) r.Handle(VersionedPath("/libpod/pods/{name}/stop"), s.APIHandler(libpod.PodStop)).Methods(http.MethodPost)
@ -256,6 +269,8 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error {
// $ref: '#/responses/PodUnpauseReport' // $ref: '#/responses/PodUnpauseReport'
// 404: // 404:
// $ref: "#/responses/NoSuchPod" // $ref: "#/responses/NoSuchPod"
// 409:
// $ref: '#/responses/PodUnpauseReport'
// 500: // 500:
// $ref: "#/responses/InternalError" // $ref: "#/responses/InternalError"
r.Handle(VersionedPath("/libpod/pods/{name}/unpause"), s.APIHandler(libpod.PodUnpause)).Methods(http.MethodPost) r.Handle(VersionedPath("/libpod/pods/{name}/unpause"), s.APIHandler(libpod.PodUnpause)).Methods(http.MethodPost)

View File

@ -162,7 +162,7 @@ class TestApi(unittest.TestCase):
r = requests.post(_url(ctnr("/containers/{}/resize?h=43&w=80"))) r = requests.post(_url(ctnr("/containers/{}/resize?h=43&w=80")))
self.assertIn(r.status_code, (200, 409), r.text) self.assertIn(r.status_code, (200, 409), r.text)
if r.status_code == 200: if r.status_code == 200:
self.assertIsNone(r.text) self.assertEqual(r.text, "", r.text)
def test_attach_containers(self): def test_attach_containers(self):
self.skipTest("FIXME: Test timeouts") self.skipTest("FIXME: Test timeouts")
@ -359,14 +359,14 @@ class TestApi(unittest.TestCase):
# Had issues with this test hanging when repositories not happy # Had issues with this test hanging when repositories not happy
def do_search1(): def do_search1():
payload = {'term': 'alpine'} payload = {"term": "alpine"}
r = requests.get(url, params=payload, timeout=5) r = requests.get(url, params=payload, timeout=5)
self.assertEqual(r.status_code, 200, r.text) self.assertEqual(r.status_code, 200, r.text)
objs = json.loads(r.text) objs = json.loads(r.text)
self.assertIn(type(objs), (list,)) self.assertIn(type(objs), (list,))
def do_search2(): def do_search2():
payload = {'term': 'alpine', 'limit': 1} payload = {"term": "alpine", "limit": 1}
r = requests.get(url, params=payload, timeout=5) r = requests.get(url, params=payload, timeout=5)
self.assertEqual(r.status_code, 200, r.text) self.assertEqual(r.status_code, 200, r.text)
objs = json.loads(r.text) objs = json.loads(r.text)
@ -374,7 +374,7 @@ class TestApi(unittest.TestCase):
self.assertEqual(len(objs), 1) self.assertEqual(len(objs), 1)
def do_search3(): def do_search3():
payload = {'term': 'alpine', 'filters': '{"is-official":["true"]}'} payload = {"term": "alpine", "filters": '{"is-official":["true"]}'}
r = requests.get(url, params=payload, timeout=5) r = requests.get(url, params=payload, timeout=5)
self.assertEqual(r.status_code, 200, r.text) self.assertEqual(r.status_code, 200, r.text)
objs = json.loads(r.text) objs = json.loads(r.text)
@ -383,14 +383,14 @@ class TestApi(unittest.TestCase):
self.assertEqual(len(objs), 1) self.assertEqual(len(objs), 1)
def do_search4(): def do_search4():
headers = {'X-Registry-Auth': 'null'} headers = {"X-Registry-Auth": "null"}
payload = {'term': 'alpine'} payload = {"term": "alpine"}
r = requests.get(url, params=payload, headers=headers, timeout=5) r = requests.get(url, params=payload, headers=headers, timeout=5)
self.assertEqual(r.status_code, 200, r.text) self.assertEqual(r.status_code, 200, r.text)
def do_search5(): def do_search5():
headers = {'X-Registry-Auth': 'invalid value'} headers = {"X-Registry-Auth": "invalid value"}
payload = {'term': 'alpine'} payload = {"term": "alpine"}
r = requests.get(url, params=payload, headers=headers, timeout=5) r = requests.get(url, params=payload, headers=headers, timeout=5)
self.assertEqual(r.status_code, 400, r.text) self.assertEqual(r.status_code, 400, r.text)
@ -620,15 +620,19 @@ class TestApi(unittest.TestCase):
self.assertIsNotNone(prune_payload["ImagesDeleted"][1]["Deleted"]) self.assertIsNotNone(prune_payload["ImagesDeleted"][1]["Deleted"])
def test_status_compat(self): def test_status_compat(self):
r = requests.post(PODMAN_URL + "/v1.40/containers/create?name=topcontainer", r = requests.post(
json={"Cmd": ["top"], "Image": "alpine:latest"}) PODMAN_URL + "/v1.40/containers/create?name=topcontainer",
json={"Cmd": ["top"], "Image": "alpine:latest"},
)
self.assertEqual(r.status_code, 201, r.text) self.assertEqual(r.status_code, 201, r.text)
payload = json.loads(r.text) payload = json.loads(r.text)
container_id = payload["Id"] container_id = payload["Id"]
self.assertIsNotNone(container_id) self.assertIsNotNone(container_id)
r = requests.get(PODMAN_URL + "/v1.40/containers/json", r = requests.get(
params={'all': 'true', 'filters': f'{{"id":["{container_id}"]}}'}) PODMAN_URL + "/v1.40/containers/json",
params={"all": "true", "filters": f'{{"id":["{container_id}"]}}'},
)
self.assertEqual(r.status_code, 200, r.text) self.assertEqual(r.status_code, 200, r.text)
payload = json.loads(r.text) payload = json.loads(r.text)
self.assertEqual(payload[0]["Status"], "Created") self.assertEqual(payload[0]["Status"], "Created")
@ -636,8 +640,10 @@ class TestApi(unittest.TestCase):
r = requests.post(PODMAN_URL + f"/v1.40/containers/{container_id}/start") r = requests.post(PODMAN_URL + f"/v1.40/containers/{container_id}/start")
self.assertEqual(r.status_code, 204, r.text) self.assertEqual(r.status_code, 204, r.text)
r = requests.get(PODMAN_URL + "/v1.40/containers/json", r = requests.get(
params={'all': 'true', 'filters': f'{{"id":["{container_id}"]}}'}) PODMAN_URL + "/v1.40/containers/json",
params={"all": "true", "filters": f'{{"id":["{container_id}"]}}'},
)
self.assertEqual(r.status_code, 200, r.text) self.assertEqual(r.status_code, 200, r.text)
payload = json.loads(r.text) payload = json.loads(r.text)
self.assertTrue(str(payload[0]["Status"]).startswith("Up")) self.assertTrue(str(payload[0]["Status"]).startswith("Up"))
@ -645,8 +651,10 @@ class TestApi(unittest.TestCase):
r = requests.post(PODMAN_URL + f"/v1.40/containers/{container_id}/pause") r = requests.post(PODMAN_URL + f"/v1.40/containers/{container_id}/pause")
self.assertEqual(r.status_code, 204, r.text) self.assertEqual(r.status_code, 204, r.text)
r = requests.get(PODMAN_URL + "/v1.40/containers/json", r = requests.get(
params={'all': 'true', 'filters': f'{{"id":["{container_id}"]}}'}) PODMAN_URL + "/v1.40/containers/json",
params={"all": "true", "filters": f'{{"id":["{container_id}"]}}'},
)
self.assertEqual(r.status_code, 200, r.text) self.assertEqual(r.status_code, 200, r.text)
payload = json.loads(r.text) payload = json.loads(r.text)
self.assertTrue(str(payload[0]["Status"]).startswith("Up")) self.assertTrue(str(payload[0]["Status"]).startswith("Up"))
@ -657,8 +665,10 @@ class TestApi(unittest.TestCase):
r = requests.post(PODMAN_URL + f"/v1.40/containers/{container_id}/stop") r = requests.post(PODMAN_URL + f"/v1.40/containers/{container_id}/stop")
self.assertEqual(r.status_code, 204, r.text) self.assertEqual(r.status_code, 204, r.text)
r = requests.get(PODMAN_URL + "/v1.40/containers/json", r = requests.get(
params={'all': 'true', 'filters': f'{{"id":["{container_id}"]}}'}) PODMAN_URL + "/v1.40/containers/json",
params={"all": "true", "filters": f'{{"id":["{container_id}"]}}'},
)
self.assertEqual(r.status_code, 200, r.text) self.assertEqual(r.status_code, 200, r.text)
payload = json.loads(r.text) payload = json.loads(r.text)
self.assertTrue(str(payload[0]["Status"]).startswith("Exited")) self.assertTrue(str(payload[0]["Status"]).startswith("Exited"))
@ -666,6 +676,60 @@ class TestApi(unittest.TestCase):
r = requests.delete(PODMAN_URL + f"/v1.40/containers/{container_id}") r = requests.delete(PODMAN_URL + f"/v1.40/containers/{container_id}")
self.assertEqual(r.status_code, 204, r.text) self.assertEqual(r.status_code, 204, r.text)
def test_pod_start_conflict(self):
"""Verify issue #8865"""
pod_name = list()
pod_name.append("Pod_" + "".join(random.choice(string.ascii_letters) for i in range(10)))
pod_name.append("Pod_" + "".join(random.choice(string.ascii_letters) for i in range(10)))
r = requests.post(
_url("/pods/create"),
json={
"name": pod_name[0],
"no_infra": False,
"portmappings": [{"host_ip": "127.0.0.1", "host_port": 8889, "container_port": 89}],
},
)
self.assertEqual(r.status_code, 201, r.text)
r = requests.post(
_url("/containers/create"),
json={
"pod": pod_name[0],
"image": "docker.io/alpine:latest",
"command": ["top"],
},
)
self.assertEqual(r.status_code, 201, r.text)
r = requests.post(
_url("/pods/create"),
json={
"name": pod_name[1],
"no_infra": False,
"portmappings": [{"host_ip": "127.0.0.1", "host_port": 8889, "container_port": 89}],
},
)
self.assertEqual(r.status_code, 201, r.text)
r = requests.post(
_url("/containers/create"),
json={
"pod": pod_name[1],
"image": "docker.io/alpine:latest",
"command": ["top"],
},
)
self.assertEqual(r.status_code, 201, r.text)
r = requests.post(_url(f"/pods/{pod_name[0]}/start"))
self.assertEqual(r.status_code, 200, r.text)
r = requests.post(_url(f"/pods/{pod_name[1]}/start"))
self.assertEqual(r.status_code, 409, r.text)
start = json.loads(r.text)
self.assertGreater(len(start["Errs"]), 0, r.text)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

View File

@ -518,27 +518,15 @@ func (s *PodmanSessionIntegration) InspectPodArrToJSON() []define.InspectPodData
// CreatePod creates a pod with no infra container // CreatePod creates a pod with no infra container
// it optionally takes a pod name // it optionally takes a pod name
func (p *PodmanTestIntegration) CreatePod(name string) (*PodmanSessionIntegration, int, string) { func (p *PodmanTestIntegration) CreatePod(options map[string][]string) (*PodmanSessionIntegration, int, string) {
var podmanArgs = []string{"pod", "create", "--infra=false", "--share", ""} var args = []string{"pod", "create", "--infra=false", "--share", ""}
if name != "" { for k, values := range options {
podmanArgs = append(podmanArgs, "--name", name) for _, v := range values {
args = append(args, k+"="+v)
}
} }
session := p.Podman(podmanArgs)
session.WaitWithDefaultTimeout()
return session, session.ExitCode(), session.OutputToString()
}
// CreatePod creates a pod with no infra container and some labels. session := p.Podman(args)
// it optionally takes a pod name
func (p *PodmanTestIntegration) CreatePodWithLabels(name string, labels map[string]string) (*PodmanSessionIntegration, int, string) {
var podmanArgs = []string{"pod", "create", "--infra=false", "--share", ""}
if name != "" {
podmanArgs = append(podmanArgs, "--name", name)
}
for labelKey, labelValue := range labels {
podmanArgs = append(podmanArgs, "--label", fmt.Sprintf("%s=%s", labelKey, labelValue))
}
session := p.Podman(podmanArgs)
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
return session, session.ExitCode(), session.OutputToString() return session, session.ExitCode(), session.OutputToString()
} }

View File

@ -83,7 +83,7 @@ var _ = Describe("Podman image|container exists", func() {
}) })
It("podman pod exists in local storage by name", func() { It("podman pod exists in local storage by name", func() {
setup, _, _ := podmanTest.CreatePod("foobar") setup, _, _ := podmanTest.CreatePod(map[string][]string{"--name": {"foobar"}})
setup.WaitWithDefaultTimeout() setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0)) Expect(setup).Should(Exit(0))
@ -92,7 +92,7 @@ var _ = Describe("Podman image|container exists", func() {
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
}) })
It("podman pod exists in local storage by container ID", func() { It("podman pod exists in local storage by container ID", func() {
setup, _, podID := podmanTest.CreatePod("") setup, _, podID := podmanTest.CreatePod(nil)
setup.WaitWithDefaultTimeout() setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0)) Expect(setup).Should(Exit(0))
@ -101,7 +101,7 @@ var _ = Describe("Podman image|container exists", func() {
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
}) })
It("podman pod exists in local storage by short container ID", func() { It("podman pod exists in local storage by short container ID", func() {
setup, _, podID := podmanTest.CreatePod("") setup, _, podID := podmanTest.CreatePod(nil)
setup.WaitWithDefaultTimeout() setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0)) Expect(setup).Should(Exit(0))

View File

@ -131,7 +131,7 @@ var _ = Describe("Podman generate kube", func() {
}) })
It("podman generate kube on pod", func() { It("podman generate kube on pod", func() {
_, rc, _ := podmanTest.CreatePod("toppod") _, rc, _ := podmanTest.CreatePod(map[string][]string{"--name": {"toppod"}})
Expect(rc).To(Equal(0)) Expect(rc).To(Equal(0))
session := podmanTest.RunTopContainerInPod("topcontainer", "toppod") session := podmanTest.RunTopContainerInPod("topcontainer", "toppod")
@ -221,7 +221,7 @@ var _ = Describe("Podman generate kube", func() {
}) })
It("podman generate service kube on pod", func() { It("podman generate service kube on pod", func() {
_, rc, _ := podmanTest.CreatePod("toppod") _, rc, _ := podmanTest.CreatePod(map[string][]string{"--name": {"toppod"}})
Expect(rc).To(Equal(0)) Expect(rc).To(Equal(0))
session := podmanTest.RunTopContainerInPod("topcontainer", "toppod") session := podmanTest.RunTopContainerInPod("topcontainer", "toppod")
@ -373,7 +373,7 @@ var _ = Describe("Podman generate kube", func() {
It("podman generate and reimport kube on pod", func() { It("podman generate and reimport kube on pod", func() {
podName := "toppod" podName := "toppod"
_, rc, _ := podmanTest.CreatePod(podName) _, rc, _ := podmanTest.CreatePod(map[string][]string{"--name": {podName}})
Expect(rc).To(Equal(0)) Expect(rc).To(Equal(0))
session := podmanTest.Podman([]string{"create", "--pod", podName, "--name", "test1", ALPINE, "top"}) session := podmanTest.Podman([]string{"create", "--pod", podName, "--name", "test1", ALPINE, "top"})
@ -412,7 +412,7 @@ var _ = Describe("Podman generate kube", func() {
It("podman generate with user and reimport kube on pod", func() { It("podman generate with user and reimport kube on pod", func() {
podName := "toppod" podName := "toppod"
_, rc, _ := podmanTest.CreatePod(podName) _, rc, _ := podmanTest.CreatePod(map[string][]string{"--name": {podName}})
Expect(rc).To(Equal(0)) Expect(rc).To(Equal(0))
session := podmanTest.Podman([]string{"create", "--pod", podName, "--name", "test1", "--user", "100:200", ALPINE, "top"}) session := podmanTest.Podman([]string{"create", "--pod", podName, "--name", "test1", "--user", "100:200", ALPINE, "top"})

View File

@ -38,7 +38,7 @@ var _ = Describe("Podman pod create", func() {
}) })
It("podman create pod", func() { It("podman create pod", func() {
_, ec, podID := podmanTest.CreatePod("") _, ec, podID := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
check := podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc"}) check := podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc"})
@ -50,7 +50,7 @@ var _ = Describe("Podman pod create", func() {
It("podman create pod with name", func() { It("podman create pod with name", func() {
name := "test" name := "test"
_, ec, _ := podmanTest.CreatePod(name) _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {name}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
check := podmanTest.Podman([]string{"pod", "ps", "--no-trunc"}) check := podmanTest.Podman([]string{"pod", "ps", "--no-trunc"})
@ -61,10 +61,10 @@ var _ = Describe("Podman pod create", func() {
It("podman create pod with doubled name", func() { It("podman create pod with doubled name", func() {
name := "test" name := "test"
_, ec, _ := podmanTest.CreatePod(name) _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {name}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec2, _ := podmanTest.CreatePod(name) _, ec2, _ := podmanTest.CreatePod(map[string][]string{"--name": {name}})
Expect(ec2).To(Not(Equal(0))) Expect(ec2).To(Not(Equal(0)))
check := podmanTest.Podman([]string{"pod", "ps", "-q"}) check := podmanTest.Podman([]string{"pod", "ps", "-q"})
@ -78,7 +78,7 @@ var _ = Describe("Podman pod create", func() {
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec, _ := podmanTest.CreatePod(name) _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {name}})
Expect(ec).To(Not(Equal(0))) Expect(ec).To(Not(Equal(0)))
check := podmanTest.Podman([]string{"pod", "ps", "-q"}) check := podmanTest.Podman([]string{"pod", "ps", "-q"})

View File

@ -41,7 +41,7 @@ var _ = Describe("Podman pod inspect", func() {
}) })
It("podman inspect a pod", func() { It("podman inspect a pod", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)

View File

@ -40,7 +40,7 @@ var _ = Describe("Podman pod kill", func() {
}) })
It("podman pod kill a pod by id", func() { It("podman pod kill a pod by id", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -58,7 +58,7 @@ var _ = Describe("Podman pod kill", func() {
}) })
It("podman pod kill a pod by id with TERM", func() { It("podman pod kill a pod by id with TERM", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -72,7 +72,7 @@ var _ = Describe("Podman pod kill", func() {
}) })
It("podman pod kill a pod by name", func() { It("podman pod kill a pod by name", func() {
_, ec, podid := podmanTest.CreatePod("test1") _, ec, podid := podmanTest.CreatePod(map[string][]string{"--name": {"test1"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -86,7 +86,7 @@ var _ = Describe("Podman pod kill", func() {
}) })
It("podman pod kill a pod by id with a bogus signal", func() { It("podman pod kill a pod by id with a bogus signal", func() {
_, ec, podid := podmanTest.CreatePod("test1") _, ec, podid := podmanTest.CreatePod(map[string][]string{"--name": {"test1"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -100,14 +100,14 @@ var _ = Describe("Podman pod kill", func() {
}) })
It("podman pod kill latest pod", func() { It("podman pod kill latest pod", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec, podid2 := podmanTest.CreatePod("") _, ec, podid2 := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session = podmanTest.RunTopContainerInPod("", podid2) session = podmanTest.RunTopContainerInPod("", podid2)
@ -128,7 +128,7 @@ var _ = Describe("Podman pod kill", func() {
It("podman pod kill all", func() { It("podman pod kill all", func() {
SkipIfRootlessCgroupsV1("Not supported for rootless + CGroupsV1") SkipIfRootlessCgroupsV1("Not supported for rootless + CGroupsV1")
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -139,7 +139,7 @@ var _ = Describe("Podman pod kill", func() {
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec, podid2 := podmanTest.CreatePod("") _, ec, podid2 := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session = podmanTest.RunTopContainerInPod("", podid2) session = podmanTest.RunTopContainerInPod("", podid2)

View File

@ -48,7 +48,7 @@ var _ = Describe("Podman pod pause", func() {
}) })
It("podman pod pause a created pod by id", func() { It("podman pod pause a created pod by id", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"pod", "pause", podid}) result := podmanTest.Podman([]string{"pod", "pause", podid})
@ -57,7 +57,7 @@ var _ = Describe("Podman pod pause", func() {
}) })
It("podman pod pause a running pod by id", func() { It("podman pod pause a running pod by id", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -78,7 +78,7 @@ var _ = Describe("Podman pod pause", func() {
}) })
It("podman unpause a running pod by id", func() { It("podman unpause a running pod by id", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -93,7 +93,7 @@ var _ = Describe("Podman pod pause", func() {
}) })
It("podman pod pause a running pod by name", func() { It("podman pod pause a running pod by name", func() {
_, ec, _ := podmanTest.CreatePod("test1") _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {"test1"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", "test1") session := podmanTest.RunTopContainerInPod("", "test1")

View File

@ -33,7 +33,7 @@ var _ = Describe("Podman pod prune", func() {
}) })
It("podman pod prune empty pod", func() { It("podman pod prune empty pod", func() {
_, ec, _ := podmanTest.CreatePod("") _, ec, _ := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"pod", "prune", "--force"}) result := podmanTest.Podman([]string{"pod", "prune", "--force"})
@ -42,7 +42,7 @@ var _ = Describe("Podman pod prune", func() {
}) })
It("podman pod prune doesn't remove a pod with a running container", func() { It("podman pod prune doesn't remove a pod with a running container", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
ec2 := podmanTest.RunTopContainerInPod("", podid) ec2 := podmanTest.RunTopContainerInPod("", podid)
@ -59,7 +59,7 @@ var _ = Describe("Podman pod prune", func() {
}) })
It("podman pod prune removes a pod with a stopped container", func() { It("podman pod prune removes a pod with a stopped container", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec2, _ := podmanTest.RunLsContainerInPod("", podid) _, ec2, _ := podmanTest.RunLsContainerInPod("", podid)

View File

@ -43,7 +43,7 @@ var _ = Describe("Podman ps", func() {
}) })
It("podman pod ps default", func() { It("podman pod ps default", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -57,7 +57,7 @@ var _ = Describe("Podman ps", func() {
}) })
It("podman pod ps quiet flag", func() { It("podman pod ps quiet flag", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec, _ = podmanTest.RunLsContainerInPod("", podid) _, ec, _ = podmanTest.RunLsContainerInPod("", podid)
@ -71,7 +71,7 @@ var _ = Describe("Podman ps", func() {
}) })
It("podman pod ps no-trunc", func() { It("podman pod ps no-trunc", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec2, _ := podmanTest.RunLsContainerInPod("", podid) _, ec2, _ := podmanTest.RunLsContainerInPod("", podid)
@ -86,10 +86,10 @@ var _ = Describe("Podman ps", func() {
It("podman pod ps latest", func() { It("podman pod ps latest", func() {
SkipIfRemote("--latest flag n/a") SkipIfRemote("--latest flag n/a")
_, ec, podid1 := podmanTest.CreatePod("") _, ec, podid1 := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec2, podid2 := podmanTest.CreatePod("") _, ec2, podid2 := podmanTest.CreatePod(nil)
Expect(ec2).To(Equal(0)) Expect(ec2).To(Equal(0))
result := podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--latest"}) result := podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--latest"})
@ -100,7 +100,7 @@ var _ = Describe("Podman ps", func() {
}) })
It("podman pod ps id filter flag", func() { It("podman pod ps id filter flag", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"pod", "ps", "--filter", fmt.Sprintf("id=%s", podid)}) result := podmanTest.Podman([]string{"pod", "ps", "--filter", fmt.Sprintf("id=%s", podid)})
@ -109,9 +109,9 @@ var _ = Describe("Podman ps", func() {
}) })
It("podman pod ps filter name regexp", func() { It("podman pod ps filter name regexp", func() {
_, ec, podid := podmanTest.CreatePod("mypod") _, ec, podid := podmanTest.CreatePod(map[string][]string{"--name": {"mypod"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec2, _ := podmanTest.CreatePod("mypod1") _, ec2, _ := podmanTest.CreatePod(map[string][]string{"--name": {"mypod1"}})
Expect(ec2).To(Equal(0)) Expect(ec2).To(Equal(0))
result := podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", "name=mypod"}) result := podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", "name=mypod"})
@ -138,13 +138,13 @@ var _ = Describe("Podman ps", func() {
}) })
It("podman pod ps --sort by name", func() { It("podman pod ps --sort by name", func() {
_, ec, _ := podmanTest.CreatePod("") _, ec, _ := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec2, _ := podmanTest.CreatePod("") _, ec2, _ := podmanTest.CreatePod(nil)
Expect(ec2).To(Equal(0)) Expect(ec2).To(Equal(0))
_, ec3, _ := podmanTest.CreatePod("") _, ec3, _ := podmanTest.CreatePod(nil)
Expect(ec3).To(Equal(0)) Expect(ec3).To(Equal(0))
session := podmanTest.Podman([]string{"pod", "ps", "--sort=name", "--format", "{{.Name}}"}) session := podmanTest.Podman([]string{"pod", "ps", "--sort=name", "--format", "{{.Name}}"})
@ -159,7 +159,7 @@ var _ = Describe("Podman ps", func() {
It("podman pod ps --ctr-names", func() { It("podman pod ps --ctr-names", func() {
SkipIfRootlessCgroupsV1("Not supported for rootless + CGroupsV1") SkipIfRootlessCgroupsV1("Not supported for rootless + CGroupsV1")
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("test1", podid) session := podmanTest.RunTopContainerInPod("test1", podid)
@ -177,14 +177,14 @@ var _ = Describe("Podman ps", func() {
}) })
It("podman pod ps filter ctr attributes", func() { It("podman pod ps filter ctr attributes", func() {
_, ec, podid1 := podmanTest.CreatePod("") _, ec, podid1 := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("test1", podid1) session := podmanTest.RunTopContainerInPod("test1", podid1)
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec2, podid2 := podmanTest.CreatePod("") _, ec2, podid2 := podmanTest.CreatePod(nil)
Expect(ec2).To(Equal(0)) Expect(ec2).To(Equal(0))
_, ec3, cid := podmanTest.RunLsContainerInPod("test2", podid2) _, ec3, cid := podmanTest.RunLsContainerInPod("test2", podid2)
@ -214,7 +214,7 @@ var _ = Describe("Podman ps", func() {
Expect(session.OutputToString()).To(ContainSubstring(podid2)) Expect(session.OutputToString()).To(ContainSubstring(podid2))
Expect(session.OutputToString()).To(Not(ContainSubstring(podid1))) Expect(session.OutputToString()).To(Not(ContainSubstring(podid1)))
_, ec3, podid3 := podmanTest.CreatePod("") _, ec3, podid3 := podmanTest.CreatePod(nil)
Expect(ec3).To(Equal(0)) Expect(ec3).To(Equal(0))
session = podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", "ctr-number=1"}) session = podmanTest.Podman([]string{"pod", "ps", "-q", "--no-trunc", "--filter", "ctr-number=1"})
@ -259,23 +259,20 @@ var _ = Describe("Podman ps", func() {
}) })
It("podman pod ps filter labels", func() { It("podman pod ps filter labels", func() {
_, ec, podid1 := podmanTest.CreatePod("") s, _, podid1 := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(s).To(Exit(0))
_, ec, podid2 := podmanTest.CreatePodWithLabels("", map[string]string{ s, _, podid2 := podmanTest.CreatePod(map[string][]string{
"app": "myapp", "--label": {"app=myapp", "io.podman.test.key=irrelevant-value"},
"io.podman.test.key": "irrelevant-value",
}) })
Expect(ec).To(Equal(0)) Expect(s).To(Exit(0))
_, ec, podid3 := podmanTest.CreatePodWithLabels("", map[string]string{ s, _, podid3 := podmanTest.CreatePod(map[string][]string{"--label": {"app=test"}})
"app": "test", Expect(s).To(Exit(0))
})
Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"pod", "ps", "--no-trunc", "--filter", "label=app", "--filter", "label=app=myapp"}) session := podmanTest.Podman([]string{"pod", "ps", "--no-trunc", "--filter", "label=app", "--filter", "label=app=myapp"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session).To(Exit(0))
Expect(session.OutputToString()).To(Not(ContainSubstring(podid1))) Expect(session.OutputToString()).To(Not(ContainSubstring(podid1)))
Expect(session.OutputToString()).To(ContainSubstring(podid2)) Expect(session.OutputToString()).To(ContainSubstring(podid2))
Expect(session.OutputToString()).To(Not(ContainSubstring(podid3))) Expect(session.OutputToString()).To(Not(ContainSubstring(podid3)))
@ -359,13 +356,13 @@ var _ = Describe("Podman ps", func() {
}) })
It("podman pod ps format with labels", func() { It("podman pod ps format with labels", func() {
_, ec, _ := podmanTest.CreatePod("") _, ec, _ := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec1, _ := podmanTest.CreatePodWithLabels("", map[string]string{ _, ec1, _ := podmanTest.CreatePod(map[string][]string{"--label": {
"io.podman.test.label": "value1", "io.podman.test.label=value1",
"io.podman.test.key": "irrelevant-value", "io.podman.test.key=irrelevant-value",
}) }})
Expect(ec1).To(Equal(0)) Expect(ec1).To(Equal(0))
session := podmanTest.Podman([]string{"pod", "ps", "--format", "{{.Labels}}"}) session := podmanTest.Podman([]string{"pod", "ps", "--format", "{{.Labels}}"})

View File

@ -39,7 +39,7 @@ var _ = Describe("Podman pod restart", func() {
}) })
It("podman pod restart single empty pod", func() { It("podman pod restart single empty pod", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"pod", "restart", podid}) session := podmanTest.Podman([]string{"pod", "restart", podid})
@ -48,7 +48,7 @@ var _ = Describe("Podman pod restart", func() {
}) })
It("podman pod restart single pod by name", func() { It("podman pod restart single pod by name", func() {
_, ec, _ := podmanTest.CreatePod("foobar99") _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("test1", "foobar99") session := podmanTest.RunTopContainerInPod("test1", "foobar99")
@ -68,14 +68,14 @@ var _ = Describe("Podman pod restart", func() {
}) })
It("podman pod restart multiple pods", func() { It("podman pod restart multiple pods", func() {
_, ec, _ := podmanTest.CreatePod("foobar99") _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("test1", "foobar99") session := podmanTest.RunTopContainerInPod("test1", "foobar99")
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec, _ = podmanTest.CreatePod("foobar100") _, ec, _ = podmanTest.CreatePod(map[string][]string{"--name": {"foobar100"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session = podmanTest.RunTopContainerInPod("test2", "foobar100") session = podmanTest.RunTopContainerInPod("test2", "foobar100")
@ -106,14 +106,14 @@ var _ = Describe("Podman pod restart", func() {
}) })
It("podman pod restart all pods", func() { It("podman pod restart all pods", func() {
_, ec, _ := podmanTest.CreatePod("foobar99") _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("test1", "foobar99") session := podmanTest.RunTopContainerInPod("test1", "foobar99")
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec, _ = podmanTest.CreatePod("foobar100") _, ec, _ = podmanTest.CreatePod(map[string][]string{"--name": {"foobar100"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session = podmanTest.RunTopContainerInPod("test2", "foobar100") session = podmanTest.RunTopContainerInPod("test2", "foobar100")
@ -134,14 +134,14 @@ var _ = Describe("Podman pod restart", func() {
}) })
It("podman pod restart latest pod", func() { It("podman pod restart latest pod", func() {
_, ec, _ := podmanTest.CreatePod("foobar99") _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("test1", "foobar99") session := podmanTest.RunTopContainerInPod("test1", "foobar99")
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec, _ = podmanTest.CreatePod("foobar100") _, ec, _ = podmanTest.CreatePod(map[string][]string{"--name": {"foobar100"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session = podmanTest.RunTopContainerInPod("test2", "foobar100") session = podmanTest.RunTopContainerInPod("test2", "foobar100")
@ -166,7 +166,7 @@ var _ = Describe("Podman pod restart", func() {
}) })
It("podman pod restart multiple pods with bogus", func() { It("podman pod restart multiple pods with bogus", func() {
_, ec, podid1 := podmanTest.CreatePod("foobar99") _, ec, podid1 := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", "foobar99") session := podmanTest.RunTopContainerInPod("", "foobar99")

View File

@ -37,7 +37,7 @@ var _ = Describe("Podman pod rm", func() {
}) })
It("podman pod rm empty pod", func() { It("podman pod rm empty pod", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"pod", "rm", podid}) result := podmanTest.Podman([]string{"pod", "rm", podid})
@ -61,10 +61,10 @@ var _ = Describe("Podman pod rm", func() {
}) })
It("podman pod rm latest pod", func() { It("podman pod rm latest pod", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec2, podid2 := podmanTest.CreatePod("pod2") _, ec2, podid2 := podmanTest.CreatePod(map[string][]string{"--name": {"pod2"}})
Expect(ec2).To(Equal(0)) Expect(ec2).To(Equal(0))
latest := "--latest" latest := "--latest"
@ -83,7 +83,7 @@ var _ = Describe("Podman pod rm", func() {
}) })
It("podman pod rm removes a pod with a container", func() { It("podman pod rm removes a pod with a container", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec2, _ := podmanTest.RunLsContainerInPod("", podid) _, ec2, _ := podmanTest.RunLsContainerInPod("", podid)
@ -99,7 +99,7 @@ var _ = Describe("Podman pod rm", func() {
}) })
It("podman pod rm -f does remove a running container", func() { It("podman pod rm -f does remove a running container", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -117,10 +117,10 @@ var _ = Describe("Podman pod rm", func() {
It("podman pod rm -a doesn't remove a running container", func() { It("podman pod rm -a doesn't remove a running container", func() {
fmt.Printf("To start, there are %d pods\n", podmanTest.NumberOfPods()) fmt.Printf("To start, there are %d pods\n", podmanTest.NumberOfPods())
_, ec, podid1 := podmanTest.CreatePod("") _, ec, podid1 := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec, _ = podmanTest.CreatePod("") _, ec, _ = podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
fmt.Printf("Started %d pods\n", podmanTest.NumberOfPods()) fmt.Printf("Started %d pods\n", podmanTest.NumberOfPods())
@ -154,13 +154,13 @@ var _ = Describe("Podman pod rm", func() {
}) })
It("podman pod rm -fa removes everything", func() { It("podman pod rm -fa removes everything", func() {
_, ec, podid1 := podmanTest.CreatePod("") _, ec, podid1 := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec, podid2 := podmanTest.CreatePod("") _, ec, podid2 := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
_, ec, _ = podmanTest.CreatePod("") _, ec, _ = podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid1) session := podmanTest.RunTopContainerInPod("", podid1)
@ -199,7 +199,7 @@ var _ = Describe("Podman pod rm", func() {
}) })
It("podman rm bogus pod and a running pod", func() { It("podman rm bogus pod and a running pod", func() {
_, ec, podid1 := podmanTest.CreatePod("") _, ec, podid1 := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("test1", podid1) session := podmanTest.RunTopContainerInPod("test1", podid1)
@ -217,7 +217,7 @@ var _ = Describe("Podman pod rm", func() {
It("podman rm --ignore bogus pod and a running pod", func() { It("podman rm --ignore bogus pod and a running pod", func() {
_, ec, podid1 := podmanTest.CreatePod("") _, ec, podid1 := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("test1", podid1) session := podmanTest.RunTopContainerInPod("test1", podid1)

View File

@ -10,6 +10,7 @@ import (
. "github.com/containers/podman/v2/test/utils" . "github.com/containers/podman/v2/test/utils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
) )
var _ = Describe("Podman pod start", func() { var _ = Describe("Podman pod start", func() {
@ -43,7 +44,7 @@ var _ = Describe("Podman pod start", func() {
}) })
It("podman pod start single empty pod", func() { It("podman pod start single empty pod", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"pod", "start", podid}) session := podmanTest.Podman([]string{"pod", "start", podid})
@ -52,7 +53,7 @@ var _ = Describe("Podman pod start", func() {
}) })
It("podman pod start single pod by name", func() { It("podman pod start single pod by name", func() {
_, ec, _ := podmanTest.CreatePod("foobar99") _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"create", "--pod", "foobar99", ALPINE, "ls"}) session := podmanTest.Podman([]string{"create", "--pod", "foobar99", ALPINE, "ls"})
@ -65,14 +66,14 @@ var _ = Describe("Podman pod start", func() {
}) })
It("podman pod start multiple pods", func() { It("podman pod start multiple pods", func() {
_, ec, podid1 := podmanTest.CreatePod("foobar99") _, ec, podid1 := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"create", "--pod", "foobar99", ALPINE, "top"}) session := podmanTest.Podman([]string{"create", "--pod", "foobar99", ALPINE, "top"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec2, podid2 := podmanTest.CreatePod("foobar100") _, ec2, podid2 := podmanTest.CreatePod(map[string][]string{"--name": {"foobar100"}})
Expect(ec2).To(Equal(0)) Expect(ec2).To(Equal(0))
session = podmanTest.Podman([]string{"create", "--pod", "foobar100", ALPINE, "top"}) session = podmanTest.Podman([]string{"create", "--pod", "foobar100", ALPINE, "top"})
@ -85,15 +86,45 @@ var _ = Describe("Podman pod start", func() {
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2)) Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2))
}) })
It("multiple pods in conflict", func() {
podName := []string{"Pod_" + RandomString(10), "Pod_" + RandomString(10)}
pod, _, podid1 := podmanTest.CreatePod(map[string][]string{
"--infra": {"true"},
"--name": {podName[0]},
"--publish": {"127.0.0.1:8080:80"},
})
Expect(pod).To(Exit(0))
session := podmanTest.Podman([]string{"create", "--pod", podName[0], ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).To(Exit(0))
pod, _, podid2 := podmanTest.CreatePod(map[string][]string{
"--infra": {"true"},
"--name": {podName[1]},
"--publish": {"127.0.0.1:8080:80"},
})
Expect(pod).To(Exit(0))
session = podmanTest.Podman([]string{"create", "--pod", podName[1], ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session).To(Exit(0))
session = podmanTest.Podman([]string{"pod", "start", podid1, podid2})
session.WaitWithDefaultTimeout()
Expect(session).To(Exit(125))
})
It("podman pod start all pods", func() { It("podman pod start all pods", func() {
_, ec, _ := podmanTest.CreatePod("foobar99") _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"create", "--pod", "foobar99", ALPINE, "top"}) session := podmanTest.Podman([]string{"create", "--pod", "foobar99", ALPINE, "top"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec, _ = podmanTest.CreatePod("foobar100") _, ec, _ = podmanTest.CreatePod(map[string][]string{"--name": {"foobar100"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session = podmanTest.Podman([]string{"create", "--pod", "foobar100", ALPINE, "top"}) session = podmanTest.Podman([]string{"create", "--pod", "foobar100", ALPINE, "top"})
@ -107,14 +138,14 @@ var _ = Describe("Podman pod start", func() {
}) })
It("podman pod start latest pod", func() { It("podman pod start latest pod", func() {
_, ec, _ := podmanTest.CreatePod("foobar99") _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"create", "--pod", "foobar99", ALPINE, "top"}) session := podmanTest.Podman([]string{"create", "--pod", "foobar99", ALPINE, "top"})
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec, _ = podmanTest.CreatePod("foobar100") _, ec, _ = podmanTest.CreatePod(map[string][]string{"--name": {"foobar100"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session = podmanTest.Podman([]string{"create", "--pod", "foobar100", ALPINE, "top"}) session = podmanTest.Podman([]string{"create", "--pod", "foobar100", ALPINE, "top"})
@ -132,7 +163,7 @@ var _ = Describe("Podman pod start", func() {
}) })
It("podman pod start multiple pods with bogus", func() { It("podman pod start multiple pods with bogus", func() {
_, ec, podid := podmanTest.CreatePod("foobar99") _, ec, podid := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"create", "--pod", "foobar99", ALPINE, "top"}) session := podmanTest.Podman([]string{"create", "--pod", "foobar99", ALPINE, "top"})

View File

@ -50,7 +50,7 @@ var _ = Describe("Podman pod stats", func() {
}) })
It("podman stats on a specific running pod", func() { It("podman stats on a specific running pod", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -67,7 +67,7 @@ var _ = Describe("Podman pod stats", func() {
}) })
It("podman stats on a specific running pod with shortID", func() { It("podman stats on a specific running pod with shortID", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -84,7 +84,7 @@ var _ = Describe("Podman pod stats", func() {
}) })
It("podman stats on a specific running pod with name", func() { It("podman stats on a specific running pod with name", func() {
_, ec, podid := podmanTest.CreatePod("test") _, ec, podid := podmanTest.CreatePod(map[string][]string{"--name": {"test"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -101,7 +101,7 @@ var _ = Describe("Podman pod stats", func() {
}) })
It("podman stats on running pods", func() { It("podman stats on running pods", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -118,7 +118,7 @@ var _ = Describe("Podman pod stats", func() {
}) })
It("podman stats on all pods", func() { It("podman stats on all pods", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -135,7 +135,7 @@ var _ = Describe("Podman pod stats", func() {
}) })
It("podman stats with json output", func() { It("podman stats with json output", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -152,7 +152,7 @@ var _ = Describe("Podman pod stats", func() {
Expect(stats.IsJSONOutputValid()).To(BeTrue()) Expect(stats.IsJSONOutputValid()).To(BeTrue())
}) })
It("podman stats with GO template", func() { It("podman stats with GO template", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -164,7 +164,7 @@ var _ = Describe("Podman pod stats", func() {
}) })
It("podman stats with invalid GO template", func() { It("podman stats with invalid GO template", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)

View File

@ -47,7 +47,7 @@ var _ = Describe("Podman pod stop", func() {
}) })
It("podman stop bogus pod and a running pod", func() { It("podman stop bogus pod and a running pod", func() {
_, ec, podid1 := podmanTest.CreatePod("") _, ec, podid1 := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("test1", podid1) session := podmanTest.RunTopContainerInPod("test1", podid1)
@ -61,7 +61,7 @@ var _ = Describe("Podman pod stop", func() {
It("podman stop --ignore bogus pod and a running pod", func() { It("podman stop --ignore bogus pod and a running pod", func() {
_, ec, podid1 := podmanTest.CreatePod("") _, ec, podid1 := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("test1", podid1) session := podmanTest.RunTopContainerInPod("test1", podid1)
@ -78,7 +78,7 @@ var _ = Describe("Podman pod stop", func() {
}) })
It("podman pod stop single empty pod", func() { It("podman pod stop single empty pod", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"pod", "stop", podid}) session := podmanTest.Podman([]string{"pod", "stop", podid})
@ -87,7 +87,7 @@ var _ = Describe("Podman pod stop", func() {
}) })
It("podman pod stop single pod by name", func() { It("podman pod stop single pod by name", func() {
_, ec, _ := podmanTest.CreatePod("foobar99") _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", "foobar99") session := podmanTest.RunTopContainerInPod("", "foobar99")
@ -101,14 +101,14 @@ var _ = Describe("Podman pod stop", func() {
}) })
It("podman pod stop multiple pods", func() { It("podman pod stop multiple pods", func() {
_, ec, podid1 := podmanTest.CreatePod("foobar99") _, ec, podid1 := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", "foobar99") session := podmanTest.RunTopContainerInPod("", "foobar99")
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec2, podid2 := podmanTest.CreatePod("foobar100") _, ec2, podid2 := podmanTest.CreatePod(map[string][]string{"--name": {"foobar100"}})
Expect(ec2).To(Equal(0)) Expect(ec2).To(Equal(0))
session = podmanTest.RunTopContainerInPod("", "foobar100") session = podmanTest.RunTopContainerInPod("", "foobar100")
@ -122,14 +122,14 @@ var _ = Describe("Podman pod stop", func() {
}) })
It("podman pod stop all pods", func() { It("podman pod stop all pods", func() {
_, ec, _ := podmanTest.CreatePod("foobar99") _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", "foobar99") session := podmanTest.RunTopContainerInPod("", "foobar99")
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec, _ = podmanTest.CreatePod("foobar100") _, ec, _ = podmanTest.CreatePod(map[string][]string{"--name": {"foobar100"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session = podmanTest.RunTopContainerInPod("", "foobar100") session = podmanTest.RunTopContainerInPod("", "foobar100")
@ -143,14 +143,14 @@ var _ = Describe("Podman pod stop", func() {
}) })
It("podman pod stop latest pod", func() { It("podman pod stop latest pod", func() {
_, ec, _ := podmanTest.CreatePod("foobar99") _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", "foobar99") session := podmanTest.RunTopContainerInPod("", "foobar99")
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
_, ec, _ = podmanTest.CreatePod("foobar100") _, ec, _ = podmanTest.CreatePod(map[string][]string{"--name": {"foobar100"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session = podmanTest.RunTopContainerInPod("", "foobar100") session = podmanTest.RunTopContainerInPod("", "foobar100")
@ -168,7 +168,7 @@ var _ = Describe("Podman pod stop", func() {
}) })
It("podman pod stop multiple pods with bogus", func() { It("podman pod stop multiple pods with bogus", func() {
_, ec, podid1 := podmanTest.CreatePod("foobar99") _, ec, podid1 := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", "foobar99") session := podmanTest.RunTopContainerInPod("", "foobar99")

View File

@ -47,7 +47,7 @@ var _ = Describe("Podman top", func() {
}) })
It("podman pod top on non-running pod", func() { It("podman pod top on non-running pod", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
result := podmanTest.Podman([]string{"top", podid}) result := podmanTest.Podman([]string{"top", podid})
@ -56,7 +56,7 @@ var _ = Describe("Podman top", func() {
}) })
It("podman pod top on pod", func() { It("podman pod top on pod", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"run", "-d", "--pod", podid, ALPINE, "top", "-d", "2"}) session := podmanTest.Podman([]string{"run", "-d", "--pod", podid, ALPINE, "top", "-d", "2"})
@ -73,7 +73,7 @@ var _ = Describe("Podman top", func() {
}) })
It("podman pod top with options", func() { It("podman pod top with options", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"run", "-d", "--pod", podid, ALPINE, "top", "-d", "2"}) session := podmanTest.Podman([]string{"run", "-d", "--pod", podid, ALPINE, "top", "-d", "2"})
@ -87,7 +87,7 @@ var _ = Describe("Podman top", func() {
}) })
It("podman pod top on pod invalid options", func() { It("podman pod top on pod invalid options", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"run", "-d", "--pod", podid, ALPINE, "top", "-d", "2"}) session := podmanTest.Podman([]string{"run", "-d", "--pod", podid, ALPINE, "top", "-d", "2"})
@ -104,7 +104,7 @@ var _ = Describe("Podman top", func() {
}) })
It("podman pod top on pod with containers in same pid namespace", func() { It("podman pod top on pod with containers in same pid namespace", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"run", "-d", "--pod", podid, ALPINE, "top", "-d", "2"}) session := podmanTest.Podman([]string{"run", "-d", "--pod", podid, ALPINE, "top", "-d", "2"})
@ -123,7 +123,7 @@ var _ = Describe("Podman top", func() {
}) })
It("podman pod top on pod with containers in different namespace", func() { It("podman pod top on pod with containers in different namespace", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.Podman([]string{"run", "-d", "--pod", podid, ALPINE, "top", "-d", "2"}) session := podmanTest.Podman([]string{"run", "-d", "--pod", podid, ALPINE, "top", "-d", "2"})

View File

@ -389,7 +389,7 @@ var _ = Describe("Podman ps", func() {
}) })
It("podman --pod", func() { It("podman --pod", func() {
_, ec, podid := podmanTest.CreatePod("") _, ec, podid := podmanTest.CreatePod(nil)
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podid) session := podmanTest.RunTopContainerInPod("", podid)
@ -409,7 +409,7 @@ var _ = Describe("Podman ps", func() {
It("podman --pod with a non-empty pod name", func() { It("podman --pod with a non-empty pod name", func() {
podName := "testPodName" podName := "testPodName"
_, ec, podid := podmanTest.CreatePod(podName) _, ec, podid := podmanTest.CreatePod(map[string][]string{"--name": {podName}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("", podName) session := podmanTest.RunTopContainerInPod("", podName)

View File

@ -197,10 +197,10 @@ var _ = Describe("Podman restart", func() {
Expect(restartTime.OutputToStringArray()[1]).To(Not(Equal(startTime.OutputToStringArray()[1]))) Expect(restartTime.OutputToStringArray()[1]).To(Not(Equal(startTime.OutputToStringArray()[1])))
}) })
It("Podman restart a container in a pod and hosts shouln't duplicated", func() { It("Podman restart a container in a pod and hosts should not duplicated", func() {
// Fixes: https://github.com/containers/podman/issues/8921 // Fixes: https://github.com/containers/podman/issues/8921
_, ec, _ := podmanTest.CreatePod("foobar99") _, ec, _ := podmanTest.CreatePod(map[string][]string{"--name": {"foobar99"}})
Expect(ec).To(Equal(0)) Expect(ec).To(Equal(0))
session := podmanTest.RunTopContainerInPod("host-restart-test", "foobar99") session := podmanTest.RunTopContainerInPod("host-restart-test", "foobar99")

View File

@ -467,11 +467,14 @@ func Containerized() bool {
return false return false
} }
func init() {
rand.Seed(GinkgoRandomSeed())
}
var randomLetters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") 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 {
rand.Seed(GinkgoRandomSeed())
b := make([]rune, n) b := make([]rune, n)
for i := range b { for i := range b {