Merge pull request #6118 from baude/v2bindingsenforce

set binding tests to required
This commit is contained in:
OpenShift Merge Robot
2020-05-08 17:57:10 +02:00
committed by GitHub
12 changed files with 107 additions and 78 deletions

View File

@ -644,7 +644,6 @@ special_testing_cross_task:
special_testing_bindings_task: special_testing_bindings_task:
skip: $CI == 'true'
depends_on: depends_on:
- "gating" - "gating"
- "varlink_api" - "varlink_api"

View File

@ -234,7 +234,6 @@ func outputJSON(stats []*containerStats) error {
Pids: j.PIDS(), Pids: j.PIDS(),
}) })
} }
b, err := json.MarshalIndent(jstats, "", " ") b, err := json.MarshalIndent(jstats, "", " ")
if err != nil { if err != nil {
return err return err

View File

@ -24,7 +24,7 @@ var (
func init() { func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{ registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Mode: []entities.EngineMode{entities.ABIMode},
Command: annotateCmd, Command: annotateCmd,
Parent: manifestCmd, Parent: manifestCmd,
}) })

View File

@ -87,7 +87,7 @@ case "$CG_FS_TYPE" in
# Normally not something to do for stable testing # Normally not something to do for stable testing
# but crun is new, and late-breaking fixes may be required # but crun is new, and late-breaking fixes may be required
# on short notice # on short notice
dnf update -y crun dnf update -y crun containers-common
fi fi
;; ;;
*) *)

View File

@ -125,23 +125,24 @@ func Push(ctx context.Context, name string, destination *string, all *bool) (str
return idr.ID, response.Process(&idr) 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 // Annotate updates the image configuration of a given manifest list
func Annotate(ctx context.Context, name, digest string, options image.ManifestAnnotateOpts) (string, error) { //func Annotate(ctx context.Context, name, digest string, options image.ManifestAnnotateOpts) (string, error) {
var idr handlers.IDResponse // var idr handlers.IDResponse
conn, err := bindings.GetClient(ctx) // conn, err := bindings.GetClient(ctx)
if err != nil { // if err != nil {
return "", err // return "", err
} // }
params := url.Values{} // params := url.Values{}
params.Set("digest", digest) // params.Set("digest", digest)
optionsString, err := jsoniter.MarshalToString(options) // optionsString, err := jsoniter.MarshalToString(options)
if err != nil { // if err != nil {
return "", err // return "", err
} // }
stringReader := strings.NewReader(optionsString) // stringReader := strings.NewReader(optionsString)
response, err := conn.DoRequest(stringReader, http.MethodPost, "/manifests/%s/annotate", params, name) // response, err := conn.DoRequest(stringReader, http.MethodPost, "/manifests/%s/annotate", params, name)
if err != nil { // if err != nil {
return "", err // return "", err
} // }
return idr.ID, response.Process(&idr) // return idr.ID, response.Process(&idr)
} //}

View File

@ -531,7 +531,7 @@ var _ = Describe("Podman containers ", func() {
Expect(err).ToNot(BeNil()) 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. // Start and stop a container to enter in exited state.
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, &bindings.PFalse, nil) _, err := bt.RunTopContainer(&name, &bindings.PFalse, nil)
@ -546,7 +546,7 @@ var _ = Describe("Podman containers ", func() {
Expect(len(pruneResponse.ID)).To(Equal(1)) 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. // Start and stop a container to enter in exited state.
var name = "top" var name = "top"
_, err := bt.RunTopContainer(&name, &bindings.PFalse, nil) _, err := bt.RunTopContainer(&name, &bindings.PFalse, nil)

View File

@ -118,25 +118,27 @@ var _ = Describe("Podman containers ", func() {
Expect(len(data.Manifests)).To(BeZero()) Expect(len(data.Manifests)).To(BeZero())
}) })
It("annotate manifest", func() { // There is NO annotate endpoint, this could never work.:w
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) //It("annotate manifest", func() {
Expect(err).To(BeNil()) // id, err := manifests.Create(bt.conn, []string{"quay.io/libpod/foobar:latest"}, []string{}, nil)
data, err := manifests.Inspect(bt.conn, id) // Expect(err).To(BeNil())
Expect(err).To(BeNil()) // opts := image.ManifestAddOpts{Images: []string{"docker.io/library/alpine:latest"}}
Expect(len(data.Manifests)).To(BeNumerically("==", 1)) //
digest := data.Manifests[0].Digest.String() // _, err = manifests.Add(bt.conn, id, opts)
annoOpts := image.ManifestAnnotateOpts{OS: "foo"} // Expect(err).To(BeNil())
_, err = manifests.Annotate(bt.conn, id, digest, annoOpts) // data, err := manifests.Inspect(bt.conn, id)
Expect(err).To(BeNil()) // Expect(err).To(BeNil())
list, err := manifests.Inspect(bt.conn, id) // Expect(len(data.Manifests)).To(BeNumerically("==", 1))
Expect(err).To(BeNil()) // digest := data.Manifests[0].Digest.String()
Expect(len(list.Manifests)).To(BeNumerically("==", 1)) // annoOpts := image.ManifestAnnotateOpts{OS: "foo"}
Expect(list.Manifests[0].Platform.OS).To(Equal("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() { It("push manifest", func() {
Skip("TODO") Skip("TODO")

View File

@ -57,6 +57,11 @@ var _ = Describe("Podman pods", func() {
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(1)) 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 // Adding an alpine container to the existing pod
_, err = bt.RunTopContainer(nil, &bindings.PTrue, &newpod) _, err = bt.RunTopContainer(nil, &bindings.PTrue, &newpod)
Expect(err).To(BeNil()) Expect(err).To(BeNil())
@ -83,6 +88,11 @@ var _ = Describe("Podman pods", func() {
It("List pods with filters", func() { It("List pods with filters", func() {
newpod2 := "newpod2" newpod2 := "newpod2"
bt.Podcreate(&newpod2) bt.Podcreate(&newpod2)
// Start the pod
_, err = pods.Start(bt.conn, newpod)
Expect(err).To(BeNil())
_, err = bt.RunTopContainer(nil, &bindings.PTrue, &newpod) _, err = bt.RunTopContainer(nil, &bindings.PTrue, &newpod)
Expect(err).To(BeNil()) Expect(err).To(BeNil())

View File

@ -3,7 +3,6 @@ package test_bindings
import ( import (
"time" "time"
"github.com/containers/libpod/pkg/api/handlers"
"github.com/containers/libpod/pkg/bindings" "github.com/containers/libpod/pkg/bindings"
"github.com/containers/libpod/pkg/bindings/containers" "github.com/containers/libpod/pkg/bindings/containers"
"github.com/containers/libpod/pkg/bindings/pods" "github.com/containers/libpod/pkg/bindings/pods"
@ -39,8 +38,8 @@ var _ = Describe("Podman system", func() {
}) })
It("podman events", func() { It("podman events", func() {
eChan := make(chan handlers.Event, 1) eChan := make(chan entities.Event, 1)
var messages []handlers.Event var messages []entities.Event
cancelChan := make(chan bool, 1) cancelChan := make(chan bool, 1)
go func() { go func() {
for e := range eChan { for e := range eChan {

View File

@ -64,32 +64,34 @@ func (ir *ImageEngine) ManifestAdd(ctx context.Context, opts entities.ManifestAd
return listID, nil 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 // ManifestAnnotate updates an entry of the manifest list
func (ir *ImageEngine) ManifestAnnotate(ctx context.Context, names []string, opts entities.ManifestAnnotateOptions) (string, error) { func (ir *ImageEngine) ManifestAnnotate(ctx context.Context, names []string, opts entities.ManifestAnnotateOptions) (string, error) {
manifestAnnotateOpts := image.ManifestAnnotateOpts{ return "", errors.New("not implemented")
Arch: opts.Arch, // manifestAnnotateOpts := image.ManifestAnnotateOpts{
Features: opts.Features, // Arch: opts.Arch,
OS: opts.OS, // Features: opts.Features,
OSFeatures: opts.OSFeatures, // OS: opts.OS,
OSVersion: opts.OSVersion, // OSFeatures: opts.OSFeatures,
Variant: opts.Variant, // OSVersion: opts.OSVersion,
} // Variant: opts.Variant,
if len(opts.Annotation) > 0 { // }
annotations := make(map[string]string) // if len(opts.Annotation) > 0 {
for _, annotationSpec := range opts.Annotation { // annotations := make(map[string]string)
spec := strings.SplitN(annotationSpec, "=", 2) // for _, annotationSpec := range opts.Annotation {
if len(spec) != 2 { // spec := strings.SplitN(annotationSpec, "=", 2)
return "", errors.Errorf("no value given for annotation %q", spec[0]) // if len(spec) != 2 {
} // return "", errors.Errorf("no value given for annotation %q", spec[0])
annotations[spec[0]] = spec[1] // }
} // annotations[spec[0]] = spec[1]
manifestAnnotateOpts.Annotation = annotations // }
} // manifestAnnotateOpts.Annotation = annotations
updatedListID, err := manifests.Annotate(ctx, names[0], names[1], manifestAnnotateOpts) // }
if err != nil { // updatedListID, err := manifests.Annotate(ctx, names[0], names[1], manifestAnnotateOpts)
return updatedListID, errors.Wrapf(err, "error annotating %s of manifest list %s", names[1], names[0]) // 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 fmt.Sprintf("%s :%s", updatedListID, names[1]), nil
} }
// ManifestRemove removes the digest from manifest list // ManifestRemove removes the digest from manifest list

View File

@ -42,12 +42,14 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
if err != nil { if err != nil {
return err return err
} }
if stopSignal != "" {
sig, err := signal.ParseSignalNameOrNumber(stopSignal) sig, err := signal.ParseSignalNameOrNumber(stopSignal)
if err != nil { if err != nil {
return err return err
} }
s.StopSignal = &sig s.StopSignal = &sig
} }
}
rtc, err := r.GetConfig() rtc, err := r.GetConfig()
if err != nil { if err != nil {
@ -78,6 +80,9 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
} }
// labels from the image that dont exist already // 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 { for k, v := range labels {
if _, exists := s.Labels[k]; !exists { if _, exists := s.Labels[k]; !exists {
s.Labels[k] = v s.Labels[k] = v

View File

@ -5,6 +5,7 @@ package integration
import ( import (
"fmt" "fmt"
"os" "os"
"time"
"github.com/containers/libpod/pkg/cgroups" "github.com/containers/libpod/pkg/cgroups"
. "github.com/containers/libpod/test/utils" . "github.com/containers/libpod/test/utils"
@ -87,13 +88,24 @@ var _ = Describe("Podman stats", func() {
}) })
It("podman stats with json output", func() { It("podman stats with json output", func() {
var found bool
session := podmanTest.RunTopContainer("") session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout() session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0)) Expect(session.ExitCode()).To(Equal(0))
session = podmanTest.Podman([]string{"stats", "--all", "--no-stream", "--format", "json"}) for i := 0; i < 5; i++ {
session.WaitWithDefaultTimeout() ps := podmanTest.Podman([]string{"ps", "-q"})
Expect(session.ExitCode()).To(Equal(0)) ps.WaitWithDefaultTimeout()
Expect(session.IsJSONOutputValid()).To(BeTrue()) 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() { It("podman stats on a container with no net ns", func() {