-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle channelName #172
Handle channelName #172
Changes from 2 commits
2efcc9d
4ddf729
1493163
5067bfc
a93f137
1c538f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,7 @@ var _ = Describe("Operator Controller Test", func() { | |
var pkgName string | ||
BeforeEach(func() { | ||
By("initializing cluster state") | ||
pkgName = fmt.Sprintf("exists-%s", rand.String(6)) | ||
pkgName = "prometheus" | ||
operator = &operatorsv1alpha1.Operator{ | ||
ObjectMeta: metav1.ObjectMeta{Name: opKey.Name}, | ||
Spec: operatorsv1alpha1.OperatorSpec{ | ||
|
@@ -594,6 +594,80 @@ var _ = Describe("Operator Controller Test", func() { | |
}) | ||
|
||
}) | ||
When("the operator specifies a channel that exist", func() { | ||
var pkgName string | ||
var pkgVer string | ||
var pkgChan string | ||
BeforeEach(func() { | ||
By("initializing cluster state") | ||
pkgName = "prometheus" | ||
pkgVer = "0.47.0" | ||
pkgChan = "beta" | ||
operator = &operatorsv1alpha1.Operator{ | ||
ObjectMeta: metav1.ObjectMeta{Name: opKey.Name}, | ||
Spec: operatorsv1alpha1.OperatorSpec{ | ||
PackageName: pkgName, | ||
Version: pkgVer, | ||
Channel: pkgChan, | ||
}, | ||
} | ||
err := cl.Create(ctx, operator) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
It("sets resolution success status", func() { | ||
By("running reconcile") | ||
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey}) | ||
Expect(res).To(Equal(ctrl.Result{})) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
By("fetching updated operator after reconcile") | ||
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred()) | ||
|
||
By("checking the expected conditions") | ||
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) | ||
Expect(cond).NotTo(BeNil()) | ||
Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) | ||
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInstallationStatusUnknown)) | ||
Expect(cond.Message).To(ContainSubstring("waiting for BundleDeployment")) | ||
}) | ||
}) | ||
When("the operator specifies a channel that does not exist", func() { | ||
var pkgName string | ||
var pkgVer string | ||
var pkgChan string | ||
BeforeEach(func() { | ||
By("initializing cluster state") | ||
pkgName = "prometheus" | ||
pkgVer = "0.47.0" | ||
pkgChan = "alpha" | ||
operator = &operatorsv1alpha1.Operator{ | ||
ObjectMeta: metav1.ObjectMeta{Name: opKey.Name}, | ||
Spec: operatorsv1alpha1.OperatorSpec{ | ||
PackageName: pkgName, | ||
Version: pkgVer, | ||
Channel: pkgChan, | ||
}, | ||
} | ||
err := cl.Create(ctx, operator) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
It("sets resolution failure status", func() { | ||
By("running reconcile") | ||
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey}) | ||
Expect(res).To(Equal(ctrl.Result{})) | ||
Expect(err).To(MatchError(fmt.Sprintf("package '%s' at version '%s' not found", pkgName, pkgVer))) | ||
|
||
By("fetching updated operator after reconcile") | ||
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred()) | ||
|
||
By("checking the expected conditions") | ||
cond := apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeReady) | ||
Expect(cond).NotTo(BeNil()) | ||
Expect(cond.Status).To(Equal(metav1.ConditionFalse)) | ||
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) | ||
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '%s' not found", pkgName, pkgVer))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a confusing message. The version exists, but just not in this channel. Do we need to update the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I though the message ought to include the channel as well, that might require updating other tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on how We should handle both being set as well and try to come up with a coherent message in that case, but again, not super concerned with that in this particular PR. Do it if it's easy, but if handling it seems hard or contentious, then add a TODO comment and GH issue and move on without it. My two cents at least. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
}) | ||
}) | ||
AfterEach(func() { | ||
verifyInvariants(ctx, operator) | ||
|
||
|
@@ -648,7 +722,7 @@ var _ = Describe("Operator Controller Test", func() { | |
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonInvalidSpec)) | ||
Expect(cond.Message).To(Equal("invalid .spec.version: Invalid character(s) found in prerelease \"123abc_def\"")) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
func verifyInvariants(ctx context.Context, op *operatorsv1alpha1.Operator) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we leave the version unset for the base
spec.channel
tests so we can isolate the behavior we're expecting and avoid side effects from setting the version?(We should probably also have tests where both are set to test for interactions, but I think that's outside the scope of this PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's easy enough to copy/paste the test w/o the package version.