Skip to content

Commit d939fc8

Browse files
committed
e2e wait for internal registry hostname
For tests that use imagestreams, wait for the internal registry hostname to be available.
1 parent 152f4c2 commit d939fc8

2 files changed

Lines changed: 49 additions & 9 deletions

File tree

test/extended/imageapis/limitrange_admission.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ var _ = g.Describe("[Feature:ImageQuota][registry][Serial][Suite:openshift/regis
2828

2929
var oc = exutil.NewCLI("limitrange-admission", exutil.KubeConfigPath())
3030

31+
g.BeforeEach(func() {
32+
_, err := exutil.WaitForInternalRegistryHostname(oc)
33+
o.Expect(err).NotTo(o.HaveOccurred())
34+
})
35+
3136
g.It(fmt.Sprintf("should deny a push of built image exceeding %s limit", imageapi.LimitTypeImage), func() {
3237
_, err := createLimitRangeOfType(oc, imageapi.LimitTypeImage, kapi.ResourceList{
3338
kapi.ResourceStorage: resource.MustParse("10Ki"),

test/extended/util/framework.go

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,43 @@ import (
4848
const pvPrefix = "pv-"
4949
const nfsPrefix = "nfs-"
5050

51+
// WaitForInternalRegistryHostname waits for the internal registry hostname to be made available to the cluster.
52+
func WaitForInternalRegistryHostname(oc *CLI) (string, error) {
53+
e2e.Logf("Waiting up to 2 minutes for the internal registry hostname to be published")
54+
var registryHostname string
55+
err := wait.Poll(2*time.Second, 2*time.Minute, func() (bool, error) {
56+
imageConfig, err := oc.AsAdmin().AdminConfigClient().ConfigV1().Images().Get("cluster", metav1.GetOptions{})
57+
if err != nil {
58+
if errors.IsNotFound(err) {
59+
return false, nil
60+
}
61+
return false, err
62+
}
63+
if imageConfig == nil {
64+
return false, nil
65+
}
66+
registryHostname = imageConfig.Status.InternalRegistryHostname
67+
if len(registryHostname) == 0 {
68+
return false, nil
69+
}
70+
return true, nil
71+
})
72+
if err == wait.ErrWaitTimeout {
73+
return "", fmt.Errorf("Timed out waiting for internal registry hostname to be published")
74+
}
75+
if err != nil {
76+
return "", err
77+
}
78+
return registryHostname, nil
79+
}
80+
5181
// WaitForOpenShiftNamespaceImageStreams waits for the standard set of imagestreams to be imported
5282
func WaitForOpenShiftNamespaceImageStreams(oc *CLI) error {
83+
// First wait for the internal registry hostname to be published
84+
registryHostname, err := WaitForInternalRegistryHostname(oc)
85+
if err != nil {
86+
return err
87+
}
5388
langs := []string{"ruby", "nodejs", "perl", "php", "python", "mysql", "postgresql", "mongodb", "jenkins"}
5489
scan := func() bool {
5590
for _, lang := range langs {
@@ -59,6 +94,10 @@ func WaitForOpenShiftNamespaceImageStreams(oc *CLI) error {
5994
e2e.Logf("ImageStream Error: %#v \n", err)
6095
return false
6196
}
97+
if !strings.HasPrefix(is.Status.DockerImageRepository, registryHostname) {
98+
e2e.Logf("ImageStream repository %s does not match expected host %s \n", is.Status.DockerImageRepository, registryHostname)
99+
return false
100+
}
62101
for tag := range is.Spec.Tags {
63102
e2e.Logf("Checking tag %v \n", tag)
64103
if _, ok := is.Status.Tags[tag]; !ok {
@@ -70,7 +109,6 @@ func WaitForOpenShiftNamespaceImageStreams(oc *CLI) error {
70109
return true
71110
}
72111

73-
success := false
74112
// with the move to ocp/rhel as the default for the samples in 4.0, there are alot more imagestreams;
75113
// if by some chance this path runs very soon after the cluster has come up, the original time out would
76114
// not be sufficient;
@@ -79,15 +117,12 @@ func WaitForOpenShiftNamespaceImageStreams(oc *CLI) error {
79117
// have proven less reliable that docker.io)
80118
// we've also determined that e2e-aws-image-ecosystem can be started before all the operators have completed; while
81119
// that is getting sorted out, the longer time will help there as well
82-
for i := 0; i < 15; i++ {
83-
e2e.Logf("Running scan #%v \n", i)
120+
e2e.Logf("Scanning openshift ImageStreams \n")
121+
success := false
122+
wait.Poll(10*time.Second, 150*time.Second, func() (bool, error) {
84123
success = scan()
85-
if success {
86-
break
87-
}
88-
e2e.Logf("Sleeping for 10 seconds \n")
89-
time.Sleep(10 * time.Second)
90-
}
124+
return success, nil
125+
})
91126
if success {
92127
e2e.Logf("Success! \n")
93128
return nil

0 commit comments

Comments
 (0)