From a4c607cc71ea5c3a4d4898a84b19cdd236ae90bd Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Thu, 7 May 2020 09:19:00 -0500 Subject: set binding tests to required some small fix ups for binding tests and then make them required. update containers-common V2 bindings tests were failing because of changes introduced in commit a2ad5bb. Fix some typos. Signed-off-by: Lokesh Mandvekar in the case where the specgen attribute for Env and Labels are nil, we should should then make the map IF we have labels and envs that need to be added. Signed-off-by: Brent Baude --- .cirrus.yml | 1 - cmd/podman/manifest/annotate.go | 2 +- contrib/cirrus/setup_environment.sh | 2 +- pkg/bindings/manifests/manifests.go | 39 ++++++++++++++-------------- pkg/bindings/test/containers_test.go | 4 +-- pkg/bindings/test/manifests_test.go | 40 +++++++++++++++-------------- pkg/bindings/test/pods_test.go | 10 ++++++++ pkg/bindings/test/system_test.go | 5 ++-- pkg/domain/infra/tunnel/manifest.go | 50 +++++++++++++++++++----------------- pkg/specgen/generate/container.go | 13 +++++++--- 10 files changed, 92 insertions(+), 74 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 2aae343e8..7400ae0a8 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -644,7 +644,6 @@ special_testing_cross_task: special_testing_bindings_task: - skip: $CI == 'true' depends_on: - "gating" - "varlink_api" diff --git a/cmd/podman/manifest/annotate.go b/cmd/podman/manifest/annotate.go index 21d4fb747..82ee1ffda 100644 --- a/cmd/podman/manifest/annotate.go +++ b/cmd/podman/manifest/annotate.go @@ -24,7 +24,7 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, + Mode: []entities.EngineMode{entities.ABIMode}, Command: annotateCmd, Parent: manifestCmd, }) diff --git a/contrib/cirrus/setup_environment.sh b/contrib/cirrus/setup_environment.sh index 6bec9625e..756240444 100755 --- a/contrib/cirrus/setup_environment.sh +++ b/contrib/cirrus/setup_environment.sh @@ -87,7 +87,7 @@ case "$CG_FS_TYPE" in # Normally not something to do for stable testing # but crun is new, and late-breaking fixes may be required # on short notice - dnf update -y crun + dnf update -y crun containers-common fi ;; *) diff --git a/pkg/bindings/manifests/manifests.go b/pkg/bindings/manifests/manifests.go index b85169410..3e0ef0325 100644 --- a/pkg/bindings/manifests/manifests.go +++ b/pkg/bindings/manifests/manifests.go @@ -125,23 +125,24 @@ func Push(ctx context.Context, name string, destination *string, all *bool) (str return idr.ID, response.Process(&idr) } +// There is NO annotate endpoint. this binding could never work // Annotate updates the image configuration of a given manifest list -func Annotate(ctx context.Context, name, digest string, options image.ManifestAnnotateOpts) (string, error) { - var idr handlers.IDResponse - conn, err := bindings.GetClient(ctx) - if err != nil { - return "", err - } - params := url.Values{} - params.Set("digest", digest) - optionsString, err := jsoniter.MarshalToString(options) - if err != nil { - return "", err - } - stringReader := strings.NewReader(optionsString) - response, err := conn.DoRequest(stringReader, http.MethodPost, "/manifests/%s/annotate", params, name) - if err != nil { - return "", err - } - return idr.ID, response.Process(&idr) -} +//func Annotate(ctx context.Context, name, digest string, options image.ManifestAnnotateOpts) (string, error) { +// var idr handlers.IDResponse +// conn, err := bindings.GetClient(ctx) +// if err != nil { +// return "", err +// } +// params := url.Values{} +// params.Set("digest", digest) +// optionsString, err := jsoniter.MarshalToString(options) +// if err != nil { +// return "", err +// } +// stringReader := strings.NewReader(optionsString) +// response, err := conn.DoRequest(stringReader, http.MethodPost, "/manifests/%s/annotate", params, name) +// if err != nil { +// return "", err +// } +// return idr.ID, response.Process(&idr) +//} diff --git a/pkg/bindings/test/containers_test.go b/pkg/bindings/test/containers_test.go index c79d89b73..f40d8ce46 100644 --- a/pkg/bindings/test/containers_test.go +++ b/pkg/bindings/test/containers_test.go @@ -531,7 +531,7 @@ var _ = Describe("Podman containers ", func() { Expect(err).ToNot(BeNil()) }) - It("podman prune stoped containers", func() { + It("podman prune stopped containers", func() { // Start and stop a container to enter in exited state. var name = "top" _, err := bt.RunTopContainer(&name, &bindings.PFalse, nil) @@ -546,7 +546,7 @@ var _ = Describe("Podman containers ", func() { Expect(len(pruneResponse.ID)).To(Equal(1)) }) - It("podman prune stoped containers with filters", func() { + It("podman prune stopped containers with filters", func() { // Start and stop a container to enter in exited state. var name = "top" _, err := bt.RunTopContainer(&name, &bindings.PFalse, nil) diff --git a/pkg/bindings/test/manifests_test.go b/pkg/bindings/test/manifests_test.go index ddb75865c..71d626b7b 100644 --- a/pkg/bindings/test/manifests_test.go +++ b/pkg/bindings/test/manifests_test.go @@ -118,25 +118,27 @@ var _ = Describe("Podman containers ", func() { Expect(len(data.Manifests)).To(BeZero()) }) - It("annotate manifest", func() { - id, err := manifests.Create(bt.conn, []string{"quay.io/libpod/foobar:latest"}, []string{}, nil) - Expect(err).To(BeNil()) - opts := image.ManifestAddOpts{Images: []string{"docker.io/library/alpine:latest"}} - - _, err = manifests.Add(bt.conn, id, opts) - Expect(err).To(BeNil()) - data, err := manifests.Inspect(bt.conn, id) - Expect(err).To(BeNil()) - Expect(len(data.Manifests)).To(BeNumerically("==", 1)) - digest := data.Manifests[0].Digest.String() - annoOpts := image.ManifestAnnotateOpts{OS: "foo"} - _, err = manifests.Annotate(bt.conn, id, digest, annoOpts) - Expect(err).To(BeNil()) - list, err := manifests.Inspect(bt.conn, id) - Expect(err).To(BeNil()) - Expect(len(list.Manifests)).To(BeNumerically("==", 1)) - Expect(list.Manifests[0].Platform.OS).To(Equal("foo")) - }) + // There is NO annotate endpoint, this could never work.:w + + //It("annotate manifest", func() { + // id, err := manifests.Create(bt.conn, []string{"quay.io/libpod/foobar:latest"}, []string{}, nil) + // Expect(err).To(BeNil()) + // opts := image.ManifestAddOpts{Images: []string{"docker.io/library/alpine:latest"}} + // + // _, err = manifests.Add(bt.conn, id, opts) + // Expect(err).To(BeNil()) + // data, err := manifests.Inspect(bt.conn, id) + // Expect(err).To(BeNil()) + // Expect(len(data.Manifests)).To(BeNumerically("==", 1)) + // digest := data.Manifests[0].Digest.String() + // annoOpts := image.ManifestAnnotateOpts{OS: "foo"} + // _, err = manifests.Annotate(bt.conn, id, digest, annoOpts) + // Expect(err).To(BeNil()) + // list, err := manifests.Inspect(bt.conn, id) + // Expect(err).To(BeNil()) + // Expect(len(list.Manifests)).To(BeNumerically("==", 1)) + // Expect(list.Manifests[0].Platform.OS).To(Equal("foo")) + //}) It("push manifest", func() { Skip("TODO") diff --git a/pkg/bindings/test/pods_test.go b/pkg/bindings/test/pods_test.go index 8a0b9c7a6..49bbfa246 100644 --- a/pkg/bindings/test/pods_test.go +++ b/pkg/bindings/test/pods_test.go @@ -57,6 +57,11 @@ var _ = Describe("Podman pods", func() { podSummary, err := pods.List(bt.conn, nil) Expect(err).To(BeNil()) Expect(len(podSummary)).To(Equal(1)) + + // Start the pod + _, err = pods.Start(bt.conn, newpod) + Expect(err).To(BeNil()) + // Adding an alpine container to the existing pod _, err = bt.RunTopContainer(nil, &bindings.PTrue, &newpod) Expect(err).To(BeNil()) @@ -83,6 +88,11 @@ var _ = Describe("Podman pods", func() { It("List pods with filters", func() { newpod2 := "newpod2" bt.Podcreate(&newpod2) + + // Start the pod + _, err = pods.Start(bt.conn, newpod) + Expect(err).To(BeNil()) + _, err = bt.RunTopContainer(nil, &bindings.PTrue, &newpod) Expect(err).To(BeNil()) diff --git a/pkg/bindings/test/system_test.go b/pkg/bindings/test/system_test.go index 87e6d56dc..62ea32377 100644 --- a/pkg/bindings/test/system_test.go +++ b/pkg/bindings/test/system_test.go @@ -3,7 +3,6 @@ package test_bindings import ( "time" - "github.com/containers/libpod/pkg/api/handlers" "github.com/containers/libpod/pkg/bindings" "github.com/containers/libpod/pkg/bindings/containers" "github.com/containers/libpod/pkg/bindings/pods" @@ -39,8 +38,8 @@ var _ = Describe("Podman system", func() { }) It("podman events", func() { - eChan := make(chan handlers.Event, 1) - var messages []handlers.Event + eChan := make(chan entities.Event, 1) + var messages []entities.Event cancelChan := make(chan bool, 1) go func() { for e := range eChan { diff --git a/pkg/domain/infra/tunnel/manifest.go b/pkg/domain/infra/tunnel/manifest.go index 7d9a0fce1..9c1f5349a 100644 --- a/pkg/domain/infra/tunnel/manifest.go +++ b/pkg/domain/infra/tunnel/manifest.go @@ -64,32 +64,34 @@ func (ir *ImageEngine) ManifestAdd(ctx context.Context, opts entities.ManifestAd return listID, nil } +// FIXME There is no endpoint for annotate and therefor this code is currently invalid // ManifestAnnotate updates an entry of the manifest list func (ir *ImageEngine) ManifestAnnotate(ctx context.Context, names []string, opts entities.ManifestAnnotateOptions) (string, error) { - manifestAnnotateOpts := image.ManifestAnnotateOpts{ - Arch: opts.Arch, - Features: opts.Features, - OS: opts.OS, - OSFeatures: opts.OSFeatures, - OSVersion: opts.OSVersion, - Variant: opts.Variant, - } - if len(opts.Annotation) > 0 { - annotations := make(map[string]string) - for _, annotationSpec := range opts.Annotation { - spec := strings.SplitN(annotationSpec, "=", 2) - if len(spec) != 2 { - return "", errors.Errorf("no value given for annotation %q", spec[0]) - } - annotations[spec[0]] = spec[1] - } - manifestAnnotateOpts.Annotation = annotations - } - updatedListID, err := manifests.Annotate(ctx, names[0], names[1], manifestAnnotateOpts) - if err != nil { - return updatedListID, errors.Wrapf(err, "error annotating %s of manifest list %s", names[1], names[0]) - } - return fmt.Sprintf("%s :%s", updatedListID, names[1]), nil + return "", errors.New("not implemented") + // manifestAnnotateOpts := image.ManifestAnnotateOpts{ + // Arch: opts.Arch, + // Features: opts.Features, + // OS: opts.OS, + // OSFeatures: opts.OSFeatures, + // OSVersion: opts.OSVersion, + // Variant: opts.Variant, + // } + // if len(opts.Annotation) > 0 { + // annotations := make(map[string]string) + // for _, annotationSpec := range opts.Annotation { + // spec := strings.SplitN(annotationSpec, "=", 2) + // if len(spec) != 2 { + // return "", errors.Errorf("no value given for annotation %q", spec[0]) + // } + // annotations[spec[0]] = spec[1] + // } + // manifestAnnotateOpts.Annotation = annotations + // } + // updatedListID, err := manifests.Annotate(ctx, names[0], names[1], manifestAnnotateOpts) + // if err != nil { + // return updatedListID, errors.Wrapf(err, "error annotating %s of manifest list %s", names[1], names[0]) + // } + // return fmt.Sprintf("%s :%s", updatedListID, names[1]), nil } // ManifestRemove removes the digest from manifest list diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go index e4bd2991a..a217125f4 100644 --- a/pkg/specgen/generate/container.go +++ b/pkg/specgen/generate/container.go @@ -42,11 +42,13 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat if err != nil { return err } - sig, err := signal.ParseSignalNameOrNumber(stopSignal) - if err != nil { - return err + if stopSignal != "" { + sig, err := signal.ParseSignalNameOrNumber(stopSignal) + if err != nil { + return err + } + s.StopSignal = &sig } - s.StopSignal = &sig } rtc, err := r.GetConfig() @@ -78,6 +80,9 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat } // labels from the image that dont exist already + if len(labels) > 0 && s.Labels == nil { + s.Labels = make(map[string]string) + } for k, v := range labels { if _, exists := s.Labels[k]; !exists { s.Labels[k] = v -- cgit v1.2.3-54-g00ecf From 20407a2f1fadb1488caac1560dfdd56facff4153 Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Thu, 7 May 2020 16:35:48 -0500 Subject: fix pod stats flake it appears that the pod stats flake can be attributed to the fact that the container being run is not fully running when the stats call is made. because the stats call is in format of json, it fails when nil Signed-off-by: Brent Baude --- cmd/podman/containers/stats.go | 1 - test/e2e/stats_test.go | 20 ++++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cmd/podman/containers/stats.go b/cmd/podman/containers/stats.go index 3f9db671f..5b7f52cc7 100644 --- a/cmd/podman/containers/stats.go +++ b/cmd/podman/containers/stats.go @@ -234,7 +234,6 @@ func outputJSON(stats []*containerStats) error { Pids: j.PIDS(), }) } - b, err := json.MarshalIndent(jstats, "", " ") if err != nil { return err diff --git a/test/e2e/stats_test.go b/test/e2e/stats_test.go index 762417a17..d3af44891 100644 --- a/test/e2e/stats_test.go +++ b/test/e2e/stats_test.go @@ -5,6 +5,7 @@ package integration import ( "fmt" "os" + "time" "github.com/containers/libpod/pkg/cgroups" . "github.com/containers/libpod/test/utils" @@ -87,13 +88,24 @@ var _ = Describe("Podman stats", func() { }) It("podman stats with json output", func() { + var found bool session := podmanTest.RunTopContainer("") session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"stats", "--all", "--no-stream", "--format", "json"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) - Expect(session.IsJSONOutputValid()).To(BeTrue()) + for i := 0; i < 5; i++ { + ps := podmanTest.Podman([]string{"ps", "-q"}) + ps.WaitWithDefaultTimeout() + if len(ps.OutputToStringArray()) == 1 { + found = true + break + } + time.Sleep(time.Second) + } + Expect(found).To(BeTrue()) + stats := podmanTest.Podman([]string{"stats", "--all", "--no-stream", "--format", "json"}) + stats.WaitWithDefaultTimeout() + Expect(stats.ExitCode()).To(Equal(0)) + Expect(stats.IsJSONOutputValid()).To(BeTrue()) }) It("podman stats on a container with no net ns", func() { -- cgit v1.2.3-54-g00ecf