@@ -2,20 +2,21 @@ package e2e
2
2
3
3
import (
4
4
"encoding/json"
5
+ "fmt"
5
6
"testing"
6
-
7
+
7
8
"github.com/coreos/go-semver/semver"
8
9
"github.com/ghodss/yaml"
9
10
"github.com/stretchr/testify/require"
10
11
appsv1 "k8s.io/api/apps/v1"
11
12
corev1 "k8s.io/api/core/v1"
13
+ "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
12
14
k8serrors "k8s.io/apimachinery/pkg/api/errors"
13
15
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14
16
"k8s.io/apimachinery/pkg/util/wait"
15
- "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
16
17
17
- "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
18
18
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1"
19
+ "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
19
20
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
20
21
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
21
22
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
73
74
Name : outdated ,
74
75
},
75
76
Spec : v1alpha1.ClusterServiceVersionSpec {
76
- Replaces : "" ,
77
- Version : * semver .New ("0.1.0" ),
77
+ Replaces : "" ,
78
+ Version : * semver .New ("0.1.0" ),
78
79
MinKubeVersion : "0.0.0" ,
79
80
InstallModes : []v1alpha1.InstallMode {
80
81
{
@@ -103,8 +104,8 @@ var (
103
104
Name : stable ,
104
105
},
105
106
Spec : v1alpha1.ClusterServiceVersionSpec {
106
- Replaces : outdated ,
107
- Version : * semver .New ("0.2.0" ),
107
+ Replaces : outdated ,
108
+ Version : * semver .New ("0.2.0" ),
108
109
MinKubeVersion : "0.0.0" ,
109
110
InstallModes : []v1alpha1.InstallMode {
110
111
{
@@ -260,13 +261,19 @@ func init() {
260
261
func initCatalog (t * testing.T , c operatorclient.ClientInterface , crc versioned.Interface ) error {
261
262
// Create configmap containing catalog
262
263
dummyCatalogConfigMap .SetNamespace (testNamespace )
263
- if _ , err := c .KubernetesInterface ().CoreV1 ().ConfigMaps (testNamespace ).Create (dummyCatalogConfigMap ); err != nil && ! k8serrors .IsAlreadyExists (err ) {
264
+ if _ , err := c .KubernetesInterface ().CoreV1 ().ConfigMaps (testNamespace ).Create (dummyCatalogConfigMap ); err != nil {
265
+ if k8serrors .IsAlreadyExists (err ) {
266
+ return fmt .Errorf ("E2E bug detected: %v" , err )
267
+ }
264
268
return err
265
269
}
266
270
267
271
// Create catalog source custom resource pointing to ConfigMap
268
272
dummyCatalogSource .SetNamespace (testNamespace )
269
- if _ , err := crc .OperatorsV1alpha1 ().CatalogSources (testNamespace ).Create (& dummyCatalogSource ); err != nil && ! k8serrors .IsAlreadyExists (err ) {
273
+ if _ , err := crc .OperatorsV1alpha1 ().CatalogSources (testNamespace ).Create (& dummyCatalogSource ); err != nil {
274
+ if k8serrors .IsAlreadyExists (err ) {
275
+ return fmt .Errorf ("E2E bug detected: %v" , err )
276
+ }
270
277
return err
271
278
}
272
279
@@ -384,7 +391,7 @@ func createSubscriptionForCatalog(t *testing.T, crc versioned.Interface, namespa
384
391
CatalogSourceNamespace : testNamespace ,
385
392
Package : packageName ,
386
393
Channel : channel ,
387
- StartingCSV : startingCSV ,
394
+ StartingCSV : startingCSV ,
388
395
InstallPlanApproval : approval ,
389
396
},
390
397
}
@@ -521,7 +528,7 @@ func TestSusbcriptionWithStartingCSV(t *testing.T) {
521
528
namedStrategy := newNginxInstallStrategy (genName ("dep-" ), nil , nil )
522
529
csvA := newCSV ("nginx-a" , testNamespace , "" , * semver .New ("0.1.0" ), []apiextensions.CustomResourceDefinition {crd }, nil , namedStrategy )
523
530
csvB := newCSV ("nginx-b" , testNamespace , "nginx-a" , * semver .New ("0.2.0" ), []apiextensions.CustomResourceDefinition {crd }, nil , namedStrategy )
524
-
531
+
525
532
// Create PackageManifests
526
533
manifests := []registry.PackageManifest {
527
534
{
@@ -565,7 +572,7 @@ func TestSusbcriptionWithStartingCSV(t *testing.T) {
565
572
for _ , s := range fetchedInstallPlan .Status .Plan {
566
573
require .Equal (t , csvA .GetName (), s .Resolving , "unexpected resolution found" )
567
574
require .Equal (t , v1alpha1 .StepStatusUnknown , s .Status , "status should be unknown" )
568
- require .Equal (t , catalogSourceName , s .Resource .CatalogSource , "incorrect catalogsource on step resource" )
575
+ require .Equal (t , catalogSourceName , s .Resource .CatalogSource , "incorrect catalogsource on step resource" )
569
576
switch kind := s .Resource .Kind ; kind {
570
577
case v1alpha1 .ClusterServiceVersionKind :
571
578
require .Equal (t , csvA .GetName (), s .Resource .Name , "unexpected csv found" )
0 commit comments