@@ -909,116 +909,6 @@ func TestClusterExtensionNoVersion(t *testing.T) {
909
909
require .NoError (t , cl .DeleteAllOf (ctx , & rukpakv1alpha2.BundleDeployment {}))
910
910
}
911
911
912
- func TestClusterExtensionPlainV0Bundle (t * testing.T ) {
913
- cl , reconciler := newClientAndReconciler (t )
914
- ctx := context .Background ()
915
- extKey := types.NamespacedName {Name : fmt .Sprintf ("cluster-extension-test-%s" , rand .String (8 ))}
916
-
917
- t .Log ("When the cluster extension specifies a package with a plain+v0 bundle" )
918
- t .Log ("By initializing cluster state" )
919
- pkgName := "plain"
920
- pkgVer := "0.1.0"
921
- pkgChan := "beta"
922
- clusterExtension := & ocv1alpha1.ClusterExtension {
923
- ObjectMeta : metav1.ObjectMeta {Name : extKey .Name },
924
- Spec : ocv1alpha1.ClusterExtensionSpec {
925
- PackageName : pkgName ,
926
- Version : pkgVer ,
927
- Channel : pkgChan ,
928
- InstallNamespace : "default" ,
929
- },
930
- }
931
- require .NoError (t , cl .Create (ctx , clusterExtension ))
932
-
933
- t .Log ("It sets resolution success status" )
934
- t .Log ("By running reconcile" )
935
- res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : extKey })
936
- require .Equal (t , ctrl.Result {}, res )
937
- require .NoError (t , err )
938
-
939
- t .Log ("By fetching updated cluster extension after reconcile" )
940
- require .NoError (t , cl .Get (ctx , extKey , clusterExtension ))
941
-
942
- t .Log ("By checking the status fields" )
943
- require .Equal (t , & ocv1alpha1.BundleMetadata {Name : "operatorhub/plain/0.1.0" , Version : "0.1.0" }, clusterExtension .Status .ResolvedBundle )
944
- require .Empty (t , clusterExtension .Status .InstalledBundle )
945
- t .Log ("By checking the expected conditions" )
946
- cond := apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeResolved )
947
- require .NotNil (t , cond )
948
- require .Equal (t , metav1 .ConditionTrue , cond .Status )
949
- require .Equal (t , ocv1alpha1 .ReasonSuccess , cond .Reason )
950
- require .Equal (t , "resolved to \" quay.io/operatorhub/plain@sha256:plain\" " , cond .Message )
951
- cond = apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeInstalled )
952
- require .NotNil (t , cond )
953
- require .Equal (t , metav1 .ConditionUnknown , cond .Status )
954
- require .Equal (t , ocv1alpha1 .ReasonInstallationStatusUnknown , cond .Reason )
955
- require .Equal (t , "bundledeployment status is unknown" , cond .Message )
956
-
957
- t .Log ("By fetching the bundled deployment" )
958
- bd := & rukpakv1alpha2.BundleDeployment {}
959
- require .NoError (t , cl .Get (ctx , types.NamespacedName {Name : extKey .Name }, bd ))
960
- require .Equal (t , "core-rukpak-io-plain" , bd .Spec .ProvisionerClassName )
961
- require .Equal (t , rukpakv1alpha2 .SourceTypeImage , bd .Spec .Source .Type )
962
- require .NotNil (t , bd .Spec .Source .Image )
963
- require .Equal (t , "quay.io/operatorhub/plain@sha256:plain" , bd .Spec .Source .Image .Ref )
964
-
965
- verifyInvariants (ctx , t , reconciler .Client , clusterExtension )
966
- require .NoError (t , cl .DeleteAllOf (ctx , & ocv1alpha1.ClusterExtension {}))
967
- require .NoError (t , cl .DeleteAllOf (ctx , & rukpakv1alpha2.BundleDeployment {}))
968
- }
969
-
970
- func TestClusterExtensionBadBundleMediaType (t * testing.T ) {
971
- cl , reconciler := newClientAndReconciler (t )
972
- ctx := context .Background ()
973
- extKey := types.NamespacedName {Name : fmt .Sprintf ("cluster-extension-test-%s" , rand .String (8 ))}
974
-
975
- t .Log ("When the cluster extension specifies a package with a bad bundle mediatype" )
976
- t .Log ("By initializing cluster state" )
977
- pkgName := "badmedia"
978
- pkgVer := "0.1.0"
979
- pkgChan := "beta"
980
- clusterExtension := & ocv1alpha1.ClusterExtension {
981
- ObjectMeta : metav1.ObjectMeta {Name : extKey .Name },
982
- Spec : ocv1alpha1.ClusterExtensionSpec {
983
- PackageName : pkgName ,
984
- Version : pkgVer ,
985
- Channel : pkgChan ,
986
- InstallNamespace : "default" ,
987
- },
988
- }
989
- require .NoError (t , cl .Create (ctx , clusterExtension ))
990
-
991
- t .Log ("It sets resolution success status" )
992
- t .Log ("By running reconcile" )
993
- res , err := reconciler .Reconcile (ctx , ctrl.Request {NamespacedName : extKey })
994
- require .Equal (t , ctrl.Result {}, res )
995
- require .Error (t , err )
996
- require .ErrorContains (t , err , "unknown bundle mediatype: badmedia+v1" )
997
-
998
- t .Log ("By fetching updated cluster extension after reconcile" )
999
- require .NoError (t , cl .Get (ctx , extKey , clusterExtension ))
1000
-
1001
- t .Log ("By checking the status fields" )
1002
- require .Equal (t , & ocv1alpha1.BundleMetadata {Name : "operatorhub/badmedia/0.1.0" , Version : "0.1.0" }, clusterExtension .Status .ResolvedBundle )
1003
- require .Empty (t , clusterExtension .Status .InstalledBundle )
1004
-
1005
- t .Log ("By checking the expected conditions" )
1006
- cond := apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeResolved )
1007
- require .NotNil (t , cond )
1008
- require .Equal (t , metav1 .ConditionTrue , cond .Status )
1009
- require .Equal (t , ocv1alpha1 .ReasonSuccess , cond .Reason )
1010
- require .Equal (t , "resolved to \" quay.io/operatorhub/badmedia@sha256:badmedia\" " , cond .Message )
1011
- cond = apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1alpha1 .TypeInstalled )
1012
- require .NotNil (t , cond )
1013
- require .Equal (t , metav1 .ConditionFalse , cond .Status )
1014
- require .Equal (t , ocv1alpha1 .ReasonInstallationFailed , cond .Reason )
1015
- require .Equal (t , "unknown bundle mediatype: badmedia+v1" , cond .Message )
1016
-
1017
- verifyInvariants (ctx , t , reconciler .Client , clusterExtension )
1018
- require .NoError (t , cl .DeleteAllOf (ctx , & ocv1alpha1.ClusterExtension {}))
1019
- require .NoError (t , cl .DeleteAllOf (ctx , & rukpakv1alpha2.BundleDeployment {}))
1020
- }
1021
-
1022
912
func verifyInvariants (ctx context.Context , t * testing.T , c client.Client , ext * ocv1alpha1.ClusterExtension ) {
1023
913
key := client .ObjectKeyFromObject (ext )
1024
914
require .NoError (t , c .Get (ctx , key , ext ))
@@ -2000,18 +1890,6 @@ var (
2000
1890
},
2001
1891
},
2002
1892
}
2003
- plainBetaChannel = catalogmetadata.Channel {
2004
- Channel : declcfg.Channel {
2005
- Name : "beta" ,
2006
- Package : "plain" ,
2007
- },
2008
- }
2009
- badmediaBetaChannel = catalogmetadata.Channel {
2010
- Channel : declcfg.Channel {
2011
- Name : "beta" ,
2012
- Package : "badmedia" ,
2013
- },
2014
- }
2015
1893
)
2016
1894
2017
1895
var testBundleList = []* catalogmetadata.Bundle {
@@ -2080,32 +1958,4 @@ var testBundleList = []*catalogmetadata.Bundle{
2080
1958
CatalogName : "fake-catalog" ,
2081
1959
InChannels : []* catalogmetadata.Channel {& prometheusBetaChannel },
2082
1960
},
2083
- {
2084
- Bundle : declcfg.Bundle {
2085
- Name : "operatorhub/plain/0.1.0" ,
2086
- Package : "plain" ,
2087
- Image : "quay.io/operatorhub/plain@sha256:plain" ,
2088
- Properties : []property.Property {
2089
- {Type : property .TypePackage , Value : json .RawMessage (`{"packageName":"plain","version":"0.1.0"}` )},
2090
- {Type : property .TypeGVK , Value : json .RawMessage (`[]` )},
2091
- {Type : "olm.bundle.mediatype" , Value : json .RawMessage (`"plain+v0"` )},
2092
- },
2093
- },
2094
- CatalogName : "fake-catalog" ,
2095
- InChannels : []* catalogmetadata.Channel {& plainBetaChannel },
2096
- },
2097
- {
2098
- Bundle : declcfg.Bundle {
2099
- Name : "operatorhub/badmedia/0.1.0" ,
2100
- Package : "badmedia" ,
2101
- Image : "quay.io/operatorhub/badmedia@sha256:badmedia" ,
2102
- Properties : []property.Property {
2103
- {Type : property .TypePackage , Value : json .RawMessage (`{"packageName":"badmedia","version":"0.1.0"}` )},
2104
- {Type : property .TypeGVK , Value : json .RawMessage (`[]` )},
2105
- {Type : "olm.bundle.mediatype" , Value : json .RawMessage (`"badmedia+v1"` )},
2106
- },
2107
- },
2108
- CatalogName : "fake-catalog" ,
2109
- InChannels : []* catalogmetadata.Channel {& badmediaBetaChannel },
2110
- },
2111
1961
}
0 commit comments