@@ -2,89 +2,92 @@ package e2e
2
2
3
3
import (
4
4
"context"
5
+ "fmt"
5
6
"time"
6
7
7
8
"github.com/blang/semver/v4"
8
9
. "github.com/onsi/ginkgo"
9
- "github.com/onsi/ginkgo/extensions/table"
10
10
. "github.com/onsi/gomega"
11
+ operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
11
12
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
13
+ "github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
14
+ corev1 "k8s.io/api/core/v1"
12
15
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13
16
"sigs.k8s.io/controller-runtime/pkg/client"
14
-
15
- "github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
16
17
)
17
18
18
19
var missingAPI = `{"apiVersion":"verticalpodautoscalers.autoscaling.k8s.io/v1","kind":"VerticalPodAutoscaler","metadata":{"name":"my.thing","namespace":"foo"}}`
19
20
20
21
var _ = Describe ("Not found APIs" , func () {
22
+
23
+ var ns corev1.Namespace
24
+
21
25
BeforeEach (func () {
22
- csv := newCSV ("test-csv" , testNamespace , "" , semver.Version {}, nil , nil , nil )
26
+ namespaceName := genName ("deprecated-e2e-" )
27
+ og := operatorsv1.OperatorGroup {
28
+ ObjectMeta : metav1.ObjectMeta {
29
+ Name : fmt .Sprintf ("%s-operatorgroup" , namespaceName ),
30
+ Namespace : namespaceName ,
31
+ },
32
+ }
33
+ ns = SetupGeneratedTestNamespaceWithOperatorGroup (namespaceName , og )
34
+
35
+ csv := newCSV ("test-csv" , ns .GetName (), "" , semver.Version {}, nil , nil , nil )
23
36
Expect (ctx .Ctx ().Client ().Create (context .TODO (), & csv )).To (Succeed ())
24
37
})
38
+
25
39
AfterEach (func () {
26
- TearDown ( testNamespace )
40
+ TeardownNamespace ( ns . GetName () )
27
41
})
28
42
29
- When ("objects with APIs that are not on-cluster are created in the installplan" , func () {
30
- // each entry is an installplan with a deprecated resource
31
- type payload struct {
32
- name string
33
- IP * operatorsv1alpha1.InstallPlan
34
- errMessage string
35
- }
36
-
37
- tableEntries := []table.TableEntry {
38
- table .Entry ("contains an entry with a missing API not found on cluster " , payload {
39
- name : "installplan contains a missing API" ,
40
- IP : & operatorsv1alpha1.InstallPlan {
43
+ Context ("objects with APIs that are not on-cluster are created in the installplan" , func () {
44
+ When ("installplan contains a missing API" , func () {
45
+ It ("the ip enters a failed state with a helpful error message" , func () {
46
+ ip := & operatorsv1alpha1.InstallPlan {
41
47
ObjectMeta : metav1.ObjectMeta {
42
- Namespace : * namespace , // this is necessary due to ginkgo table semantics, see https://github.com/onsi/ginkgo/issues/378
43
48
Name : "test-plan-api" ,
49
+ Namespace : ns .GetName (),
44
50
},
45
51
Spec : operatorsv1alpha1.InstallPlanSpec {
46
52
Approval : operatorsv1alpha1 .ApprovalAutomatic ,
47
53
Approved : true ,
48
54
ClusterServiceVersionNames : []string {},
49
55
},
50
- },
51
- errMessage : "api-server resource not found installing VerticalPodAutoscaler my.thing: GroupVersionKind " +
52
- "verticalpodautoscalers.autoscaling.k8s.io/v1, Kind=VerticalPodAutoscaler not found on the cluster" ,
53
- }),
54
- }
55
-
56
- table .DescribeTable ("the ip enters a failed state with a helpful error message" , func (tt payload ) {
57
- Expect (ctx .Ctx ().Client ().Create (context .Background (), tt .IP )).To (Succeed ())
56
+ }
57
+ Expect (ctx .Ctx ().Client ().Create (context .Background (), ip )).To (Succeed ())
58
58
59
- tt .IP .Status = operatorsv1alpha1.InstallPlanStatus {
60
- Phase : operatorsv1alpha1 .InstallPlanPhaseInstalling ,
61
- CatalogSources : []string {},
62
- Plan : []* operatorsv1alpha1.Step {
63
- {
64
- Resolving : "test-csv" ,
65
- Status : operatorsv1alpha1 .StepStatusUnknown ,
66
- Resource : operatorsv1alpha1.StepResource {
67
- Name : "my.thing" ,
68
- Group : "verticalpodautoscalers.autoscaling.k8s.io" ,
69
- Version : "v1" ,
70
- Kind : "VerticalPodAutoscaler" ,
71
- Manifest : missingAPI ,
59
+ ip .Status = operatorsv1alpha1.InstallPlanStatus {
60
+ Phase : operatorsv1alpha1 .InstallPlanPhaseInstalling ,
61
+ CatalogSources : []string {},
62
+ Plan : []* operatorsv1alpha1.Step {
63
+ {
64
+ Resolving : "test-csv" ,
65
+ Status : operatorsv1alpha1 .StepStatusUnknown ,
66
+ Resource : operatorsv1alpha1.StepResource {
67
+ Name : "my.thing" ,
68
+ Group : "verticalpodautoscalers.autoscaling.k8s.io" ,
69
+ Version : "v1" ,
70
+ Kind : "VerticalPodAutoscaler" ,
71
+ Manifest : missingAPI ,
72
+ },
72
73
},
73
74
},
74
- },
75
- }
75
+ }
76
76
77
- Expect (ctx .Ctx ().Client ().Status ().Update (context .Background (), tt . IP )).To (Succeed (), "failed to update the resource" )
77
+ Expect (ctx .Ctx ().Client ().Status ().Update (context .Background (), ip )).To (Succeed (), "failed to update the resource" )
78
78
79
- // The IP sits in the Installing phase with the GVK missing error
80
- Eventually (func () (* operatorsv1alpha1.InstallPlan , error ) {
81
- return tt .IP , ctx .Ctx ().Client ().Get (context .Background (), client .ObjectKeyFromObject (tt .IP ), tt .IP )
82
- }).Should (And (HavePhase (operatorsv1alpha1 .InstallPlanPhaseInstalling )), HaveMessage (tt .errMessage ))
79
+ errMessage := "api-server resource not found installing VerticalPodAutoscaler my.thing: GroupVersionKind " +
80
+ "verticalpodautoscalers.autoscaling.k8s.io/v1, Kind=VerticalPodAutoscaler not found on the cluster"
81
+ // The IP sits in the Installing phase with the GVK missing error
82
+ Eventually (func () (* operatorsv1alpha1.InstallPlan , error ) {
83
+ return ip , ctx .Ctx ().Client ().Get (context .Background (), client .ObjectKeyFromObject (ip ), ip )
84
+ }).Should (And (HavePhase (operatorsv1alpha1 .InstallPlanPhaseInstalling )), HaveMessage (errMessage ))
83
85
84
- // Eventually the IP fails with the GVK missing error, after installplan retries, which is by default 1 minute.
85
- Eventually (func () (* operatorsv1alpha1.InstallPlan , error ) {
86
- return tt .IP , ctx .Ctx ().Client ().Get (context .Background (), client .ObjectKeyFromObject (tt .IP ), tt .IP )
87
- }, 2 * time .Minute ).Should (And (HavePhase (operatorsv1alpha1 .InstallPlanPhaseFailed )), HaveMessage (tt .errMessage ))
88
- }, tableEntries ... )
86
+ // Eventually the IP fails with the GVK missing error, after installplan retries, which is by default 1 minute.
87
+ Eventually (func () (* operatorsv1alpha1.InstallPlan , error ) {
88
+ return ip , ctx .Ctx ().Client ().Get (context .Background (), client .ObjectKeyFromObject (ip ), ip )
89
+ }, 2 * time .Minute ).Should (And (HavePhase (operatorsv1alpha1 .InstallPlanPhaseFailed )), HaveMessage (errMessage ))
90
+ })
91
+ })
89
92
})
90
93
})
0 commit comments