@@ -7,11 +7,13 @@ import (
7
7
"context"
8
8
"fmt"
9
9
"net"
10
+ "path/filepath"
10
11
"strconv"
11
12
"strings"
12
13
"time"
13
14
14
15
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
16
+ operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
15
17
k8serror "k8s.io/apimachinery/pkg/api/errors"
16
18
"sigs.k8s.io/controller-runtime/pkg/client"
17
19
@@ -40,6 +42,7 @@ import (
40
42
const (
41
43
openshiftregistryFQDN = "image-registry.openshift-image-registry.svc:5000"
42
44
catsrcImage = "docker://quay.io/olmtest/catsrc-update-test:"
45
+ badCSVDir = "bad-csv"
43
46
)
44
47
45
48
var _ = Describe ("Starting CatalogSource e2e tests" , func () {
@@ -1340,6 +1343,68 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
1340
1343
}
1341
1344
}
1342
1345
})
1346
+
1347
+ When ("A CatalogSource is created with an operator that has a CSV with missing metadata.ApiVersion" , func () {
1348
+
1349
+ var (
1350
+ magicCatalog MagicCatalog
1351
+ catalogSourceName string
1352
+ subscription * operatorsv1alpha1.Subscription
1353
+ c client.Client
1354
+ )
1355
+
1356
+ BeforeEach (func () {
1357
+ c = ctx .Ctx ().Client ()
1358
+
1359
+ provider , err := NewFileBasedFiledBasedCatalogProvider (filepath .Join (testdataDir , badCSVDir , "bad-csv.yaml" ))
1360
+ Expect (err ).To (BeNil ())
1361
+
1362
+ catalogSourceName = genName ("cat-bad-csv" )
1363
+ magicCatalog = NewMagicCatalog (c , ns .GetName (), catalogSourceName , provider )
1364
+ Expect (magicCatalog .DeployCatalog (context .Background ())).To (BeNil ())
1365
+
1366
+ })
1367
+
1368
+ AfterEach (func () {
1369
+ TeardownNamespace (ns .GetName ())
1370
+ })
1371
+
1372
+ When ("A Subscription is created catalogSource built with the malformed CSV" , func () {
1373
+ BeforeEach (func () {
1374
+ subscription = & operatorsv1alpha1.Subscription {
1375
+ ObjectMeta : metav1.ObjectMeta {
1376
+ Name : fmt .Sprintf ("%s-sub" , catalogSourceName ),
1377
+ Namespace : ns .GetName (),
1378
+ },
1379
+ Spec : & operatorsv1alpha1.SubscriptionSpec {
1380
+ CatalogSource : catalogSourceName ,
1381
+ CatalogSourceNamespace : ns .GetName (),
1382
+ Channel : "stable" ,
1383
+ Package : "packageA" ,
1384
+ },
1385
+ }
1386
+ Expect (c .Create (context .Background (), subscription )).To (BeNil ())
1387
+ })
1388
+
1389
+ It ("fails with a ResolutionFailed error condition, and a message that highlights the missing field in the CSV" , func () {
1390
+
1391
+ subscription , err := fetchSubscription (crc , subscription .GetNamespace (), subscription .GetName (), subscriptionHasInstallPlanChecker )
1392
+ Expect (err ).Should (BeNil ())
1393
+ installPlanName := subscription .Status .Install .Name
1394
+
1395
+ // ensure we wait for the installPlan to fail before moving forward then fetch the subscription again
1396
+ _ , err = fetchInstallPlan (GinkgoT (), crc , installPlanName , subscription .GetNamespace (), buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseFailed ))
1397
+ Expect (err ).To (BeNil ())
1398
+ subscription , err = fetchSubscription (crc , subscription .GetNamespace (), subscription .GetName (), subscriptionHasInstallPlanChecker )
1399
+ Expect (err ).To (BeNil ())
1400
+
1401
+ // expect the message that API missing
1402
+ failingCondition := subscription .Status .GetCondition (operatorsv1alpha1 .SubscriptionInstallPlanFailed )
1403
+ Expect (failingCondition .Message ).To (ContainSubstring ("missing APIVersion" ))
1404
+ })
1405
+ })
1406
+ })
1407
+
1343
1408
})
1344
1409
1345
1410
func getOperatorDeployment (c operatorclient.ClientInterface , namespace string , operatorLabels labels.Set ) (* appsv1.Deployment , error ) {
0 commit comments