Skip to content

Commit 0df128b

Browse files
committed
add test to verify error clears on correct update
Signed-off-by: Anik Bhattacharjee <[email protected]>
1 parent eb24011 commit 0df128b

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

Diff for: pkg/controller/operators/catalog/operator.go

-4
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,6 @@ func (o *Operator) syncRegistryServer(logger *logrus.Entry, in *v1alpha1.Catalog
730730
if out.Spec.UpdateStrategy.RegistryPoll != nil {
731731
if out.Spec.UpdateStrategy.RegistryPoll.ParsingError != "" && out.Status.Reason != v1alpha1.CatalogSourceIntervalInvalidError {
732732
out.SetError(v1alpha1.CatalogSourceIntervalInvalidError, fmt.Errorf(out.Spec.UpdateStrategy.RegistryPoll.ParsingError))
733-
if _, err := o.client.OperatorsV1alpha1().CatalogSources(out.GetNamespace()).UpdateStatus(context.TODO(), out, metav1.UpdateOptions{}); err != nil {
734-
logger.Errorf("error while updating catalogsource status for an invalid interval - %v", err)
735-
return
736-
}
737733
}
738734
logger.Debugf("requeuing registry server sync based on polling interval %s", out.Spec.UpdateStrategy.Interval.Duration.String())
739735
resyncPeriod := reconciler.SyncRegistryUpdateInterval(out, time.Now())

Diff for: test/e2e/catalog_e2e_test.go

+32-3
Original file line numberDiff line numberDiff line change
@@ -1146,12 +1146,14 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
11461146

11471147
})
11481148

1149-
When("A catalogSource is created with incorrect interval", func() {
1149+
FWhen("A catalogSource is created with incorrect interval", func() {
11501150

1151-
var source *v1alpha1.CatalogSource
1151+
var (
1152+
source *v1alpha1.CatalogSource
1153+
sourceName = genName("catalog-")
1154+
)
11521155

11531156
BeforeEach(func() {
1154-
sourceName := genName("catalog-")
11551157
source = &v1alpha1.CatalogSource{
11561158
TypeMeta: metav1.TypeMeta{
11571159
Kind: v1alpha1.CatalogSourceKind,
@@ -1189,6 +1191,33 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
11891191
}
11901192
return false
11911193
}).Should(BeTrue())
1194+
1195+
When("the catalogsource is updated with a valid polling interval", func() {
1196+
BeforeEach(func() {
1197+
catsrc, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
1198+
Expect(err).ToNot(HaveOccurred())
1199+
catsrc.Spec.UpdateStrategy.RegistryPoll.RawInterval = "45m"
1200+
_, err = crc.OperatorsV1alpha1().CatalogSources(catsrc.GetNamespace()).Update(context.TODO(), catsrc, metav1.UpdateOptions{})
1201+
Expect(err).ToNot(HaveOccurred())
1202+
})
1203+
It("the catalogsource spec shows the updated polling interval, and the error message in the status is cleared", func() {
1204+
Eventually(func() error {
1205+
catsrc, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
1206+
if err != nil {
1207+
return err
1208+
}
1209+
expectedTime, err := time.ParseDuration("45m")
1210+
if err != nil {
1211+
return err
1212+
}
1213+
if catsrc.Status.Reason != "" || (catsrc.Spec.UpdateStrategy.Interval != &metav1.Duration{expectedTime}) {
1214+
return err
1215+
}
1216+
return nil
1217+
1218+
}).Should(Succeed())
1219+
})
1220+
})
11921221
})
11931222
})
11941223

0 commit comments

Comments
 (0)