Skip to content

Commit b512a74

Browse files
authored
fix: Fix polling mechanism for TestApplyAndMaterialize (#5451)
Signed-off-by: Srihari <[email protected]>
1 parent 12bed6d commit b512a74

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

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

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ func TrainAndTestModel(namespace string, feastCRName string, feastDeploymentName
583583
"cronJob": {
584584
"containerConfigs": {
585585
"commands": [
586-
"pip install -r ../requirements.txt",
586+
"pip install jupyter==1.1.1 scikit-learn==1.5.2 matplotlib==3.9.2 seaborn==0.13.2 joblib",
587587
"cd ../ && python run.py"
588588
]
589589
}
@@ -596,13 +596,17 @@ 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("python run.py"),
607+
),
608+
)
609+
fmt.Println("FeatureStore patched correctly with commands")
606610

607611
By("Creating Job from CronJob")
608612
CreateAndVerifyJobFromCron(namespace, feastDeploymentName, "feast-test-job", testDir, []string{"Loan rejected!"})
@@ -616,7 +620,7 @@ func CreateAndVerifyJobFromCron(namespace, cronName, jobName, testDir string, ex
616620
ExpectWithOffset(1, err).NotTo(HaveOccurred())
617621

618622
By("Waiting for Job completion")
619-
cmd = exec.Command("kubectl", "wait", "--for=condition=complete", "--timeout=3m", "job/"+jobName, "-n", namespace)
623+
cmd = exec.Command("kubectl", "wait", "--for=condition=complete", "--timeout=5m", "job/"+jobName, "-n", namespace)
620624
_, err = Run(cmd, testDir)
621625
ExpectWithOffset(1, err).NotTo(HaveOccurred())
622626

@@ -631,6 +635,7 @@ func CreateAndVerifyJobFromCron(namespace, cronName, jobName, testDir string, ex
631635
for _, expected := range expectedLogSubstrings {
632636
Expect(outputStr).To(ContainSubstring(expected))
633637
}
638+
fmt.Printf("created Job %s and Verified expected Logs ", jobName)
634639
}
635640

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

646651
// validate that the status of the FeatureStore CR is "Ready".
647652
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)
653+
Eventually(func() string {
654+
cmd := exec.Command("kubectl", "get", "feast", crName, "-n", namespace, "-o", "jsonpath={.status.phase}")
655+
output, err := cmd.Output()
656+
if err != nil {
657+
return ""
658+
}
659+
return string(output)
660+
}, "2m", "5s").Should(Equal("Ready"), "Feature Store CR did not reach 'Ready' state in time")
661+
662+
fmt.Printf("✅ Feature Store CR %s/%s is in Ready state\n", namespace, crName)
653663
}
654664

655665
// validate the feature store yaml

0 commit comments

Comments
 (0)