Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/e2e/epp/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func setupInfra() {
if strings.Contains(modelServerManifestArray[0], "hf-token") {
createHfSecret(testConfig, modelServerSecretManifest)
}
testutils.CreateCrdsFromKustomize(testConfig, crdKustomizePath)
testutils.ProcessKustomize(testConfig, crdKustomizePath, testutils.CreateAndVerifyObjs)
testutils.ValidateCRDsEstablished(testConfig, expectedCRDs)

inferExtManifestPath := inferExtManifestDefault
Expand Down
51 changes: 29 additions & 22 deletions test/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,7 @@ func DeleteClusterResources(testConfig *TestConfig) error {
if err != nil && !apierrors.IsNotFound(err) {
return err
}
model := &apiextv1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: "inferenceobjectives.inference.networking.x-k8s.io",
},
}
err = testConfig.K8sClient.Delete(testConfig.Context, model, client.PropagationPolicy(metav1.DeletePropagationForeground))
if err != nil && !apierrors.IsNotFound(err) {
return err
}
pool := &apiextv1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: "inferencepools.inference.networking.x-k8s.io",
},
}
err = testConfig.K8sClient.Delete(testConfig.Context, pool, client.PropagationPolicy(metav1.DeletePropagationForeground))
if err != nil && !apierrors.IsNotFound(err) {
return err
}
ProcessKustomize(testConfig, "../../../config/crd/", DeleteAndVerifyObjs)
return nil
}

Expand Down Expand Up @@ -411,7 +394,7 @@ func EventuallyExists(testConfig *TestConfig, getResource func() error) {
}, testConfig.ExistsTimeout, testConfig.Interval).Should(gomega.Succeed())
}

func createAndVerifyObjs(testConfig *TestConfig, objs []*unstructured.Unstructured) []string {
func CreateAndVerifyObjs(testConfig *TestConfig, objs []*unstructured.Unstructured) []string {
objNames := make([]string, 0, len(objs))
for _, unstrObj := range objs {
ginkgo.By(fmt.Sprintf("Processing GVK: %s", unstrObj.GroupVersionKind()))
Expand Down Expand Up @@ -447,7 +430,31 @@ func createAndVerifyObjs(testConfig *TestConfig, objs []*unstructured.Unstructur
return objNames
}

func CreateCrdsFromKustomize(testConfig *TestConfig, kustomizePath string) []string {
func DeleteAndVerifyObjs(testConfig *TestConfig, objs []*unstructured.Unstructured) []string {
objNames := make([]string, 0, len(objs))
for _, unstrObj := range objs {
ginkgo.By(fmt.Sprintf("Deleting GVK: %s", unstrObj.GroupVersionKind()))
unstrObj.SetNamespace(testConfig.NsName)

kind := unstrObj.GetKind()
name := unstrObj.GetName()
objNames = append(objNames, kind+"/"+name)
err := testConfig.K8sClient.Delete(testConfig.Context, unstrObj, client.PropagationPolicy(metav1.DeletePropagationForeground))
if err != nil && !apierrors.IsNotFound(err) {
gomega.Expect(err).NotTo(gomega.HaveOccurred(), fmt.Sprintf("Failed to delete %s %s", kind, name))
}

clientObj := getClientObject(kind)
gomega.Eventually(func() bool {
err := testConfig.K8sClient.Get(testConfig.Context,
types.NamespacedName{Namespace: testConfig.NsName, Name: name}, clientObj)
return apierrors.IsNotFound(err)
}, testConfig.ExistsTimeout, testConfig.Interval).Should(gomega.BeTrue(), fmt.Sprintf("Timed out waiting for %s %s to be deleted", kind, name))
}
return objNames
}

func ProcessKustomize(testConfig *TestConfig, kustomizePath string, action func(*TestConfig, []*unstructured.Unstructured) []string) []string {
ginkgo.By("Running Kustomize build on: " + kustomizePath)

fSys := filesys.MakeFsOnDisk()
Expand All @@ -465,7 +472,7 @@ func CreateCrdsFromKustomize(testConfig *TestConfig, kustomizePath string) []str
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to run kustomize get map")
objs = append(objs, &unstructured.Unstructured{Object: resMap})
}
return createAndVerifyObjs(testConfig, objs)
return action(testConfig, objs)
}

// CreateObjsFromYaml creates K8S objects from yaml and waits for them to be instantiated
Expand Down Expand Up @@ -495,7 +502,7 @@ func CreateObjsFromYaml(testConfig *TestConfig, docs []string) []string {
}
objs = append(objs, unstrObj)
}
return createAndVerifyObjs(testConfig, objs)
return CreateAndVerifyObjs(testConfig, objs)
}

// ApplyYAMLFile reads a file containing YAML (possibly multiple docs)
Expand Down
Loading