@@ -407,7 +407,7 @@ func createSubscription(t *testing.T, crc versioned.Interface, namespace, name,
407
407
return buildSubscriptionCleanupFunc (t , crc , subscription )
408
408
}
409
409
410
- func createSubscriptionWithPodConfig (t * testing.T , crc versioned.Interface , namespace , name , packageName , channel string , approval v1alpha1.Approval , config v1alpha1. SubscriptionConfig ) cleanupFunc {
410
+ func createSubscriptionForCatalog (t * testing.T , crc versioned.Interface , namespace , name , catalog , packageName , channel , startingCSV string , approval v1alpha1.Approval ) cleanupFunc {
411
411
subscription := & v1alpha1.Subscription {
412
412
TypeMeta : metav1.TypeMeta {
413
413
Kind : v1alpha1 .SubscriptionKind ,
@@ -418,12 +418,12 @@ func createSubscriptionWithPodConfig(t *testing.T, crc versioned.Interface, name
418
418
Name : name ,
419
419
},
420
420
Spec : & v1alpha1.SubscriptionSpec {
421
- CatalogSource : catalogSourceName ,
421
+ CatalogSource : catalog ,
422
422
CatalogSourceNamespace : namespace ,
423
423
Package : packageName ,
424
424
Channel : channel ,
425
+ StartingCSV : startingCSV ,
425
426
InstallPlanApproval : approval ,
426
- Config : config ,
427
427
},
428
428
}
429
429
@@ -432,7 +432,7 @@ func createSubscriptionWithPodConfig(t *testing.T, crc versioned.Interface, name
432
432
return buildSubscriptionCleanupFunc (t , crc , subscription )
433
433
}
434
434
435
- func createSubscriptionForCatalog (t * testing.T , crc versioned.Interface , namespace , name , catalog , packageName , channel , startingCSV string , approval v1alpha1.Approval ) cleanupFunc {
435
+ func createSubscriptionForCatalogWithSpec (t * testing.T , crc versioned.Interface , namespace , name string , spec * v1alpha1.SubscriptionSpec ) cleanupFunc {
436
436
subscription := & v1alpha1.Subscription {
437
437
TypeMeta : metav1.TypeMeta {
438
438
Kind : v1alpha1 .SubscriptionKind ,
@@ -442,14 +442,7 @@ func createSubscriptionForCatalog(t *testing.T, crc versioned.Interface, namespa
442
442
Namespace : namespace ,
443
443
Name : name ,
444
444
},
445
- Spec : & v1alpha1.SubscriptionSpec {
446
- CatalogSource : catalog ,
447
- CatalogSourceNamespace : namespace ,
448
- Package : packageName ,
449
- Channel : channel ,
450
- StartingCSV : startingCSV ,
451
- InstallPlanApproval : approval ,
452
- },
445
+ Spec : spec ,
453
446
}
454
447
455
448
subscription , err := crc .OperatorsV1alpha1 ().Subscriptions (namespace ).Create (subscription )
@@ -1165,15 +1158,10 @@ func TestCreateNewSubscriptionWithPodConfig(t *testing.T) {
1165
1158
return proxyEnv
1166
1159
}
1167
1160
1168
- c := newKubeClient (t )
1169
- crc := newCRClient (t )
1161
+ kubeClient := newKubeClient (t )
1162
+ crClient := newCRClient (t )
1170
1163
config := newConfigClient (t )
1171
1164
1172
- defer func () {
1173
- require .NoError (t , crc .OperatorsV1alpha1 ().Subscriptions (testNamespace ).DeleteCollection (& metav1.DeleteOptions {}, metav1.ListOptions {}))
1174
- }()
1175
- require .NoError (t , initCatalog (t , c , crc ))
1176
-
1177
1165
podEnv := []corev1.EnvVar {
1178
1166
corev1.EnvVar {
1179
1167
Name : "MY_ENV_VARIABLE1" ,
@@ -1188,22 +1176,31 @@ func TestCreateNewSubscriptionWithPodConfig(t *testing.T) {
1188
1176
Env : podEnv ,
1189
1177
}
1190
1178
1191
- subscriptionName := "mysub-podconfig"
1192
- cleanup := createSubscriptionWithPodConfig (t , crc , testNamespace , subscriptionName , testPackageName , betaChannel , v1alpha1 .ApprovalAutomatic , podConfig )
1193
- defer cleanup ()
1179
+ permissions := deploymentPermissions (t )
1180
+ catsrc , subSpec , catsrcCleanup := newCatalogSource (t , kubeClient , crClient , "podconfig" , testNamespace , permissions )
1181
+ defer catsrcCleanup ()
1182
+
1183
+ // Ensure that the catalog source is resolved before we create a subscription.
1184
+ _ , err := fetchCatalogSource (t , crClient , catsrc .GetName (), testNamespace , catalogSourceRegistryPodSynced )
1185
+ require .NoError (t , err )
1186
+
1187
+ subscriptionName := genName ("podconfig-sub-" )
1188
+ subSpec .Config = podConfig
1189
+ cleanupSubscription := createSubscriptionForCatalogWithSpec (t , crClient , testNamespace , subscriptionName , subSpec )
1190
+ defer cleanupSubscription ()
1194
1191
1195
- subscription , err := fetchSubscription (t , crc , testNamespace , subscriptionName , subscriptionStateAtLatestChecker )
1192
+ subscription , err := fetchSubscription (t , crClient , testNamespace , subscriptionName , subscriptionStateAtLatestChecker )
1196
1193
require .NoError (t , err )
1197
1194
require .NotNil (t , subscription )
1198
1195
1199
- csv , err := fetchCSV (t , crc , subscription .Status .CurrentCSV , testNamespace , buildCSVConditionChecker (v1alpha1 .CSVPhaseSucceeded ))
1196
+ csv , err := fetchCSV (t , crClient , subscription .Status .CurrentCSV , testNamespace , buildCSVConditionChecker (v1alpha1 .CSVPhaseSucceeded ))
1200
1197
require .NoError (t , err )
1201
1198
1202
1199
proxyEnv := proxyEnvVarFunc (t , config )
1203
1200
expected := podEnv
1204
1201
expected = append (expected , proxyEnv ... )
1205
1202
1206
- checkDeploymentWithPodConfiguration (t , c , csv , podConfig .Env )
1203
+ checkDeploymentWithPodConfiguration (t , kubeClient , csv , podConfig .Env )
1207
1204
}
1208
1205
1209
1206
func checkDeploymentWithPodConfiguration (t * testing.T , client operatorclient.ClientInterface , csv * v1alpha1.ClusterServiceVersion , envVar []corev1.EnvVar ) {
0 commit comments