@@ -901,140 +901,6 @@ var _ = Describe("Install Plan", func() {
901
901
// Should have removed every matching step
902
902
require .Equal (GinkgoT (), 0 , len (expectedSteps ), "Actual resource steps do not match expected" )
903
903
})
904
- It ("PreExistingCRDOwnerIsReplaced" , func () {
905
-
906
- mainPackageName := genName ("nginx-" )
907
- dependentPackageName := genName ("nginx-dep-" )
908
-
909
- mainPackageStable := fmt .Sprintf ("%s-stable" , mainPackageName )
910
- mainPackageBeta := fmt .Sprintf ("%s-beta" , mainPackageName )
911
- dependentPackageStable := fmt .Sprintf ("%s-stable" , dependentPackageName )
912
-
913
- stableChannel := "stable"
914
- betaChannel := "beta"
915
-
916
- // Create manifests
917
- mainManifests := []registry.PackageManifest {
918
- {
919
- PackageName : mainPackageName ,
920
- Channels : []registry.PackageChannel {
921
- {Name : stableChannel , CurrentCSVName : mainPackageStable },
922
- {Name : betaChannel , CurrentCSVName : mainPackageBeta },
923
- },
924
- DefaultChannelName : stableChannel ,
925
- },
926
- {
927
- PackageName : dependentPackageName ,
928
- Channels : []registry.PackageChannel {
929
- {Name : stableChannel , CurrentCSVName : dependentPackageStable },
930
- },
931
- DefaultChannelName : stableChannel ,
932
- },
933
- }
934
-
935
- // Create new CRDs
936
- mainCRD := newCRD (genName ("ins-" ))
937
- dependentCRD := newCRD (genName ("ins-" ))
938
-
939
- // Create new CSVs
940
- mainStableCSV := newCSV (mainPackageStable , testNamespace , "" , semver .MustParse ("0.1.0" ), []apiextensions.CustomResourceDefinition {mainCRD }, []apiextensions.CustomResourceDefinition {dependentCRD }, nil )
941
- mainBetaCSV := newCSV (mainPackageBeta , testNamespace , mainPackageStable , semver .MustParse ("0.2.0" ), []apiextensions.CustomResourceDefinition {mainCRD }, []apiextensions.CustomResourceDefinition {dependentCRD }, nil )
942
- dependentStableCSV := newCSV (dependentPackageStable , testNamespace , "" , semver .MustParse ("0.1.0" ), []apiextensions.CustomResourceDefinition {dependentCRD }, nil , nil )
943
-
944
- c := newKubeClient ()
945
- crc := newCRClient ()
946
- defer func () {
947
- require .NoError (GinkgoT (), crc .OperatorsV1alpha1 ().Subscriptions (testNamespace ).DeleteCollection (context .TODO (), metav1.DeleteOptions {}, metav1.ListOptions {}))
948
- }()
949
-
950
- // Create the catalog source
951
- mainCatalogSourceName := genName ("mock-ocs-main-" + strings .ToLower (CurrentGinkgoTestDescription ().TestText ) + "-" )
952
- _ , cleanupCatalogSource := createInternalCatalogSource (c , crc , mainCatalogSourceName , testNamespace , mainManifests , []apiextensions.CustomResourceDefinition {dependentCRD , mainCRD }, []operatorsv1alpha1.ClusterServiceVersion {dependentStableCSV , mainStableCSV , mainBetaCSV })
953
- defer cleanupCatalogSource ()
954
-
955
- // Attempt to get the catalog source before creating install plan(s)
956
- _ , err := fetchCatalogSourceOnStatus (crc , mainCatalogSourceName , testNamespace , catalogSourceRegistryPodSynced )
957
- require .NoError (GinkgoT (), err )
958
-
959
- subscriptionName := genName ("sub-nginx-" )
960
- subscriptionCleanup := createSubscriptionForCatalog (crc , testNamespace , subscriptionName , mainCatalogSourceName , mainPackageName , stableChannel , "" , operatorsv1alpha1 .ApprovalAutomatic )
961
- defer subscriptionCleanup ()
962
-
963
- subscription , err := fetchSubscription (crc , testNamespace , subscriptionName , subscriptionHasInstallPlanChecker )
964
- require .NoError (GinkgoT (), err )
965
- require .NotNil (GinkgoT (), subscription )
966
-
967
- installPlanName := subscription .Status .InstallPlanRef .Name
968
-
969
- // Wait for InstallPlan to be status: Complete or failed before checking resource presence
970
- completeOrFailedFunc := buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseComplete , operatorsv1alpha1 .InstallPlanPhaseFailed )
971
- fetchedInstallPlan , err := fetchInstallPlan (GinkgoT (), crc , installPlanName , completeOrFailedFunc )
972
- require .NoError (GinkgoT (), err )
973
- GinkgoT ().Logf ("Install plan %s fetched with status %s" , fetchedInstallPlan .GetName (), fetchedInstallPlan .Status .Phase )
974
- require .Equal (GinkgoT (), operatorsv1alpha1 .InstallPlanPhaseComplete , fetchedInstallPlan .Status .Phase )
975
-
976
- // Ensure that the desired resources have been created
977
- expectedSteps := map [registry.ResourceKey ]struct {}{
978
- {Name : mainCRD .Name , Kind : "CustomResourceDefinition" }: {},
979
- {Name : dependentCRD .Name , Kind : "CustomResourceDefinition" }: {},
980
- {Name : dependentPackageStable , Kind : operatorsv1alpha1 .ClusterServiceVersionKind }: {},
981
- {Name : mainPackageStable , Kind : operatorsv1alpha1 .ClusterServiceVersionKind }: {},
982
- {Name : strings .Join ([]string {dependentPackageStable , mainCatalogSourceName , testNamespace }, "-" ), Kind : operatorsv1alpha1 .SubscriptionKind }: {},
983
- }
984
-
985
- require .Equal (GinkgoT (), len (expectedSteps ), len (fetchedInstallPlan .Status .Plan ), "number of expected steps does not match installed" )
986
-
987
- for _ , step := range fetchedInstallPlan .Status .Plan {
988
- key := registry.ResourceKey {
989
- Name : step .Resource .Name ,
990
- Kind : step .Resource .Kind ,
991
- }
992
- _ , ok := expectedSteps [key ]
993
- require .True (GinkgoT (), ok , "couldn't find %v in expected steps: %#v" , key , expectedSteps )
994
-
995
- // Remove the entry from the expected steps set (to ensure no duplicates in resolved plan)
996
- delete (expectedSteps , key )
997
- }
998
-
999
- // Should have removed every matching step
1000
- require .Equal (GinkgoT (), 0 , len (expectedSteps ), "Actual resource steps do not match expected" )
1001
-
1002
- // Update the subscription resource to point to the beta CSV
1003
- err = crc .OperatorsV1alpha1 ().Subscriptions (testNamespace ).DeleteCollection (context .TODO (), * metav1 .NewDeleteOptions (0 ), metav1.ListOptions {})
1004
- require .NoError (GinkgoT (), err )
1005
-
1006
- // Delete orphaned csv
1007
- require .NoError (GinkgoT (), crc .OperatorsV1alpha1 ().ClusterServiceVersions (testNamespace ).Delete (context .TODO (), mainStableCSV .GetName (), metav1.DeleteOptions {}))
1008
-
1009
- // existing cleanup should remove this
1010
- createSubscriptionForCatalog (crc , testNamespace , subscriptionName , mainCatalogSourceName , mainPackageName , betaChannel , "" , operatorsv1alpha1 .ApprovalAutomatic )
1011
-
1012
- subscription , err = fetchSubscription (crc , testNamespace , subscriptionName , subscriptionHasInstallPlanChecker )
1013
- require .NoError (GinkgoT (), err )
1014
- require .NotNil (GinkgoT (), subscription )
1015
-
1016
- installPlanName = subscription .Status .InstallPlanRef .Name
1017
-
1018
- // Wait for InstallPlan to be status: Complete or Failed before checking resource presence
1019
- fetchedInstallPlan , err = fetchInstallPlan (GinkgoT (), crc , installPlanName , buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseComplete , operatorsv1alpha1 .InstallPlanPhaseFailed ))
1020
- require .NoError (GinkgoT (), err )
1021
- GinkgoT ().Logf ("Install plan %s fetched with status %s" , fetchedInstallPlan .GetName (), fetchedInstallPlan .Status .Phase )
1022
-
1023
- require .Equal (GinkgoT (), operatorsv1alpha1 .InstallPlanPhaseComplete , fetchedInstallPlan .Status .Phase )
1024
-
1025
- // Fetch installplan again to check for unnecessary control loops
1026
- fetchedInstallPlan , err = fetchInstallPlan (GinkgoT (), crc , fetchedInstallPlan .GetName (), func (fip * operatorsv1alpha1.InstallPlan ) bool {
1027
- compareResources (GinkgoT (), fetchedInstallPlan , fip )
1028
- return true
1029
- })
1030
- require .NoError (GinkgoT (), err )
1031
-
1032
- // Ensure correct in-cluster resource(s)
1033
- fetchedCSV , err := fetchCSV (crc , mainBetaCSV .GetName (), testNamespace , csvSucceededChecker )
1034
- require .NoError (GinkgoT (), err )
1035
- GinkgoT ().Logf ("All expected resources resolved %s" , fetchedCSV .Status .Phase )
1036
- })
1037
-
1038
904
})
1039
905
1040
906
Describe ("with CRD schema change" , func () {
0 commit comments