|
| 1 | +/* |
| 2 | +Copyright 2025 Feast Community. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +// Package e2erhoai provides end-to-end (E2E) test coverage for Feast integration with |
| 18 | +// Red Hat OpenShift AI (RHOAI) environments. |
| 19 | +// This specific test validates the functionality |
| 20 | +// of executing a Feast workbench integration connection with kubernetes auth and without auth successfully |
| 21 | +package e2erhoai |
| 22 | + |
| 23 | +import ( |
| 24 | + "fmt" |
| 25 | + |
| 26 | + utils "github.com/feast-dev/feast/infra/feast-operator/test/utils" |
| 27 | + . "github.com/onsi/ginkgo/v2" |
| 28 | + . "github.com/onsi/gomega" |
| 29 | +) |
| 30 | + |
| 31 | +var _ = Describe("Feast Workbench Integration Connection Testing", Ordered, func() { |
| 32 | + const ( |
| 33 | + namespace = "test-ns-feast" |
| 34 | + configMapName = "feast-wb-cm" |
| 35 | + rolebindingName = "rb-feast-test" |
| 36 | + notebookFile = "test/e2e_rhoai/resources/feast-wb-connection-credit-scoring.ipynb" |
| 37 | + pvcFile = "test/e2e_rhoai/resources/pvc.yaml" |
| 38 | + permissionFile = "test/e2e_rhoai/resources/permissions.py" |
| 39 | + notebookPVC = "jupyterhub-nb-kube-3aadmin-pvc" |
| 40 | + testDir = "/test/e2e_rhoai" |
| 41 | + notebookName = "feast-wb-connection-credit-scoring.ipynb" |
| 42 | + feastDeploymentName = utils.FeastPrefix + "credit-scoring" |
| 43 | + feastCRName = "credit-scoring" |
| 44 | + ) |
| 45 | + |
| 46 | + // Create and monitor notebook |
| 47 | + createAndMonitorNotebook := func() { |
| 48 | + nbParams := utils.GetNotebookParams(namespace, configMapName, notebookPVC, notebookName, testDir) |
| 49 | + By("Creating Jupyter Notebook") |
| 50 | + Expect(utils.CreateNotebook(nbParams)).To(Succeed(), "Failed to create notebook") |
| 51 | + |
| 52 | + By("Monitoring notebook logs") |
| 53 | + Expect(utils.MonitorNotebookPod(namespace, "jupyter-nb-", notebookName)).To(Succeed(), "Notebook execution failed") |
| 54 | + } |
| 55 | + |
| 56 | + // Parameterized test function that handles both auth and non-auth scenarios |
| 57 | + runFeastWorkbenchIntegration := func(authEnabled bool) { |
| 58 | + // Apply permissions only if auth is enabled |
| 59 | + if authEnabled { |
| 60 | + By("Applying Feast permissions for kubernetes authenticated scenario") |
| 61 | + utils.ApplyFeastPermissions(permissionFile, "/feast-data/credit_scoring_local/feature_repo/permissions.py", namespace, feastDeploymentName) |
| 62 | + } |
| 63 | + |
| 64 | + By(fmt.Sprintf("Setting namespace context to : %s", namespace)) |
| 65 | + Expect(utils.SetNamespaceContext(namespace, testDir)).To(Succeed()) |
| 66 | + fmt.Printf("Successfully set namespace context to: %s\n", namespace) |
| 67 | + |
| 68 | + By(fmt.Sprintf("Creating Config map: %s", configMapName)) |
| 69 | + Expect(utils.CreateNotebookConfigMap(namespace, configMapName, notebookFile, "test/e2e_rhoai/resources/feature_repo", testDir)).To(Succeed()) |
| 70 | + fmt.Printf("ConfigMap %s created successfully\n", configMapName) |
| 71 | + |
| 72 | + By(fmt.Sprintf("Creating Persistent volume claim: %s", notebookPVC)) |
| 73 | + Expect(utils.CreateNotebookPVC(pvcFile, testDir)).To(Succeed()) |
| 74 | + fmt.Printf("Persistent Volume Claim %s created successfully\n", notebookPVC) |
| 75 | + |
| 76 | + By(fmt.Sprintf("Creating rolebinding %s for the user", rolebindingName)) |
| 77 | + Expect(utils.CreateNotebookRoleBinding(namespace, rolebindingName, utils.GetOCUser(testDir), testDir)).To(Succeed()) |
| 78 | + fmt.Printf("Created rolebinding %s successfully\n", rolebindingName) |
| 79 | + |
| 80 | + // Create and monitor notebook for execution status |
| 81 | + createAndMonitorNotebook() |
| 82 | + } |
| 83 | + |
| 84 | + BeforeAll(func() { |
| 85 | + By(fmt.Sprintf("Creating test namespace: %s", namespace)) |
| 86 | + Expect(utils.CreateNamespace(namespace, testDir)).To(Succeed()) |
| 87 | + fmt.Printf("Namespace %s created successfully\n", namespace) |
| 88 | + |
| 89 | + By("Applying Feast infra manifests and verifying setup") |
| 90 | + utils.ApplyFeastInfraManifestsAndVerify(namespace, testDir) |
| 91 | + }) |
| 92 | + |
| 93 | + AfterAll(func() { |
| 94 | + By(fmt.Sprintf("Deleting test namespace: %s", namespace)) |
| 95 | + Expect(utils.DeleteNamespace(namespace, testDir)).To(Succeed()) |
| 96 | + fmt.Printf("Namespace %s deleted successfully\n", namespace) |
| 97 | + }) |
| 98 | + |
| 99 | + Context("Feast Workbench Integration Tests - Without Auth", func() { |
| 100 | + BeforeEach(func() { |
| 101 | + By("Applying and validating the credit-scoring FeatureStore CR without auth") |
| 102 | + utils.ApplyFeastYamlAndVerify(namespace, testDir, feastDeploymentName, feastCRName, "test/testdata/feast_integration_test_crs/feast.yaml") |
| 103 | + |
| 104 | + By("Verify Feature Store CR is in Ready state") |
| 105 | + utils.ValidateFeatureStoreCRStatus(namespace, feastCRName) |
| 106 | + |
| 107 | + By("Running `feast apply` and `feast materialize-incremental` to validate registry definitions") |
| 108 | + utils.VerifyApplyFeatureStoreDefinitions(namespace, feastCRName, feastDeploymentName) |
| 109 | + }) |
| 110 | + |
| 111 | + It("Should create and run a FeastWorkbenchIntegrationWithoutAuth scenario successfully", func() { |
| 112 | + runFeastWorkbenchIntegration(false) |
| 113 | + }) |
| 114 | + }) |
| 115 | + |
| 116 | + Context("Feast Workbench Integration Tests - With Auth", func() { |
| 117 | + BeforeEach(func() { |
| 118 | + By("Applying and validating the credit-scoring FeatureStore CR (with auth)") |
| 119 | + utils.ApplyFeastYamlAndVerify(namespace, testDir, feastDeploymentName, feastCRName, "test/e2e_rhoai/resources/feast_kube_auth.yaml") |
| 120 | + |
| 121 | + By("Verify Feature Store CR is in Ready state") |
| 122 | + utils.ValidateFeatureStoreCRStatus(namespace, feastCRName) |
| 123 | + |
| 124 | + By("Running `feast apply` and `feast materialize-incremental` to validate registry definitions") |
| 125 | + utils.VerifyApplyFeatureStoreDefinitions(namespace, feastCRName, feastDeploymentName) |
| 126 | + }) |
| 127 | + |
| 128 | + It("Should create and run a FeastWorkbenchIntegrationWithAuth scenario successfully", func() { |
| 129 | + runFeastWorkbenchIntegration(true) |
| 130 | + }) |
| 131 | + }) |
| 132 | +}) |
0 commit comments