-
Notifications
You must be signed in to change notification settings - Fork 314
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
fix: warehouse proxy endpoints #3476
Conversation
4cb875e
to
59ecefe
Compare
59ecefe
to
4431a41
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## release/1.9.x #3476 +/- ##
=================================================
+ Coverage 53.29% 53.30% +0.01%
=================================================
Files 330 330
Lines 52789 52782 -7
=================================================
+ Hits 28136 28138 +2
+ Misses 23005 22996 -9
Partials 1648 1648
☔ View full report in Codecov by Sentry. |
Context("Warehouse proxy", func() { | ||
DescribeTable("forwarding requests to warehouse with different response codes", | ||
func(url string, code int, payload string) { | ||
gateway := &HandleT{} | ||
whMock := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
Expect(r.URL.String()).To(Equal(url)) | ||
Expect(r.Body) | ||
Expect(r.Body).To(Not(BeNil())) | ||
defer func() { _ = r.Body.Close() }() | ||
reqBody, err := io.ReadAll(r.Body) | ||
Expect(err).To(BeNil()) | ||
Expect(string(reqBody)).To(Equal(payload)) | ||
w.WriteHeader(code) | ||
})) | ||
GinkgoT().Setenv("WAREHOUSE_URL", whMock.URL) | ||
GinkgoT().Setenv("RSERVER_WAREHOUSE_MODE", config.OffMode) | ||
err := gateway.Setup(context.Background(), c.mockApp, c.mockBackendConfig, c.mockJobsDB, nil, c.mockVersionHandler, rsources.NewNoOpService(), sourcedebugger.NewNoOpService()) | ||
Expect(err).To(BeNil()) | ||
|
||
defer func() { | ||
err := gateway.Shutdown() | ||
Expect(err).To(BeNil()) | ||
whMock.Close() | ||
}() | ||
|
||
req := httptest.NewRequest("POST", "http://rudder-server"+url, bytes.NewBufferString(payload)) | ||
w := httptest.NewRecorder() | ||
gateway.whProxy.ServeHTTP(w, req) | ||
resp := w.Result() | ||
Expect(resp.StatusCode).To(Equal(code)) | ||
}, | ||
Entry("successful request", "/v1/warehouse/pending-events", http.StatusOK, `{"source_id": "1", "task_run_id":"2"}`), | ||
Entry("failed request", "/v1/warehouse/pending-events", http.StatusBadRequest, `{"source_id": "3", "task_run_id":"4"}`), | ||
Entry("request with query parameters", "/v1/warehouse/pending-events?triggerUpload=true", http.StatusOK, `{"source_id": "5", "task_run_id":"6"}`), | ||
) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to have this test verify the reverse proxy behaviour.
gateway/gateway_test.go
Outdated
"testing" | ||
"time" | ||
|
||
kitHelper "github.com/rudderlabs/rudder-go-kit/testhelper" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor] for consistency
kitHelper "github.com/rudderlabs/rudder-go-kit/testhelper" | |
kithelper "github.com/rudderlabs/rudder-go-kit/testhelper" |
287034e
to
1fc6934
Compare
gateway/gateway_test.go
Outdated
parsedURL, err := url.Parse(WHURL) | ||
Expect(err).To(BeNil()) | ||
whPort := parsedURL.Port() | ||
os.Setenv("RSERVER_WAREHOUSE_WEB_PORT", whPort) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be possible to use GinkgoT().Setenv()
. Just check it out, if not nevermind.
a7d3284
to
7a556f5
Compare
7a556f5
to
7447c68
Compare
Description
Using dedicated public endpoints for the warehouse instead of passing everything with the matching
/warehouse
pattern. Currently, the warehouse supports these endpoints:Notion Ticket
https://www.notion.so/rudderstacks/Gateway-endpoints-are-not-working-for-warehouse-b6e7acafe48f49a587f7f7ef7e401291?pvs=4
Security