Skip to content

Commit

Permalink
Add GinkgoHelper to the helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
mociarain committed Feb 6, 2024
1 parent 48dd855 commit c62550c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type K8sDeleteFunc func(ctx context.Context, name string, options metav1.DeleteO
func GetK8sObjectWithRetry[T kruntime.Object](
ctx context.Context, getFunc K8sGetFunc[T], name string, options metav1.GetOptions,
) (result T, err error) {
GinkgoHelper()
Eventually(func(g Gomega, ctx context.Context) {
g.Expect(err).NotTo(HaveOccurred())
}).WithContext(ctx).WithTimeout(DefaultTimeout).WithPolling(PollingInterval).Should(Succeed())
Expand All @@ -48,6 +49,7 @@ func GetK8sObjectWithRetry[T kruntime.Object](
func GetK8sPodLogsWithRetry(
ctx context.Context, namespace string, name string, options corev1.PodLogOptions,
) (rawBody string) {
GinkgoHelper()
Eventually(func(g Gomega, ctx context.Context) {
body, err := clients.Kubernetes.CoreV1().Pods(namespace).GetLogs(name, &options).DoRaw(ctx)
g.Expect(err).NotTo(HaveOccurred())
Expand All @@ -62,6 +64,7 @@ func GetK8sPodLogsWithRetry(
func ListK8sObjectWithRetry[T kruntime.Object](
ctx context.Context, listFunc K8sListFunc[T], options metav1.ListOptions,
) T {
GinkgoHelper()
var object T
Eventually(func(g Gomega, ctx context.Context) {
result, err := listFunc(ctx, options)
Expand All @@ -77,6 +80,7 @@ func ListK8sObjectWithRetry[T kruntime.Object](
func CreateK8sObjectWithRetry[T kruntime.Object](
ctx context.Context, createFunc K8sCreateFunc[T], obj T, options metav1.CreateOptions,
) T {
GinkgoHelper()
var object T
Eventually(func(g Gomega, ctx context.Context) {
result, err := createFunc(ctx, obj, options)
Expand All @@ -91,6 +95,7 @@ func CreateK8sObjectWithRetry[T kruntime.Object](
func DeleteK8sObjectWithRetry(
ctx context.Context, deleteFunc K8sDeleteFunc, name string, options metav1.DeleteOptions,
) (err error) {
GinkgoHelper()
Eventually(func(g Gomega, ctx context.Context) {
err := deleteFunc(ctx, name, options)
g.Expect(err).NotTo(HaveOccurred())
Expand All @@ -110,6 +115,7 @@ type AllowedCleanUpAPIInterface[T kruntime.Object] interface {
func CleanupK8sResource[T kruntime.Object](
ctx context.Context, client AllowedCleanUpAPIInterface[T], name string,
) {
GinkgoHelper()
DefaultEventuallyTimeout = 10 * time.Minute
PollingInterval = 1 * time.Second
err := DeleteK8sObjectWithRetry(
Expand Down

0 comments on commit c62550c

Please sign in to comment.