Skip to content

Commit

Permalink
conformance: always run but warn if empty layer manifest not supported
Browse files Browse the repository at this point in the history
Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
  • Loading branch information
rchincha committed Jun 17, 2023
1 parent deddb2d commit 6731bd3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
11 changes: 7 additions & 4 deletions conformance/02_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,16 +350,19 @@ var test02Push = func() {

g.Specify("Registry should accept a manifest upload with no layers", func() {
SkipIfDisabled(push)
RunOnlyIfNot(skipEmptyLayerTest)
req := client.NewRequest(reggie.PUT, "/v2/<name>/manifests/<reference>",
reggie.WithReference(emptyLayerTestTag)).
SetHeader("Content-Type", "application/vnd.oci.image.manifest.v1+json").
SetBody(emptyLayerManifestContent)
resp, err := client.Do(req)
Expect(err).To(BeNil())
location := resp.Header().Get("Location")
Expect(location).ToNot(BeEmpty())
Expect(resp.StatusCode()).To(Equal(http.StatusCreated))
if resp.StatusCode() == http.StatusCreated {
location := resp.Header().Get("Location")
Expect(location).ToNot(BeEmpty())
Expect(resp.StatusCode()).To(Equal(http.StatusCreated))
} else {
Warn("WARNING: image manifest with no layers is not supported")
}
})

g.Specify("GET request to manifest URL (digest) should yield 200 response", func() {
Expand Down
3 changes: 3 additions & 0 deletions conformance/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ require (

require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nxadm/tail v1.4.8 // indirect
golang.org/x/net v0.8.0 // indirect
Expand Down
9 changes: 9 additions & 0 deletions conformance/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/bloodorangeio/reggie v0.6.1 h1:rSpfPN8oU9kflRI7aQVjImjhY5meRsXDIXnJQr
github.com/bloodorangeio/reggie v0.6.1/go.mod h1:Jkvg7UBdlXVNOlvXU6hgysdtG1XNVCB3B4/k7+PtlfM=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
Expand All @@ -28,6 +30,12 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down Expand Up @@ -87,6 +95,7 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
Expand Down
22 changes: 17 additions & 5 deletions conformance/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import (
"math/big"
mathrand "math/rand"
"os"
"runtime"
"strconv"

"github.com/bloodorangeio/reggie"
"github.com/fatih/color"
"github.com/google/uuid"
"github.com/mattn/go-colorable"
g "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/formatter"
godigest "github.com/opencontainers/go-digest"
)

Expand Down Expand Up @@ -128,7 +132,6 @@ var (
runPushSetup bool
runContentDiscoverySetup bool
runContentManagementSetup bool
skipEmptyLayerTest bool
deleteManifestBeforeBlobs bool
runAutomaticCrossmountTest bool
automaticCrossmountEnabled bool
Expand Down Expand Up @@ -309,7 +312,6 @@ func init() {
runPushSetup = true
runContentDiscoverySetup = true
runContentManagementSetup = true
skipEmptyLayerTest = true
deleteManifestBeforeBlobs = false

if os.Getenv(envVarTagName) != "" &&
Expand All @@ -322,9 +324,6 @@ func init() {
runContentDiscoverySetup = false
}

if v, ok := os.LookupEnv(envVarPushEmptyLayer); ok {
skipEmptyLayerTest, _ = strconv.ParseBool(v)
}
deleteManifestBeforeBlobs, _ = strconv.ParseBool(os.Getenv(envVarDeleteManifestBeforeBlobs))
automaticCrossmountVal := ""
automaticCrossmountVal, runAutomaticCrossmountTest = os.LookupEnv(envVarAutomaticCrossmount)
Expand Down Expand Up @@ -354,6 +353,19 @@ func RunOnlyIfNot(v bool) {
}
}

func Warn(message string) {
fmt.Fprintf(colorable.NewColorableStderr(), "\n")
// print message
msgcolor := color.New(color.FgMagenta).FprintfFunc()
msgcolor(colorable.NewColorableStderr(), formatter.Fi(2, "\nWARNING: "+message))
fmt.Fprintf(colorable.NewColorableStderr(), "\n")
// print file:line
_, file, line, _ := runtime.Caller(1)
flcolor := color.New(color.FgWhite).FprintfFunc()
flcolor(colorable.NewColorableStderr(), formatter.Fi(2, "\n"))
flcolor(colorable.NewColorableStderr(), formatter.Fi(2, "%s:%d\n", file, line))
}

func generateSkipReport() string {
buf := new(bytes.Buffer)
fmt.Fprintf(buf, "you have skipped this test; if this is an error, check your environment variable settings:\n")
Expand Down

0 comments on commit 6731bd3

Please sign in to comment.