Skip to content

Commit e56578d

Browse files
Srihari1192ntkathole
authored andcommitted
test:Add cron job check for e2e test runTestDeploySimpleCRFunc
Signed-off-by: Srihari <svenkata@redhat.com>
1 parent 97b0f25 commit e56578d

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,27 @@ func checkIfKubernetesServiceExists(namespace, serviceName string) error {
176176
return nil
177177
}
178178

179+
// validates if a CronJob exists using the kubectl CLI.
180+
func checkIfCronJobExists(namespace, cronJobName string) error {
181+
cmd := exec.Command("kubectl", "get", "cronjob", cronJobName, "-n", namespace)
182+
183+
var out bytes.Buffer
184+
var stderr bytes.Buffer
185+
cmd.Stdout = &out
186+
cmd.Stderr = &stderr
187+
188+
if err := cmd.Run(); err != nil {
189+
return fmt.Errorf("failed to find CronJob %s in namespace %s. Error: %v. Stderr: %s",
190+
cronJobName, namespace, err, stderr.String())
191+
}
192+
193+
if !strings.Contains(out.String(), cronJobName) {
194+
return fmt.Errorf("CronJob %s not found in namespace %s", cronJobName, namespace)
195+
}
196+
197+
return nil
198+
}
199+
179200
func isFeatureStoreHavingRemoteRegistry(namespace, featureStoreName string) (bool, error) {
180201
timeout := 5 * time.Minute
181202
interval := time.Second * 2 // Poll every 2 seconds
@@ -288,6 +309,14 @@ func validateTheFeatureStoreCustomResource(namespace string, featureStoreName st
288309
fmt.Printf("kubernetes service %s is available\n", serviceName)
289310
}
290311

312+
By(fmt.Sprintf("validate the feast CronJob: %s exists.", feastResourceName))
313+
err = checkIfCronJobExists(namespace, feastResourceName)
314+
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf(
315+
"CronJob %s does not exist in namespace %s. Error: %v",
316+
feastResourceName, namespace, err,
317+
))
318+
fmt.Printf("CronJob %s exists in namespace %s\n", feastResourceName, namespace)
319+
291320
By(fmt.Sprintf("Checking FeatureStore customer resource: %s is in Ready Status.", featureStoreName))
292321
err = checkIfFeatureStoreCustomResourceConditionsInReady(featureStoreName, namespace)
293322
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf(

0 commit comments

Comments
 (0)