Skip to content

Commit

Permalink
[SAPBTPCFS-7876] Optimize handling of non-transient errors
Browse files Browse the repository at this point in the history
  • Loading branch information
I065450 committed Dec 11, 2023
1 parent cb31706 commit e5d8601
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/v1/serviceinstance_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,14 @@ var _ = Describe("Service Instance Type Test", func() {
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("cannot be a future timestamp"))
})
It("validate annotation exist and valid", func() {

annotation := map[string]string{
api.IgnoreNonTransientErrorAnnotation: "true",
api.IgnoreNonTransientErrorTimestampAnnotation: time.Now().Format(time.RFC3339),
}
instance.SetAnnotations(annotation)
exist := instance.IsIgnoreNonTransientAnnotationExistAndValid(serviceinstancelog, time.Hour)
Expect(exist).To(BeTrue())
})
})
33 changes: 33 additions & 0 deletions api/v1alpha1/serviceinstance_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"time"
)

var _ = Describe("Service Instance Type Test", func() {
var instance *ServiceInstance
var serviceinstancelog = logf.Log.WithName("serviceinstance-resource")

BeforeEach(func() {
instance = getInstance()
conditions := instance.GetConditions()
Expand Down Expand Up @@ -121,4 +125,33 @@ var _ = Describe("Service Instance Type Test", func() {
instance.SetStatus(status)
Expect(instance.GetStatus()).To(Equal(status))
})

It("should update annotation", func() {
annotation := map[string]string{
api.IgnoreNonTransientErrorAnnotation: "true",
}
instance.SetAnnotations(annotation)
Expect(instance.GetAnnotations()).To(Equal(annotation))
})

It("validate timestamp annotation- not date", func() {

annotation := map[string]string{
api.IgnoreNonTransientErrorAnnotation: "true",
api.IgnoreNonTransientErrorTimestampAnnotation: "true",
}
instance.SetAnnotations(annotation)
exist := instance.IsIgnoreNonTransientAnnotationExistAndValid(serviceinstancelog, time.Hour)
Expect(exist).To(BeFalse())
})
It("validate annotation exist and valid", func() {

annotation := map[string]string{
api.IgnoreNonTransientErrorAnnotation: "true",
api.IgnoreNonTransientErrorTimestampAnnotation: time.Now().Format(time.RFC3339),
}
instance.SetAnnotations(annotation)
exist := instance.IsIgnoreNonTransientAnnotationExistAndValid(serviceinstancelog, time.Hour)
Expect(exist).To(BeTrue())
})
})

0 comments on commit e5d8601

Please sign in to comment.