-
Notifications
You must be signed in to change notification settings - Fork 18
HYPERFLEET-978 - chore: Update adapter configs, docs, and tests to use put #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,7 +142,7 @@ func createTestConfig(apiBaseURL string) *configloader.Config { | |
| ActionBase: configloader.ActionBase{ | ||
| Name: "reportClusterStatus", | ||
| APICall: &configloader.APICall{ | ||
| Method: "POST", | ||
| Method: "PUT", | ||
| URL: "{{ .hyperfleetApiBaseUrl }}/api/{{ .hyperfleetApiVersion }}/clusters/{{ .clusterID }}/statuses", | ||
|
Comment on lines
+145
to
146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add integration build tags to this integration test file. This integration test should be explicitly gated to avoid running in default unit-test paths. Suggested patch+//go:build integration
+// +build integration
+
package executorintegrationtestAs per coding guidelines, 🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a mandatory tag? A lot of the test files under https://github.com/openshift-hyperfleet/hyperfleet-adapter/tree/main/test/integration are missing the tag. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Repository: openshift-hyperfleet/hyperfleet-adapter 🏁 Script executed: Repository: openshift-hyperfleet/hyperfleet-adapter
This means the The inconsistency in the repo confirms this is not an enforced convention: only I'll retract this as a blocking concern given the current project conventions. If the team wants to standardize on the build tag for defense-in-depth (e.g., enabling
|
||
| Body: "{{ .clusterStatusPayload }}", | ||
| Timeout: "5s", | ||
|
|
@@ -1142,21 +1142,21 @@ func TestExecutor_PostActionAPIFailure(t *testing.T) { | |
| // Verify the phase is post_actions | ||
| assert.Equal(t, executor.PhasePostActions, result.CurrentPhase, "Expected failure in post_actions phase") | ||
|
|
||
| // Verify precondition API was called, but status POST failed | ||
| // Verify precondition API was called, but status PUT failed | ||
| requests := mockAPI.GetRequests() | ||
| assert.GreaterOrEqual(t, len(requests), 2, "Expected at least 2 API calls (GET cluster + POST status)") | ||
| assert.GreaterOrEqual(t, len(requests), 2, "Expected at least 2 API calls (GET cluster + PUT status)") | ||
|
|
||
| // Find the status POST request | ||
| var statusPostFound bool | ||
| var statusPutFound bool | ||
| for _, req := range requests { | ||
| if req.Method == http.MethodPost && strings.Contains(req.Path, "/statuses") { | ||
| statusPostFound = true | ||
| t.Logf("Status POST was attempted: %s %s", req.Method, req.Path) | ||
| if req.Method == http.MethodPut && strings.Contains(req.Path, "/statuses") { | ||
| statusPutFound = true | ||
| t.Logf("Status PUT was attempted: %s %s", req.Method, req.Path) | ||
| } | ||
| } | ||
| assert.True(t, statusPostFound, "Expected status POST to be attempted") | ||
| assert.True(t, statusPutFound, "Expected status PUT to be attempted") | ||
|
|
||
| // No status should be successfully stored since POST failed | ||
| // No status should be successfully stored since PUT failed | ||
| statusResponses := mockAPI.GetStatusResponses() | ||
| assert.Empty(t, statusResponses, "Expected no successful status responses due to API failure") | ||
|
|
||
|
|
@@ -1254,7 +1254,7 @@ func TestExecutor_ExecutionError_CELAccess(t *testing.T) { | |
| ActionBase: configloader.ActionBase{ | ||
| Name: "reportError", | ||
| APICall: &configloader.APICall{ | ||
| Method: "POST", | ||
| Method: "PUT", | ||
| URL: "{{ .hyperfleetApiBaseUrl }}/api/{{ .hyperfleetApiVersion }}/clusters/{{ .clusterID }}/error-report", | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| Body: "{{ .errorReportPayload }}", | ||
| Timeout: "5s", | ||
|
|
@@ -1299,7 +1299,7 @@ func TestExecutor_ExecutionError_CELAccess(t *testing.T) { | |
| requests := mockAPI.GetRequests() | ||
| var errorReportRequest *testutil.MockRequest | ||
| for i := range requests { | ||
| if requests[i].Method == http.MethodPost && strings.Contains(requests[i].Path, "/error-report") { | ||
| if requests[i].Method == http.MethodPut && strings.Contains(requests[i].Path, "/error-report") { | ||
| errorReportRequest = &requests[i] | ||
| break | ||
| } | ||
|
|
@@ -1391,7 +1391,7 @@ func TestExecutor_PayloadBuildFailure(t *testing.T) { | |
| ActionBase: configloader.ActionBase{ | ||
| Name: "shouldNotExecute", | ||
| APICall: &configloader.APICall{ | ||
| Method: "POST", | ||
| Method: "PUT", | ||
| URL: "{{ .hyperfleetApiBaseUrl }}/api/{{ .hyperfleetApiVersion }}/clusters/{{ .clusterID }}/statuses", | ||
| Body: "{{ .badPayload }}", | ||
| Timeout: "5s", | ||
|
|
@@ -1457,7 +1457,7 @@ func TestExecutor_PayloadBuildFailure(t *testing.T) { | |
| // Verify NO API call was made to the post action endpoint (blocked) | ||
| requests := mockAPI.GetRequests() | ||
| for _, req := range requests { | ||
| if req.Method == http.MethodPost && strings.Contains(req.Path, "/statuses") { | ||
| if req.Method == http.MethodPut && strings.Contains(req.Path, "/statuses") { | ||
| t.Errorf("Post action API call should NOT have been made (blocked by payload build failure)") | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -83,7 +83,7 @@ func newK8sTestAPIServer(t *testing.T) *k8sTestAPIServer { | |||||||||||||
|
|
||||||||||||||
| switch { | ||||||||||||||
| case strings.Contains(r.URL.Path, "/clusters/") && strings.HasSuffix(r.URL.Path, "/statuses"): | ||||||||||||||
| if r.Method == http.MethodPost { | ||||||||||||||
| if r.Method == http.MethodPut { | ||||||||||||||
| var statusBody map[string]interface{} | ||||||||||||||
|
ma-hill marked this conversation as resolved.
|
||||||||||||||
| if err := json.Unmarshal([]byte(bodyStr), &statusBody); err == nil { | ||||||||||||||
| mock.statusResponses = append(mock.statusResponses, statusBody) | ||||||||||||||
|
|
@@ -295,7 +295,7 @@ func createK8sTestConfig(testNamespace string) *configloader.Config { | |||||||||||||
| ActionBase: configloader.ActionBase{ | ||||||||||||||
| Name: "reportClusterStatus", | ||||||||||||||
| APICall: &configloader.APICall{ | ||||||||||||||
| Method: "POST", | ||||||||||||||
| Method: "PUT", | ||||||||||||||
| URL: "{{ .hyperfleetApiBaseUrl }}/api/{{ .hyperfleetApiVersion }}/clusters/" + | ||||||||||||||
|
Comment on lines
+298
to
299
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add integration build tags to this integration test file. This test sits in the integration suite and should be gated with build tags so default unit-test runs don’t include it. Suggested patch+//go:build integration
+// +build integration
+
package executorintegrationtestAs per coding guidelines, 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a mandatory tag? A lot of the test files under https://github.com/openshift-hyperfleet/hyperfleet-adapter/tree/main/test/integration are missing the tag. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Repository: openshift-hyperfleet/hyperfleet-adapter
This is a pre-existing gap in the codebase, not something introduced by this PR. Flagging it here is unfair to this change. I'll withdraw this comment as a blocker. That said, the coding guideline exists for a good reason — without the build tag, these tests run during
|
||||||||||||||
| "{{ .clusterID }}/statuses", | ||||||||||||||
| Body: "{{ .clusterStatusPayload }}", | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.