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