Skip to content

Commit

Permalink
Merge pull request #25388 from dmage/ocm-test-watch
Browse files Browse the repository at this point in the history
Print error if watch.Error happens
  • Loading branch information
openshift-merge-robot committed Aug 10, 2020
2 parents 5a28c82 + 18e07d1 commit 3fbb1d6
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions test/extended/controller_manager/deploy_trigger.go
Expand Up @@ -7,6 +7,7 @@ import (

g "github.com/onsi/ginkgo"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
watchapi "k8s.io/apimachinery/pkg/watch"
Expand Down Expand Up @@ -248,16 +249,24 @@ var _ = g.Describe("[sig-apps][Feature:OpenShiftControllerManager]", func() {
for {
select {
case event := <-imageWatch.ResultChan():
stream := event.Object.(*imagev1.ImageStream)
tagEventList, ok := imageutil.StatusHasTag(stream, imagev1.DefaultImageTag)
if ok && len(tagEventList.Items) > 0 && tagEventList.Items[0].DockerImageReference == mapping.Image.DockerImageReference {
t.Logf("imagestream %q now has status with tags: %#v", stream.Name, stream.Status.Tags)
return
}
if len(tagEventList.Items) > 0 {
t.Logf("want: %s, got: %s", mapping.Image.DockerImageReference, tagEventList.Items[0].DockerImageReference)
switch event.Type {
case watchapi.Error:
if status, ok := event.Object.(*metav1.Status); ok {
t.Fatalf("unexpected error from watcher: %v", errors.FromObject(status))
}
t.Fatalf("unexpected object from watcher: %#v", event.Object)
default:
stream := event.Object.(*imagev1.ImageStream)
tagEventList, ok := imageutil.StatusHasTag(stream, imagev1.DefaultImageTag)
if ok && len(tagEventList.Items) > 0 && tagEventList.Items[0].DockerImageReference == mapping.Image.DockerImageReference {
t.Logf("imagestream %q now has status with tags: %#v", stream.Name, stream.Status.Tags)
return
}
if len(tagEventList.Items) > 0 {
t.Logf("want: %s, got: %s", mapping.Image.DockerImageReference, tagEventList.Items[0].DockerImageReference)
}
t.Logf("Still waiting for latest tag status update on imagestream %q with tags: %#v", stream.Name, tagEventList)
}
t.Logf("Still waiting for latest tag status update on imagestream %q with tags: %#v", stream.Name, tagEventList)
case <-timeout:
t.Fatalf("timed out waiting for image stream %q to be updated", imageStream.Name)
}
Expand Down

0 comments on commit 3fbb1d6

Please sign in to comment.