Closed github-actions[bot] closed 2 years ago
that references the combo repository and toggle between the main branch and the v0.0.2 tag.
https://github.com/timflannagan/rukpak/blob/6a85dab6a45117569f77dd5a9b9c13c67df3bd5b/test/e2e/plain_provisioner_test.go#L697
}) var _ = Describe("plain provisioner bundleinstance", func() { Context("embedded bundle template", func() { var ( bi *rukpakv1alpha1.BundleInstance ctx context.Context ) BeforeEach(func() { ctx = context.Background() bi = &rukpakv1alpha1.BundleInstance{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "olm-crds", }, Spec: rukpakv1alpha1.BundleInstanceSpec{ ProvisionerClassName: provisioner.PlainID, Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ "app.kubernetes.io/name": "olm-crds", }, }, Template: &rukpakv1alpha1.BundleTemplate{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/name": "olm-crds", }, }, Spec: rukpakv1alpha1.BundleSpec{ ProvisionerClassName: provisioner.PlainID, Source: rukpakv1alpha1.BundleSource{ Type: rukpakv1alpha1.SourceTypeImage, Image: &rukpakv1alpha1.ImageSource{ Ref: "testdata/bundles/plain-v0:valid", }, }, }, }, }, } err := c.Create(ctx, bi) Expect(err).To(BeNil()) }) AfterEach(func() { By("deleting the testing BI resource") Expect(c.Delete(ctx, bi)).To(BeNil()) }) It("should generate a Bundle that contains an owner reference", func() { // Note: cannot use bi.GroupVersionKind() as the Kind/APIVersion fields // will be empty during the testing suite. biRef := metav1.NewControllerRef(bi, rukpakv1alpha1.BundleInstanceGVK) Eventually(func() []metav1.OwnerReference { if err := c.Get(ctx, client.ObjectKeyFromObject(bi), bi); err != nil { return nil } b := &rukpakv1alpha1.Bundle{} if err := c.Get(ctx, types.NamespacedName{Name: bi.Status.InstalledBundleName}, b); err != nil { return nil } return b.GetOwnerReferences() }).Should(And( Not(BeNil()), ContainElement(*biRef)), ) }) // TODO: spec.Selector cannot be different than spec.Template.Metadata.Labels? It("should generate a Bundle that contains the correct labels", func() { Eventually(func() map[string]string { if err := c.Get(ctx, client.ObjectKeyFromObject(bi), bi); err != nil { return nil } b := &rukpakv1alpha1.Bundle{} if err := c.Get(ctx, types.NamespacedName{Name: bi.Status.InstalledBundleName}, b); err != nil { return nil } return b.Labels }).Should(And( Not(BeNil()), Equal(bi.Spec.Selector.MatchLabels)), ) }) When("a bundle template is updated", func() { var ( originalBundle *rukpakv1alpha1.Bundle ) BeforeEach(func() { originalBundle = &rukpakv1alpha1.Bundle{} Eventually(func() error { if err := c.Get(ctx, client.ObjectKeyFromObject(bi), bi); err != nil { return err } if err := c.Get(ctx, types.NamespacedName{Name: bi.Status.InstalledBundleName}, originalBundle); err != nil { return err } // Note: if we need to test spec changes are respected, then we can build up a git-based Bundle // that references the combo repository and toggle between the main branch and the v0.0.2 tag. bi.Spec.Template.Labels["e2e-test"] = "stub" return c.Update(ctx, bi) }).Should(Succeed()) }) It("should generate a new Bundle resource that matches the desired specification", func() { Eventually(func() bool { if err := c.Get(ctx, client.ObjectKeyFromObject(bi), bi); err != nil { return false } currBundle := &rukpakv1alpha1.Bundle{} if err := c.Get(ctx, types.NamespacedName{Name: bi.Status.InstalledBundleName}, currBundle); err != nil { return false } return util.CheckDesiredBundleTemplate(currBundle, bi.Spec.Template) }).Should(BeTrue()) }) It("should delete the old Bundle once the newly generated Bundle reports a successful installation state", func() { By("waiting until the BI reports a successful installation") Eventually(func() (*metav1.Condition, error) { if err := c.Get(ctx, client.ObjectKeyFromObject(bi), bi); err != nil { return nil, err } return meta.FindStatusCondition(bi.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil }).Should(And( Not(BeNil()), WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallationSucceeded)), WithTransform(func(c *metav1.Condition) string { return c.Message }, Equal("")), )) By("verifying that the old Bundle no longer exists") Eventually(func() error { return c.Get(ctx, client.ObjectKeyFromObject(originalBundle), &rukpakv1alpha1.Bundle{}) }).Should(WithTransform(apierrors.IsNotFound, BeTrue())) }) }) }) When("a BundleInstance targets a valid Bundle", func() { var ( bi *rukpakv1alpha1.BundleInstance ctx context.Context ) BeforeEach(func() { ctx = context.Background() bi = &rukpakv1alpha1.BundleInstance{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "olm-crds", }, Spec: rukpakv1alpha1.BundleInstanceSpec{ ProvisionerClassName: provisioner.PlainID, Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ "app.kubernetes.io/name": "olm-crds", }, }, Template: &rukpakv1alpha1.BundleTemplate{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/name": "olm-crds", }, }, Spec: rukpakv1alpha1.BundleSpec{ ProvisionerClassName: provisioner.PlainID, Source: rukpakv1alpha1.BundleSource{ Type: rukpakv1alpha1.SourceTypeImage, Image: &rukpakv1alpha1.ImageSource{ Ref: "testdata/bundles/plain-v0:valid", }, }, }, }, }, } err := c.Create(ctx, bi) Expect(err).To(BeNil()) }) AfterEach(func() { By("deleting the testing BI resource") Expect(c.Delete(ctx, bi)).To(BeNil()) }) It("should rollout the bundle contents successfully", func() { By("eventually writing a successful installation state back to the bundleinstance status") Eventually(func() (*metav1.Condition, error) { if err := c.Get(ctx, client.ObjectKeyFromObject(bi), bi); err != nil { return nil, err } return meta.FindStatusCondition(bi.Status.Conditions, rukpakv1alpha1.TypeInstalled), nil }).Should(And( Not(BeNil()), WithTransform(func(c *metav1.Condition) string { return c.Type }, Equal(rukpakv1alpha1.TypeInstalled)), WithTransform(func(c *metav1.Condition) metav1.ConditionStatus { return c.Status }, Equal(metav1.ConditionTrue)), WithTransform(func(c *metav1.Condition) string { return c.Reason }, Equal(rukpakv1alpha1.ReasonInstallationSucceeded)), WithTransform(func(c *metav1.Condition) string { return c.Message }, Equal("")), )) }) }) When("a BundleInstance targets an invalid Bundle", func() { var ( bi *rukpakv1alpha1.BundleInstance ctx context.Context ) BeforeEach(func() { ctx = context.Background() bi = &rukpakv1alpha1.BundleInstance{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "olm-apis", }, Spec: rukpakv1alpha1.BundleInstanceSpec{ ProvisionerClassName: provisioner.PlainID, Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ "app.kubernetes.io/name": "olm-apis", }, }, Template: &rukpakv1alpha1.BundleTemplate{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/name": "olm-apis", }, }, Spec: rukpakv1alpha1.BundleSpec{ ProvisionerClassName: provisioner.PlainID, Source: rukpakv1alpha1.BundleSource{ Type: rukpakv1alpha1.SourceTypeImage, Image: &rukpakv1alpha1.ImageSource{ Ref: "testdata/bundles/plain-v0:invalid-missing-crds", }, }, }, }, }, } err := c.Create(ctx, bi) Expect(err).To(BeNil()) }) AfterEach(func() { By("deleting the testing BundleInstance resource") Eventually(func() error { return client.IgnoreNotFound(c.Delete(ctx, bi))
Closed in 038b29172a225f7faf214e70bbd9e3bbee7d4a90
that references the combo repository and toggle between the main branch and the v0.0.2 tag.
https://github.com/timflannagan/rukpak/blob/6a85dab6a45117569f77dd5a9b9c13c67df3bd5b/test/e2e/plain_provisioner_test.go#L697