@@ -27,12 +27,6 @@ import (
27
27
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil"
28
28
)
29
29
30
- const (
31
- oldsha256 = "sha256:aeb23777c920d98605c4c960f109a9994f5af1aab49bed51c94b88fe8463a919"
32
- newsha256 = "sha256:f04cd65be9767684c7399cc0f183af15c0933e91124bc1f8312654e26678dc11"
33
- catsrcImage = "docker://quay.io/olmtest/catsrc-update-test:"
34
- )
35
-
36
30
func TestCatalogLoadingBetweenRestarts (t * testing.T ) {
37
31
defer cleaner .NotifyTestComplete (t , true )
38
32
@@ -704,6 +698,11 @@ func TestDeleteGRPCRegistryPodTriggersRecreation(t *testing.T) {
704
698
require .Equal (t , 1 , len (registryPods .Items ), "unexpected number of replacement registry pods found" )
705
699
}
706
700
701
+ const (
702
+ openshiftregistryFQDN = "image-registry.openshift-image-registry.svc:5000/openshift-operators"
703
+ catsrcImage = "docker://quay.io/olmtest/catsrc-update-test:"
704
+ )
705
+
707
706
func TestCatalogImageUpdate (t * testing.T ) {
708
707
// Create an image based catalog source from public Quay image
709
708
// Use a unique tag as identifier
@@ -713,21 +712,68 @@ func TestCatalogImageUpdate(t *testing.T) {
713
712
// etcd operator updated from 0.9.0 to 0.9.2-clusterwide
714
713
// Subscription should detect the latest version of the operator in the new catalog source and pull it
715
714
716
- // 0. check old tag to ensure correct image is used
717
- image := fmt .Sprint (catsrcImage , "old" )
718
- tagOk , err := skopeoInspectDigest (image , oldsha256 )
715
+ // create internal registry for purposes of pushing/pulling IF running e2e test locally
716
+ // registry is insecure and for purposes of this test only
717
+ c := newKubeClient (t )
718
+ crc := newCRClient (t )
719
+
720
+ local , err := Local (c )
719
721
if err != nil {
720
- t .Fatalf ("error confirming old catalog image : %s" , err )
722
+ t .Fatalf ("cannot determine if test running locally or on CI : %s" , err )
721
723
}
722
- if ! tagOk {
723
- t .Fatal ("cannot confirm old catalog image integrity" )
724
+
725
+ var registryURL string
726
+ var registryAuth string
727
+ if local {
728
+ registryURL , err = createDockerRegistry (c , testNamespace )
729
+ if err != nil {
730
+ t .Fatalf ("error creating container registry: %s" , err )
731
+ }
732
+ defer deleteDockerRegistry (c , testNamespace )
733
+
734
+ // ensure registry pod is ready before attempting port-forwarding
735
+ _ = awaitPod (t , c , testNamespace , registryName , podReady )
736
+
737
+ err = registryPortForward (testNamespace )
738
+ if err != nil {
739
+ t .Fatalf ("port-forwarding local registry: %s" , err )
740
+ }
741
+ } else {
742
+ registryURL = openshiftregistryFQDN
743
+ registryAuth , err = openshiftRegistryAuth (c , testNamespace )
744
+ if err != nil {
745
+ t .Fatalf ("error getting openshift registry authentication: %s" , err )
746
+ }
724
747
}
725
748
726
- // 1. copy old catalog image into test-specific tag
749
+ // testImage is the name of the image used throughout the test - the image overwritten by skopeo
750
+ // the tag is generated randomly and appended to the end of the testImage
751
+ testImage := fmt .Sprint ("docker://" , registryURL , "/catsrc-update" , ":" )
727
752
tag := genName ("x" )
728
- oldImage , err := skopeoCopy (catsrcImage , tag , catsrcImage , "old" )
729
- if err != nil {
730
- t .Fatalf ("copying old registry file: %s" , err )
753
+
754
+ // 1. copy old catalog image into test-specific tag in internal docker registry
755
+ // create skopeo pod to actually do the work of copying (on openshift) or exec out to local skopeo
756
+ if local {
757
+ _ , err := skopeoLocalCopy (testImage , tag , catsrcImage , "old" )
758
+ if err != nil {
759
+ t .Fatalf ("error copying old registry file: %s" , err )
760
+ }
761
+ } else {
762
+ skopeoArgs := skopeoCopyCmd (testImage , tag , catsrcImage , "old" , registryAuth )
763
+ err = createSkopeoPod (c , skopeoArgs , testNamespace )
764
+ if err != nil {
765
+ t .Fatalf ("error creating skopeo pod: %s" , err )
766
+ }
767
+
768
+ // wait for skopeo pod to exit successfully
769
+ awaitPod (t , c , testNamespace , skopeo , func (pod * corev1.Pod ) bool {
770
+ return pod .Status .Phase == corev1 .PodSucceeded
771
+ })
772
+
773
+ err = deleteSkopeoPod (c , testNamespace )
774
+ if err != nil {
775
+ t .Fatalf ("error deleting skopeo pod: %s" , err )
776
+ }
731
777
}
732
778
733
779
// 2. setup catalog source
@@ -738,6 +784,10 @@ func TestCatalogImageUpdate(t *testing.T) {
738
784
channelName := "clusterwide-alpha"
739
785
740
786
// Create gRPC CatalogSource using an external registry image and poll interval
787
+ var image string
788
+ image = testImage [9 :] // strip off docker://
789
+ image = fmt .Sprint (image , tag )
790
+
741
791
source := & v1alpha1.CatalogSource {
742
792
TypeMeta : metav1.TypeMeta {
743
793
Kind : v1alpha1 .CatalogSourceKind ,
@@ -750,7 +800,7 @@ func TestCatalogImageUpdate(t *testing.T) {
750
800
},
751
801
Spec : v1alpha1.CatalogSourceSpec {
752
802
SourceType : v1alpha1 .SourceTypeGrpc ,
753
- Image : oldImage [ 9 :], // strip off docker://
803
+ Image : image ,
754
804
UpdateStrategy : & v1alpha1.UpdateStrategy {
755
805
RegistryPoll : & v1alpha1.RegistryPoll {
756
806
Interval : & metav1.Duration {Duration : 1 * time .Minute },
@@ -759,7 +809,6 @@ func TestCatalogImageUpdate(t *testing.T) {
759
809
},
760
810
}
761
811
762
- crc := newCRClient (t )
763
812
source , err = crc .OperatorsV1alpha1 ().CatalogSources (source .GetNamespace ()).Create (source )
764
813
require .NoError (t , err )
765
814
defer func () {
@@ -768,7 +817,6 @@ func TestCatalogImageUpdate(t *testing.T) {
768
817
769
818
// wait for new catalog source pod to be created
770
819
// Wait for a new registry pod to be created
771
- c := newKubeClient (t )
772
820
selector := labels .SelectorFromSet (map [string ]string {"olm.catalogSource" : source .GetName ()})
773
821
singlePod := podCount (1 )
774
822
registryPods , err := awaitPods (t , c , source .GetNamespace (), selector .String (), singlePod )
@@ -790,16 +838,6 @@ func TestCatalogImageUpdate(t *testing.T) {
790
838
_ , err = fetchCSV (t , crc , subscription .Status .CurrentCSV , subscription .GetNamespace (), csvSucceededChecker )
791
839
require .NoError (t , err )
792
840
793
- // check new image pod is as we expect
794
- image = fmt .Sprint (catsrcImage , "new" )
795
- tagOk , err = skopeoInspectDigest (image , newsha256 )
796
- if err != nil {
797
- t .Fatalf ("error confirming new catalog image: %s" , err )
798
- }
799
- if ! tagOk {
800
- t .Fatal ("cannot confirm new catalog image integrity" )
801
- }
802
-
803
841
registryCheckFunc := func (podList * corev1.PodList ) bool {
804
842
if len (podList .Items ) > 1 {
805
843
return false
@@ -810,9 +848,28 @@ func TestCatalogImageUpdate(t *testing.T) {
810
848
registryPod , err := awaitPods (t , c , source .GetNamespace (), selector .String (), registryCheckFunc )
811
849
// 3. Update image on registry via skopeo: this should trigger a newly updated version of the catalog source pod
812
850
// to be deployed after some time
813
- _ , err = skopeoCopy (catsrcImage , tag , catsrcImage , "new" )
814
- if err != nil {
815
- t .Fatalf ("copying new registry file: %s" , err )
851
+ // Make another skopeo pod to do the work of copying the image
852
+ if local {
853
+ _ , err := skopeoLocalCopy (testImage , tag , catsrcImage , "new" )
854
+ if err != nil {
855
+ t .Fatalf ("error copying new registry file: %s" , err )
856
+ }
857
+ } else {
858
+ skopeoArgs := skopeoCopyCmd (testImage , tag , catsrcImage , "new" , registryAuth )
859
+ err = createSkopeoPod (c , skopeoArgs , testNamespace )
860
+ if err != nil {
861
+ t .Fatalf ("error creating skopeo pod: %s" , err )
862
+ }
863
+
864
+ // wait for skopeo pod to exit successfully
865
+ awaitPod (t , c , testNamespace , skopeo , func (pod * corev1.Pod ) bool {
866
+ return pod .Status .Phase == corev1 .PodSucceeded
867
+ })
868
+
869
+ err = deleteSkopeoPod (c , testNamespace )
870
+ if err != nil {
871
+ t .Fatalf ("error deleting skopeo pod: %s" , err )
872
+ }
816
873
}
817
874
818
875
// update catalog source with annotation (to kick resync)
0 commit comments