Skip to content

Commit daecd4e

Browse files
committed
fix: Fix polling mechanism for TestApplyAndMaterialize
Signed-off-by: Srihari <svenkata@redhat.com>
1 parent 12bed6d commit daecd4e

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

infra/feast-operator/test/utils/test_util.go

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -596,13 +596,18 @@ func TrainAndTestModel(namespace string, feastCRName string, feastDeploymentName
596596
fmt.Println("Patched FeatureStore with train/test commands")
597597

598598
By("Validating patch was applied correctly")
599-
cmd = exec.Command("kubectl", "get", "feast/"+feastCRName, "-n", namespace, "-o", "jsonpath={.status.applied.cronJob.containerConfigs.commands}")
600-
output, err := Run(cmd, testDir)
601-
ExpectWithOffset(1, err).NotTo(HaveOccurred())
602-
outputStr := string(output)
603-
Expect(outputStr).To(ContainSubstring("pip install -r ../requirements.txt"))
604-
Expect(outputStr).To(ContainSubstring("python run.py"))
605-
fmt.Print("FeatureStore patched correctly with commands", outputStr)
599+
600+
Eventually(func() string {
601+
cmd := exec.Command("kubectl", "get", "feast/"+feastCRName, "-n", namespace, "-o", "jsonpath={.status.applied.cronJob.containerConfigs.commands}")
602+
output, _ := Run(cmd, testDir)
603+
return string(output)
604+
}, "30s", "3s").Should(
605+
And(
606+
ContainSubstring("pip install -r ../requirements.txt"),
607+
ContainSubstring("python run.py"),
608+
),
609+
)
610+
fmt.Println("FeatureStore patched correctly with commands")
606611

607612
By("Creating Job from CronJob")
608613
CreateAndVerifyJobFromCron(namespace, feastDeploymentName, "feast-test-job", testDir, []string{"Loan rejected!"})
@@ -616,7 +621,7 @@ func CreateAndVerifyJobFromCron(namespace, cronName, jobName, testDir string, ex
616621
ExpectWithOffset(1, err).NotTo(HaveOccurred())
617622

618623
By("Waiting for Job completion")
619-
cmd = exec.Command("kubectl", "wait", "--for=condition=complete", "--timeout=3m", "job/"+jobName, "-n", namespace)
624+
cmd = exec.Command("kubectl", "wait", "--for=condition=complete", "--timeout=5m", "job/"+jobName, "-n", namespace)
620625
_, err = Run(cmd, testDir)
621626
ExpectWithOffset(1, err).NotTo(HaveOccurred())
622627

@@ -631,6 +636,7 @@ func CreateAndVerifyJobFromCron(namespace, cronName, jobName, testDir string, ex
631636
for _, expected := range expectedLogSubstrings {
632637
Expect(outputStr).To(ContainSubstring(expected))
633638
}
639+
fmt.Printf("created Job %s and Verified expected Logs ", jobName)
634640
}
635641

636642
// verifies the specified deployment exists and is in the "Available" state.
@@ -645,11 +651,16 @@ func checkDeployment(namespace, name string) {
645651

646652
// validate that the status of the FeatureStore CR is "Ready".
647653
func validateFeatureStoreCRStatus(namespace, crName string) {
648-
cmd := exec.Command("kubectl", "get", "feast", crName, "-n", namespace, "-o", "jsonpath={.status.phase}")
649-
output, err := cmd.Output()
650-
Expect(err).ToNot(HaveOccurred(), "failed to get Feature Store CR status")
651-
Expect(string(output)).To(Equal("Ready"))
652-
fmt.Printf("Feature Store CR is in %s state\n", output)
654+
Eventually(func() string {
655+
cmd := exec.Command("kubectl", "get", "feast", crName, "-n", namespace, "-o", "jsonpath={.status.phase}")
656+
output, err := cmd.Output()
657+
if err != nil {
658+
return ""
659+
}
660+
return string(output)
661+
}, "2m", "5s").Should(Equal("Ready"), "Feature Store CR did not reach 'Ready' state in time")
662+
663+
fmt.Printf("✅ Feature Store CR %s/%s is in Ready state\n", namespace, crName)
653664
}
654665

655666
// validate the feature store yaml

0 commit comments

Comments
 (0)