@@ -4175,58 +4175,61 @@ var _ = Describe("ClusterServiceVersion", func() {
4175
4175
})
4176
4176
4177
4177
var _ = Describe ("Disabling copied CSVs" , func () {
4178
- // Define namespace, operatorGroup, and csv upfront
4179
- ns := & corev1.Namespace {
4180
- ObjectMeta : metav1.ObjectMeta {
4181
- Name : genName ("csv-toggle-test-" ),
4182
- },
4183
- }
4178
+ var (
4179
+ ns corev1.Namespace
4180
+ csv operatorsv1alpha1.ClusterServiceVersion
4184
4181
4185
- operatorGroup := operatorsv1.OperatorGroup {
4186
- ObjectMeta : metav1.ObjectMeta {
4187
- Name : genName ("csv-toggle-test-" ),
4188
- Namespace : ns .GetName (),
4189
- },
4190
- }
4182
+ )
4191
4183
4192
- csv := operatorsv1alpha1.ClusterServiceVersion {
4193
- ObjectMeta : metav1.ObjectMeta {
4194
- Name : genName ("csv-toggle-test-" ),
4195
- Namespace : ns .GetName (),
4196
- },
4197
- Spec : operatorsv1alpha1.ClusterServiceVersionSpec {
4198
- InstallStrategy : newNginxInstallStrategy (genName ("csv-toggle-test-" ), nil , nil ),
4199
- InstallModes : []operatorsv1alpha1.InstallMode {
4200
- {
4201
- Type : operatorsv1alpha1 .InstallModeTypeAllNamespaces ,
4202
- Supported : true ,
4203
- },
4184
+ BeforeEach (func () {
4185
+ nsname := genName ("csv-toggle-test-" )
4186
+ og := operatorsv1.OperatorGroup {
4187
+ ObjectMeta : metav1.ObjectMeta {
4188
+ Name : fmt .Sprintf ("%s-operatorgroup" , nsname ),
4189
+ Namespace : nsname ,
4204
4190
},
4205
- },
4206
- }
4191
+ }
4192
+ ns = SetupGeneratedTestNamespaceWithOperatorGroup ( nsname , og )
4207
4193
4208
- When ("an operator is installed in AllNamespace mode" , func () {
4209
- BeforeEach (func () {
4210
- Eventually (func () error {
4211
- if err := ctx .Ctx ().Client ().Create (context .TODO (), ns ); err != nil && ! k8serrors .IsAlreadyExists (err ) {
4212
- ctx .Ctx ().Logf ("Unable to create ns: %v" , err )
4213
- return err
4214
- }
4194
+ Eventually (func () error {
4195
+ csv = operatorsv1alpha1.ClusterServiceVersion {
4196
+ ObjectMeta : metav1.ObjectMeta {
4197
+ Name : genName ("csv-toggle-test-" ),
4198
+ Namespace : nsname ,
4199
+ },
4200
+ Spec : operatorsv1alpha1.ClusterServiceVersionSpec {
4201
+ InstallStrategy : newNginxInstallStrategy (genName ("csv-toggle-test-" ), nil , nil ),
4202
+ InstallModes : []operatorsv1alpha1.InstallMode {
4203
+ {
4204
+ Type : operatorsv1alpha1 .InstallModeTypeAllNamespaces ,
4205
+ Supported : true ,
4206
+ },
4207
+ },
4208
+ },
4209
+ }
4215
4210
4216
- if err := ctx .Ctx ().Client ().Create (context .TODO (), & operatorGroup ); err != nil && ! k8serrors .IsAlreadyExists (err ) {
4217
- ctx .Ctx ().Logf ("Unable to create og : %v" , err )
4218
- return err
4219
- }
4211
+ if err := ctx .Ctx ().Client ().Create (context .TODO (), & csv ); err != nil && ! k8serrors .IsAlreadyExists (err ) {
4212
+ ctx .Ctx ().Logf ("Unable to create csv : %v" , err )
4213
+ return err
4214
+ }
4220
4215
4221
- if err := ctx .Ctx ().Client ().Create (context .TODO (), & csv ); err != nil && ! k8serrors .IsAlreadyExists (err ) {
4222
- ctx .Ctx ().Logf ("Unable to create csv: %v" , err )
4223
- return err
4224
- }
4216
+ return nil
4217
+ }).Should (Succeed ())
4225
4218
4226
- return nil
4227
- }).Should (Succeed ())
4228
- })
4219
+ })
4220
+ AfterEach (func () {
4221
+ Eventually (func () error {
4222
+ err := ctx .Ctx ().Client ().Delete (context .TODO (), & csv )
4223
+ if err != nil && k8serrors .IsNotFound (err ) {
4224
+ return err
4225
+ }
4226
+
4227
+ return nil
4228
+ }).Should (Succeed ())
4229
+ TeardownNamespace (ns .GetName ())
4230
+ })
4229
4231
4232
+ When ("an operator is installed in AllNamespace mode" , func () {
4230
4233
It ("should have Copied CSVs in all other namespaces" , func () {
4231
4234
Eventually (func () error {
4232
4235
requirement , err := k8slabels .NewRequirement (operatorsv1alpha1 .CopiedLabelKey , selection .Equals , []string {csv .GetNamespace ()})
0 commit comments