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 21, 2023
1 parent e3d7eda commit b6a2cc6
Show file tree
Hide file tree
Showing 2 changed files with 17 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("image manifest with no layers is not supported")
}
})

g.Specify("GET request to manifest URL (digest) should yield 200 response", func() {
Expand Down
15 changes: 10 additions & 5 deletions conformance/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import (
"math/big"
mathrand "math/rand"
"os"
"runtime"
"strconv"

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

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

if os.Getenv(envVarTagName) != "" &&
Expand All @@ -322,9 +322,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 +351,14 @@ func RunOnlyIfNot(v bool) {
}
}

func Warn(message string) {
// print message
fmt.Fprintf(os.Stderr, formatter.Fi(2, "\n{{magenta}}WARNING: %s\n{{/}}", message))
// print file:line
_, file, line, _ := runtime.Caller(1)
fmt.Fprintf(os.Stderr, formatter.Fi(2, "\n%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 b6a2cc6

Please sign in to comment.