Skip to content

Commit 9632e0e

Browse files
author
Michal Minář
committed
extended: fixed registry tests
The extended test suite now secures the registry. This patch allows for secure connection to the registry. Mark few registry tests as serial. Prevent them from being run parallel with some other registry tests. Write registry log to file on re-deployment. The registry log is essential for externded test debugging. Without writing it to a file, this information will be lost. Skip image signature workflow test until we figure out, how to make `oadm verify-image-signature` work with secured integrated Docker registry. Issue #16344. Temporarily skip limitrange_admission test. The image size counting is still broken for schema 1 - the layer sizes need to be filled on registry side. Will be fixed by #16776. Signed-off-by: Michal Minář <[email protected]>
1 parent f0b6abd commit 9632e0e

File tree

7 files changed

+61
-17
lines changed

7 files changed

+61
-17
lines changed

test/extended/imageapis/limitrange_admission.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
const limitRangeName = "limits"
2323

24-
var _ = g.Describe("[Feature:ImageQuota] Image limit range", func() {
24+
var _ = g.Describe("[Feature:ImageQuota][Serial] Image limit range", func() {
2525
defer g.GinkgoRecover()
2626
var oc = exutil.NewCLI("limitrange-admission", exutil.KubeConfigPath())
2727

@@ -40,7 +40,8 @@ var _ = g.Describe("[Feature:ImageQuota] Image limit range", func() {
4040
deleteTestImagesAndStreams(oc)
4141
}
4242

43-
g.It(fmt.Sprintf("should deny a push of built image exceeding %s limit", imageapi.LimitTypeImage), func() {
43+
g.It(fmt.Sprintf("[Skipped] should deny a push of built image exceeding %s limit", imageapi.LimitTypeImage), func() {
44+
g.Skip("FIXME: fill image metadata for schema1 in the registry")
4445
oc.SetOutputDir(exutil.TestContext.OutputDir)
4546
defer tearDown(oc)
4647

test/extended/imageapis/quota_admission.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626
waitTimeout = time.Second * 30
2727
)
2828

29-
var _ = g.Describe("[Feature:ImageQuota] Image resource quota", func() {
29+
var _ = g.Describe("[Feature:ImageQuota][Serial] Image resource quota", func() {
3030
defer g.GinkgoRecover()
3131
var oc = exutil.NewCLI("resourcequota-admission", exutil.KubeConfigPath())
3232

test/extended/images/helper.go

+33-10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package images
33
import (
44
"bytes"
55
cryptorand "crypto/rand"
6+
"crypto/tls"
67
"fmt"
78
"io"
89
"io/ioutil"
@@ -21,6 +22,7 @@ import (
2122

2223
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2324
kerrors "k8s.io/apimachinery/pkg/util/errors"
25+
knet "k8s.io/apimachinery/pkg/util/net"
2426
"k8s.io/apimachinery/pkg/util/sets"
2527
"k8s.io/apimachinery/pkg/util/wait"
2628
"k8s.io/kubernetes/pkg/client/retry"
@@ -517,20 +519,41 @@ func MirrorBlobInRegistry(oc *exutil.CLI, dgst digest.Digest, repository string,
517519
if err != nil {
518520
return err
519521
}
520-
req, err := http.NewRequest("GET", fmt.Sprintf("http://%s/v2/%s/blobs/%s", registryURL, repository, dgst.String()), nil)
521-
if err != nil {
522-
return err
523-
}
524522
token, err := oc.Run("whoami").Args("-t").Output()
525523
if err != nil {
526524
return err
527525
}
528-
req.Header.Set("range", "bytes=0-1")
529-
req.Header.Set("Authorization", "Bearer "+token)
530-
c := http.Client{}
531-
resp, err := c.Do(req)
532-
if err != nil {
533-
return err
526+
527+
c := http.Client{
528+
Transport: knet.SetTransportDefaults(&http.Transport{
529+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
530+
}),
531+
}
532+
533+
peekAtBlob := func(schema string) (*http.Request, *http.Response, error) {
534+
req, err := http.NewRequest("GET", fmt.Sprintf("%s://%s/v2/%s/blobs/%s", schema, registryURL, repository, dgst.String()), nil)
535+
if err != nil {
536+
return nil, nil, err
537+
}
538+
req.Header.Set("range", "bytes=0-1")
539+
req.Header.Set("Authorization", "Bearer "+token)
540+
resp, err := c.Do(req)
541+
if err != nil {
542+
fmt.Fprintf(g.GinkgoWriter, "failed to %s %s: %v (%#+v)\n", req.Method, req.URL, err, err)
543+
return nil, nil, err
544+
}
545+
return req, resp, nil
546+
}
547+
548+
var (
549+
req *http.Request
550+
resp *http.Response
551+
getErr error
552+
)
553+
if req, resp, getErr = peekAtBlob("https"); getErr != nil {
554+
if req, resp, getErr = peekAtBlob("http"); getErr != nil {
555+
return getErr
556+
}
534557
}
535558
defer resp.Body.Close()
536559

test/extended/registry/registry.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const (
2525
imageSize = 1024
2626
)
2727

28-
var _ = g.Describe("[Conformance][registry][migration] manifest migration from etcd to registry storage", func() {
28+
var _ = g.Describe("[Conformance][registry][migration][Serial] manifest migration from etcd to registry storage", func() {
2929
defer g.GinkgoRecover()
3030
var oc = exutil.NewCLI("registry-migration", exutil.KubeConfigPath())
3131

test/extended/registry/signature.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
e2e "k8s.io/kubernetes/test/e2e/framework"
1313
)
1414

15-
var _ = g.Describe("[imageapis][registry] image signature workflow", func() {
15+
var _ = g.Describe("[imageapis][registry][Skipped] image signature workflow", func() {
16+
1617
defer g.GinkgoRecover()
1718

1819
var (
@@ -21,6 +22,7 @@ var _ = g.Describe("[imageapis][registry] image signature workflow", func() {
2122
)
2223

2324
g.It("can push a signed image to openshift registry and verify it", func() {
25+
g.Skip("FIXME: fix oadm verify-image-signature to work with secured registry")
2426
g.By("building a signer image that knows how to sign images")
2527
output, err := oc.Run("create").Args("-f", signerBuildFixture).Output()
2628
if err != nil {

test/extended/registry/util/util.go

+18
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,19 @@ func GetRegistryPod(podsGetter kcoreclient.PodsGetter) (*kapiv1.Pod, error) {
120120
return &podList.Items[0], nil
121121
}
122122

123+
// LogRegistryPod attempts to write registry log to a file to recent test's output directory.
124+
func LogRegistryPod(oc *exutil.CLI) error {
125+
pod, err := GetRegistryPod(oc.KubeClient().Core())
126+
if err != nil {
127+
return fmt.Errorf("failed to get registry pod: %v", err)
128+
}
129+
path, err := oc.Run("logs").Args("dc/docker-registry").OutputToFile("pod-" + pod.Name + ".log")
130+
if err == nil {
131+
fmt.Fprintf(g.GinkgoWriter, "written registry pod log to %s\n", path)
132+
}
133+
return err
134+
}
135+
123136
// ConfigureRegistry re-deploys the registry pod if its configuration doesn't match the desiredState. The
124137
// function blocks until the registry is ready.
125138
func ConfigureRegistry(oc *exutil.CLI, desiredState RegistryConfiguration) error {
@@ -154,7 +167,12 @@ func ConfigureRegistry(oc *exutil.CLI, desiredState RegistryConfiguration) error
154167
if err != nil {
155168
return err
156169
}
170+
171+
// log docker-registry pod output before re-deploying
157172
waitForVersion := dc.Status.LatestVersion + 1
173+
if err = LogRegistryPod(oc); err != nil {
174+
fmt.Fprintf(g.GinkgoWriter, "failed to log registry pod: %v\n", err)
175+
}
158176

159177
err = oc.Run("env").Args(append([]string{"dc/docker-registry"}, envOverrides...)...).Execute()
160178
if err != nil {

test/extended/util/cli.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ func (c *CLI) SetNamespace(ns string) *CLI {
139139
}
140140

141141
// WithoutNamespace instructs the command should be invoked without adding --namespace parameter
142-
func (c *CLI) WithoutNamespace() *CLI {
142+
func (c CLI) WithoutNamespace() *CLI {
143143
c.withoutNamespace = true
144-
return c
144+
return &c
145145
}
146146

147147
// SetOutputDir change the default output directory for temporary files

0 commit comments

Comments
 (0)