feat(e2e): add environment-agent deploy and embedded storage registration tests (FLPATH-4803) - #45
Conversation
PR Summary by QodoAdd environment-agent and Kubernetes storage E2E coverage
AI Description
Diagram
High-Level Assessment
Files changed (15)
|
Code Review by Qodo
1.
|
57bab78 to
2841832
Compare
…s (FLPATH-4434, FLPATH-4803) Add standalone storage SP E2E (API, NATS status, cluster checks) and wire environment-agent deploy with embedded storage registration validation. Deploy: --environment-agent provider, compose override on port 8090, pull_policy missing for local agent builds, .dcm-e2e.env exports. Tests: embedded storage at embedded://storage via agent /providers; keep DCM_NATS_URL in run-e2e.sh --help for CI validate-scripts. Assisted-by: Cursor Signed-off-by: igavra <igavra@redhat.com>
495ec9d to
86f0807
Compare
| CLI_REQUIREMENT="oc-or-kubectl" | ||
|
|
||
| # Reuse storage namespace flag/env for embedded SP_K8S_NAMESPACE. | ||
| NAMESPACE_FLAG="k8s-storage-namespace" |
There was a problem hiding this comment.
nit: what do you think to prefix this variable with the K8S_STORAGE_SP_ so that it's clear these are specific for the SP and not required by the environment agent?
There was a problem hiding this comment.
Embedded storage in the agent and the standalone storage SP both create PVCs in the same namespace, so we reuse --k8s-storage-namespace / K8S_STORAGE_SP_NAMESPACE rather than adding an agent-specific flag.
NAMESPACE_FLAG="k8s-storage-namespace" — shared CLI flag with standalone SP
NAMESPACE_ENV="K8S_STORAGE_SP_NAMESPACE" — already K8S_STORAGE_SP_-prefixed
| Expect(err).NotTo(HaveOccurred()) | ||
| Expect(resp.StatusCode).To(Equal(http.StatusOK)) | ||
|
|
||
| var body map[string]interface{} |
There was a problem hiding this comment.
do we already have a defined structure to use instead of unstructured data?
There was a problem hiding this comment.
yes, but we don't import the SP package, its the same as other e2e tests
| var body map[string]interface{} | ||
| decodeJSON(resp, &body) | ||
| Expect(body["status"]).To(Equal("healthy")) | ||
| Expect(body).To(HaveKey("uptime")) |
There was a problem hiding this comment.
is there an expected value to check for all 3 fields?
There was a problem hiding this comment.
Yes for the 3 . Added more
| name := uniqueName("e2e-vol") | ||
| body := createTestVolume(volumeSpec(name, defaultTestCapacity)) | ||
|
|
||
| id := body["id"].(string) |
There was a problem hiding this comment.
any reason why not use structured data?
There was a problem hiding this comment.
Tests use maps for consistency with sp_container_*.
|
|
||
| var body map[string]interface{} | ||
| decodeJSON(resp, &body) | ||
| Expect(body).To(HaveKey("id")) |
There was a problem hiding this comment.
if you used structured data, you would not need to check this. Perhaps check that the field has a value that matches the format from the rest call?
There was a problem hiding this comment.
On the REST side we have k8sHintsFromSpec that rejects unknown keys and bad types, I was asked to remove hints fields from API spec
| ExpectWithOffset(1, err).NotTo(HaveOccurred(), "failed to get PVC %s", name) | ||
|
|
||
| var pvc map[string]interface{} | ||
| ExpectWithOffset(1, json.Unmarshal([]byte(out), &pvc)).To(Succeed()) |
There was a problem hiding this comment.
you're not validating the pvc, just that there is one. You should also validate that the PVC is ready.
|
|
||
| // runStorageKubectl executes kubectl/oc in the storage SP namespace. | ||
| func runStorageKubectl(args ...string) (string, error) { | ||
| fullArgs := append([]string{"-n", storageSPNamespace}, args...) |
There was a problem hiding this comment.
why cli and not using the kubernetes go client?
|
|
||
| // applyStorageManifest applies a Kubernetes manifest in the storage SP namespace. | ||
| func applyStorageManifest(manifest string) error { | ||
| cmd := exec.Command(kubectlBin, "-n", storageSPNamespace, "apply", "-f", "-") |
There was a problem hiding this comment.
same here: why cli and not the kubernetes go client bindings?
|
|
||
| // doEnvironmentAgentRequest sends a request to the environment agent API. | ||
| func doEnvironmentAgentRequest(method, path string, body string) (*http.Response, error) { | ||
| url := environmentAgentBaseURL + path |
There was a problem hiding this comment.
why not use the environment agent bindings? using pure http client is not testing the env agent real path. And it makes this tests brittle the moment the rest api changes (new fields, path, etc..), which should not make these tests fail
And dcm-project/environment-agent#31
Wire environment-agent with embedded k8s storage SP into the utilities E2E stack
so registration can be validated without a standalone storage SP container.
Deploy:
AGENT_EMBEDDED_SPS=storage, DCM_REGISTRATION_URL without /api/v1alpha1 path)
exports (DCM_ENVIRONMENT_AGENT_URL, K8S_STORAGE_SP_REGISTERED_ENDPOINT)
by Quay while embedded storage is not yet on main
Tests:
tests work with --environment-agent only (no :8089)
Docs: README, CLAUDE.md, e2e-tests.mdc