|
| 1 | +package e2e |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + "time" |
| 7 | + |
| 8 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 9 | + "k8s.io/apimachinery/pkg/types" |
| 10 | + "k8s.io/apimachinery/pkg/util/rand" |
| 11 | + |
| 12 | + . "github.com/onsi/ginkgo/v2" |
| 13 | + . "github.com/onsi/gomega" |
| 14 | + operatorv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" |
| 15 | +) |
| 16 | + |
| 17 | +const ( |
| 18 | + defaultTimeout = 30 * time.Second |
| 19 | + defaultPoll = 1 * time.Second |
| 20 | +) |
| 21 | + |
| 22 | +var _ = Describe("Operator Install", func() { |
| 23 | + It("resolves the specified package with correct bundle path", func() { |
| 24 | + var ( |
| 25 | + ctx context.Context = context.Background() |
| 26 | + pkgName string = "prometheus" |
| 27 | + operator *operatorv1alpha1.Operator = &operatorv1alpha1.Operator{ |
| 28 | + ObjectMeta: metav1.ObjectMeta{ |
| 29 | + Name: fmt.Sprintf("operator-%s", rand.String(8)), |
| 30 | + }, |
| 31 | + Spec: operatorv1alpha1.OperatorSpec{ |
| 32 | + PackageName: pkgName, |
| 33 | + }, |
| 34 | + } |
| 35 | + ) |
| 36 | + ctx = context.Background() |
| 37 | + By("creating the Operator resource") |
| 38 | + err := c.Create(ctx, operator) |
| 39 | + Expect(err).ToNot(HaveOccurred()) |
| 40 | + |
| 41 | + // TODO dfranz: This test currently relies on the hard-coded CatalogSources found in bundle_cache.go |
| 42 | + // and should be re-worked to use a real or test catalog source when the hard-coded stuff is removed |
| 43 | + By("eventually reporting a successful resolution and bundle path") |
| 44 | + Eventually(func(g Gomega) { |
| 45 | + err = c.Get(ctx, types.NamespacedName{Name: operator.Name}, operator) |
| 46 | + g.Expect(err).ToNot(HaveOccurred()) |
| 47 | + g.Expect(len(operator.Status.Conditions)).To(Equal(1)) |
| 48 | + g.Expect(operator.Status.Conditions[0].Message).To(Equal("resolution was successful")) |
| 49 | + }).WithTimeout(defaultTimeout).WithPolling(defaultPoll).Should(Succeed()) |
| 50 | + |
| 51 | + By("deleting the Operator resource") |
| 52 | + err = c.Delete(ctx, operator) |
| 53 | + Expect(err).ToNot(HaveOccurred()) |
| 54 | + }) |
| 55 | +}) |
0 commit comments