From 2af6142f053173cc4579a24d6f0684b39bc040ae Mon Sep 17 00:00:00 2001 From: Hongwei Liu Date: Tue, 26 Nov 2024 10:31:20 +0800 Subject: [PATCH] fix: retry when getting build PLR Signed-off-by: Hongwei Liu --- .../buildpipeline/buildpipeline_adapter_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/controller/buildpipeline/buildpipeline_adapter_test.go b/internal/controller/buildpipeline/buildpipeline_adapter_test.go index 6ce86094f..d635e6ef2 100644 --- a/internal/controller/buildpipeline/buildpipeline_adapter_test.go +++ b/internal/controller/buildpipeline/buildpipeline_adapter_test.go @@ -1033,11 +1033,14 @@ var _ = Describe("Pipeline Adapter", Ordered, func() { }) It("add pr group to the build pipelineRun annotations and labels", func() { existingBuildPLR := new(tektonv1.PipelineRun) - err := k8sClient.Get(ctx, types.NamespacedName{ - Namespace: buildPipelineRun.Namespace, - Name: buildPipelineRun.Name, - }, existingBuildPLR) - Expect(err).NotTo(HaveOccurred()) + Eventually(func() bool { + err := k8sClient.Get(ctx, types.NamespacedName{ + Namespace: buildPipelineRun.Namespace, + Name: buildPipelineRun.Name, + }, existingBuildPLR) + return err == nil + }, time.Second*10).Should(BeTrue()) + Expect(metadata.HasAnnotation(existingBuildPLR, gitops.PRGroupAnnotation)).To(BeFalse()) Expect(metadata.HasLabel(existingBuildPLR, gitops.PRGroupHashLabel)).To(BeFalse())