Skip to content

Commit e0b6204

Browse files
Abstracted the code to reuse the validations across different test cases. Incorporated the code review comments.
Signed-off-by: lrangine <19699092+lokeshrangineni@users.noreply.github.com>
1 parent 1efac3c commit e0b6204

5 files changed

Lines changed: 205 additions & 174 deletions

File tree

infra/feast-operator/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,16 @@ limitations under the License.
137137
You need a kind cluster to run the e2e tests on local(dev) environment.
138138

139139
```shell
140-
# create the default kind cluster with default configurations. If your test needs more memory or cpu please assign more compute to your docker environment.
140+
# Default kind cluster configuration is not enough to run all the pods. In my case i was using docker with colima. kind uses the cpi and memory assigned to docker.
141+
# below memory configuration worked well but if you are using other docker runtime then please increase the cpu and memory.
142+
colima start --cpu 10 --memory 15 --disk 100
143+
144+
# create the kind cluster
141145
kind create cluster
142146

147+
# set kubernetes context to the recently created kind cluster
148+
kubectl cluster-info --context kind-kind
149+
143150
# run the command from operator directory to run e2e tests.
144151
make test-e2e
145152

infra/feast-operator/test/e2e/e2e_test.go

Lines changed: 58 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,22 @@ import (
2727
"github.com/feast-dev/feast/infra/feast-operator/test/utils"
2828
)
2929

30-
const namespace = "feast-operator-system"
30+
const feastControllerNamespace = "feast-operator-system"
3131

3232
var _ = Describe("controller", Ordered, func() {
3333
BeforeAll(func() {
34-
By("installing prometheus operator")
35-
Expect(utils.InstallPrometheusOperator()).To(Succeed())
36-
37-
By("installing the cert-manager")
38-
Expect(utils.InstallCertManager()).To(Succeed())
39-
4034
By("creating manager namespace")
41-
cmd := exec.Command("kubectl", "create", "ns", namespace)
35+
cmd := exec.Command("kubectl", "create", "ns", feastControllerNamespace)
4236
_, _ = utils.Run(cmd)
4337
})
4438

4539
AfterAll(func() {
46-
By("uninstalling the Prometheus manager bundle")
47-
utils.UninstallPrometheusOperator()
48-
49-
By("uninstalling the cert-manager bundle")
50-
utils.UninstallCertManager()
51-
52-
By("removing manager namespace")
53-
cmd := exec.Command("kubectl", "delete", "ns", namespace)
54-
_, _ = utils.Run(cmd)
40+
//Add any post clean up code here.
5541
})
5642

5743
Context("Operator", func() {
5844
It("Should be able to deploy and run a default feature store CR successfully", func() {
59-
var controllerPodName string
45+
//var controllerPodName string
6046
var err error
6147

6248
// projectimage stores the name of the image used in the example
@@ -97,153 +83,78 @@ var _ = Describe("controller", Ordered, func() {
9783
_, err = utils.Run(cmd)
9884
ExpectWithOffset(1, err).NotTo(HaveOccurred())
9985

100-
By("validating that the controller-manager pod is running as expected")
101-
verifyControllerUp := func() error {
102-
// Get pod name
103-
104-
cmd = exec.Command("kubectl", "get",
105-
"pods", "-l", "control-plane=controller-manager",
106-
"-o", "go-template={{ range .items }}"+
107-
"{{ if not .metadata.deletionTimestamp }}"+
108-
"{{ .metadata.name }}"+
109-
"{{ \"\\n\" }}{{ end }}{{ end }}",
110-
"-n", namespace,
111-
)
112-
113-
podOutput, err := utils.Run(cmd)
114-
ExpectWithOffset(2, err).NotTo(HaveOccurred())
115-
podNames := utils.GetNonEmptyLines(string(podOutput))
116-
if len(podNames) != 1 {
117-
return fmt.Errorf("expect 1 controller pods running, but got %d", len(podNames))
118-
}
119-
controllerPodName = podNames[0]
120-
ExpectWithOffset(2, controllerPodName).Should(ContainSubstring("controller-manager"))
121-
122-
// Validate pod status
123-
cmd = exec.Command("kubectl", "get",
124-
"pods", controllerPodName, "-o", "jsonpath={.status.phase}",
125-
"-n", namespace,
126-
)
127-
status, err := utils.Run(cmd)
128-
ExpectWithOffset(2, err).NotTo(HaveOccurred())
129-
if string(status) != "Running" {
130-
return fmt.Errorf("controller pod in %s status", status)
131-
}
132-
return nil
133-
}
134-
EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed())
86+
timeout := 2 * time.Minute
87+
88+
controllerDeploymentName := "feast-operator-controller-manager"
89+
By("Validating that the controller-manager deployment is in available state")
90+
err = checkIfDeploymentExistsAndAvailable(feastControllerNamespace, controllerDeploymentName, timeout)
91+
Expect(err).To(BeNil(), fmt.Sprintf(
92+
"Deployment %s is not available but expected to be available. \nError: %v\n",
93+
controllerDeploymentName, err,
94+
))
95+
fmt.Printf("Feast Control Manager Deployment %s is available\n", controllerDeploymentName)
13596

13697
By("deploying the Simple Feast Custom Resource to Kubernetes")
13798
cmd = exec.Command("kubectl", "apply", "-f",
13899
"test/testdata/feast_integration_test_crs/v1alpha1_default_featurestore.yaml")
139100
_, cmdOutputerr := utils.Run(cmd)
140101
ExpectWithOffset(1, cmdOutputerr).NotTo(HaveOccurred())
141102

142-
By("validate the feast registry pod is up and running state.")
143-
verifyFeastControllerUp := func() error {
144-
// Get pod name
145-
146-
cmd := exec.Command("kubectl", "get",
147-
"pods", "-l", "feast.dev/service-type=registry",
148-
"-o", "go-template={{ range .items }}"+
149-
"{{ if not .metadata.deletionTimestamp }}"+
150-
"{{ .metadata.name }}"+
151-
"{{ \"\\n\" }}{{ end }}{{ end }}",
152-
"-n", "default",
153-
)
154-
155-
podOutput, err := utils.Run(cmd)
156-
ExpectWithOffset(2, err).NotTo(HaveOccurred())
157-
podNames := utils.GetNonEmptyLines(string(podOutput))
158-
if len(podNames) != 1 {
159-
return fmt.Errorf("expect 1 feast registry pod is running, but got %d", len(podNames))
160-
}
161-
controllerPodName = podNames[0]
162-
ExpectWithOffset(2, controllerPodName).Should(ContainSubstring("default-feast-cr"))
163-
164-
// Validate pod status
165-
cmd = exec.Command("kubectl", "get",
166-
"pods", controllerPodName, "-o", "jsonpath={.status.phase}",
167-
"-n", "default",
168-
)
169-
status, err := utils.Run(cmd)
170-
ExpectWithOffset(2, err).NotTo(HaveOccurred())
171-
if string(status) != "Running" {
172-
return fmt.Errorf("registry pod in %s status", status)
173-
}
174-
return nil
103+
namespace := "default"
104+
105+
deploymentNames := [3]string{"feast-simple-feast-setup-registry", "feast-simple-feast-setup-online", "feast-simple-feast-setup-offline"}
106+
for _, deploymentName := range deploymentNames {
107+
By(fmt.Sprintf("validate the feast deployment: %s is up and in availability state.", deploymentName))
108+
err = checkIfDeploymentExistsAndAvailable(namespace, deploymentName, timeout)
109+
Expect(err).To(BeNil(), fmt.Sprintf(
110+
"Deployment %s is not available but expected to be available. \nError: %v\n",
111+
deploymentName, err,
112+
))
113+
fmt.Printf("Feast Deployment %s is available\n", deploymentName)
175114
}
176-
EventuallyWithOffset(1, verifyFeastControllerUp, time.Minute, time.Second).Should(Succeed())
177115

178116
By("Check if the feast client - kubernetes config map exists.")
179-
verifyFeastClientConfigMapExists := func() error {
180-
// Get pod name
181-
182-
cmd := exec.Command("kubectl", "get",
183-
"configmap", "feast-default-feast-cr-client",
184-
"-n", "default", "--no-headers",
185-
)
186-
187-
cmOutput, err := utils.Run(cmd)
188-
ExpectWithOffset(2, err).NotTo(HaveOccurred())
189-
configMap := utils.GetNonEmptyLines(string(cmOutput))
190-
if len(configMap) != 1 {
191-
return fmt.Errorf("expect 1 configmap exists with "+
192-
"the name 'feast-default-feast-cr-client', but got %d", len(configMap))
193-
}
194-
return nil
195-
}
196-
EventuallyWithOffset(1, verifyFeastClientConfigMapExists, time.Minute, time.Second).Should(Succeed())
197-
198-
By("Check if the feast registry - kubernetes service exists.")
199-
verifyFeastRegistryServiceExists := func() error {
200-
// Get pod name
201-
202-
cmd := exec.Command("kubectl", "get",
203-
"service", "feast-default-feast-cr-registry",
204-
"-n", "default", "--no-headers",
205-
)
206-
207-
serviceOutput, err := utils.Run(cmd)
208-
ExpectWithOffset(2, err).NotTo(HaveOccurred())
209-
service := utils.GetNonEmptyLines(string(serviceOutput))
210-
if len(service) != 1 {
211-
return fmt.Errorf("expect 1 service exists with the name "+
212-
"'feast-default-feast-cr-registry', but got %d", len(service))
213-
}
214-
return nil
117+
configMapName := "feast-simple-feast-setup-client"
118+
err = checkIfConfigMapExists(namespace, configMapName)
119+
Expect(err).To(BeNil(), fmt.Sprintf(
120+
"config map %s is not available but expected to be available. \nError: %v\n",
121+
configMapName, err,
122+
))
123+
fmt.Printf("Feast Deployment %s is available\n", configMapName)
124+
125+
serviceAccountNames := [3]string{"feast-simple-feast-setup-registry", "feast-simple-feast-setup-online", "feast-simple-feast-setup-offline"}
126+
for _, serviceAccountName := range serviceAccountNames {
127+
By(fmt.Sprintf("validate the feast service account: %s is available.", serviceAccountName))
128+
err = checkIfServiceAccountExists(namespace, serviceAccountName)
129+
Expect(err).To(BeNil(), fmt.Sprintf(
130+
"Service account %s does not exist in namespace %s. Error: %v",
131+
serviceAccountName, namespace, err,
132+
))
133+
fmt.Printf("Service account %s exists in namespace %s\n", serviceAccountName, namespace)
215134
}
216-
EventuallyWithOffset(1, verifyFeastRegistryServiceExists, time.Minute, time.Second).Should(Succeed())
217135

218-
By("Check if the feast registry - kubernetes Service Account exists.")
219-
verifyFeastRegistryServiceAccountExists := func() error {
220-
// Get pod name
221-
222-
cmd := exec.Command("kubectl", "get",
223-
"serviceaccount", "--selector", "feast.dev/name=default-feast-cr,feast.dev/service-type=registry",
224-
"-n", "default", "--no-headers",
225-
)
226-
227-
serviceOutput, err := utils.Run(cmd)
228-
ExpectWithOffset(2, err).NotTo(HaveOccurred())
229-
serviceAccount := utils.GetNonEmptyLines(string(serviceOutput))
230-
if len(serviceAccount) != 1 {
231-
return fmt.Errorf("expect 1 service account exists with the labels "+
232-
"feast.dev/name=default-feast-cr,feast.dev/service-type=registry, but got %d", len(serviceAccount))
233-
}
234-
235-
serviceAccountName := serviceAccount[0]
236-
ExpectWithOffset(2, serviceAccountName).Should(ContainSubstring("feast-default-feast-cr-registry"))
237-
238-
return nil
136+
serviceNames := [3]string{"feast-simple-feast-setup-registry", "feast-simple-feast-setup-online", "feast-simple-feast-setup-offline"}
137+
for _, serviceName := range serviceNames {
138+
By(fmt.Sprintf("validate the kubernetes service name: %s is available.", serviceName))
139+
err = checkIfKubernetesServiceExists(namespace, serviceName)
140+
Expect(err).To(BeNil(), fmt.Sprintf(
141+
"kubernetes service %s is not available but expected to be available. \nError: %v\n",
142+
serviceName, err,
143+
))
144+
fmt.Printf("kubernetes service %s is available\n", serviceName)
239145
}
240-
EventuallyWithOffset(1, verifyFeastRegistryServiceAccountExists, time.Minute, time.Second).Should(Succeed())
241146

242-
By("deleting the Simple Feast Custom Resource")
147+
By("deleting the feast deployment")
243148
cmd = exec.Command("kubectl", "delete", "-f",
244149
"test/testdata/feast_integration_test_crs/v1alpha1_default_featurestore.yaml")
245150
_, cmdOutputerr = utils.Run(cmd)
246151
ExpectWithOffset(1, cmdOutputerr).NotTo(HaveOccurred())
152+
153+
By("Uninstalling the feast CRD")
154+
cmd = exec.Command("kubectl", "delete", "deployment", controllerDeploymentName, "-n", feastControllerNamespace)
155+
_, err = utils.Run(cmd)
156+
ExpectWithOffset(1, err).NotTo(HaveOccurred())
157+
247158
})
248159
})
249160
})

0 commit comments

Comments
 (0)