@@ -4175,58 +4175,52 @@ 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
4181
+ )
4184
4182
4185
- operatorGroup := operatorsv1.OperatorGroup {
4186
- ObjectMeta : metav1.ObjectMeta {
4187
- Name : genName ("csv-toggle-test-" ),
4188
- Namespace : ns .GetName (),
4189
- },
4190
- }
4183
+ BeforeEach (func () {
4184
+ nsname := genName ("csv-toggle-test-" )
4185
+ og := operatorsv1.OperatorGroup {
4186
+ ObjectMeta : metav1.ObjectMeta {
4187
+ Name : fmt .Sprintf ("%s-operatorgroup" , nsname ),
4188
+ Namespace : nsname ,
4189
+ },
4190
+ }
4191
+ ns = SetupGeneratedTestNamespaceWithOperatorGroup (nsname , og )
4191
4192
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 ,
4193
+ csv = operatorsv1alpha1.ClusterServiceVersion {
4194
+ ObjectMeta : metav1.ObjectMeta {
4195
+ Name : genName ("csv-toggle-test-" ),
4196
+ Namespace : nsname ,
4197
+ },
4198
+ Spec : operatorsv1alpha1.ClusterServiceVersionSpec {
4199
+ InstallStrategy : newNginxInstallStrategy (genName ("csv-toggle-test-" ), nil , nil ),
4200
+ InstallModes : []operatorsv1alpha1.InstallMode {
4201
+ {
4202
+ Type : operatorsv1alpha1 .InstallModeTypeAllNamespaces ,
4203
+ Supported : true ,
4204
+ },
4203
4205
},
4204
4206
},
4205
- },
4206
- }
4207
-
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
- }
4215
-
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
- }
4220
-
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
- }
4207
+ }
4208
+ err := ctx .Ctx ().Client ().Create (context .Background (), & csv )
4209
+ Expect (err ).ShouldNot (HaveOccurred ())
4210
+ })
4211
+ AfterEach (func () {
4212
+ Eventually (func () error {
4213
+ err := ctx .Ctx ().Client ().Delete (context .Background (), & csv )
4214
+ if err != nil && k8serrors .IsNotFound (err ) {
4215
+ return err
4216
+ }
4225
4217
4226
- return nil
4227
- }).Should (Succeed ())
4228
- })
4218
+ return nil
4219
+ }).Should (Succeed ())
4220
+ TeardownNamespace (ns .GetName ())
4221
+ })
4229
4222
4223
+ When ("an operator is installed in AllNamespace mode" , func () {
4230
4224
It ("should have Copied CSVs in all other namespaces" , func () {
4231
4225
Eventually (func () error {
4232
4226
requirement , err := k8slabels .NewRequirement (operatorsv1alpha1 .CopiedLabelKey , selection .Equals , []string {csv .GetNamespace ()})
0 commit comments