Skip to content

Commit

Permalink
fix: merge error blocks in gcf (#4004)
Browse files Browse the repository at this point in the history
* chore: advertise gzip support to transformer through X-Feature-Gzip-Support header (#3990)

* chore: release 1.15.2 (#3992)

* fix: update error parsing of eloqua (#3996)

* fix(eloqua): change null values to empty strings inspite of "null"

* address comments

* add logic to consider some warning statusCode as success

* fix lint issues

* fix: corrupted rsources stats captured by processor for dropped jobs (#3999)

* chore: release 1.15.3 (#3998)

* fix: invalid memory address or nil pointer dereference in googlecloudfunction

* fix: merge error blocks in gcf

* chore: add test case for body close

* chore: add test case for body close

---------

Co-authored-by: Gauravudia <60897972+Gauravudia@users.noreply.github.com>
Co-authored-by: devops-github-rudderstack <88187154+devops-github-rudderstack@users.noreply.github.com>
Co-authored-by: Sudip Paul <67197965+ItsSudip@users.noreply.github.com>
Co-authored-by: Aris Tzoumas <atzoumas@rudderstack.com>
  • Loading branch information
5 people authored Oct 25, 2023
1 parent d0d99bc commit 03a4c26
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@ func (producer *GoogleCloudFunctionProducer) Produce(jsonData json.RawMessage, _

// Make the request using the client
resp, err := producer.httpClient.Do(req)
if err != nil && os.IsTimeout(err) {
return http.StatusAccepted, "Success", "[GoogleCloudFunction] :: Function is called"
}

var responseBody []byte

if err == nil {
defer func() { httputil.CloseResponse(resp) }()
responseBody, err = io.ReadAll(resp.Body)
}

if err != nil {
if os.IsTimeout(err) {
return http.StatusAccepted, "Success", "[GoogleCloudFunction] :: Function is called"
}
responseMessage = err.Error()
respStatus = "Failure"
responseMessage = "[GOOGLE_CLOUD_FUNCTION] error :: Function call was not executed " + responseMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ func TestConfigGenerateToken(t *testing.T) {
assert.NotNil(t, err)
}

func TestNewProduceWithBadServer(t *testing.T) {
ctrl := gomock.NewController(t)
mockClient := mock_googlecloudfunction.NewMockGoogleCloudFunctionClient(ctrl)
conf := &Config{
RequireAuthentication: false,
FunctionUrl: "http://rudderstack-non-existing-server:54321",
}
producer := &GoogleCloudFunctionProducer{client: mockClient, config: conf, httpClient: http.DefaultClient}
statusCode, responseStatus, responseMessage := producer.Produce([]byte("invalid_json"), map[string]string{})
assert.Equal(t, http.StatusBadRequest, statusCode)
assert.Equal(t, "Failure", responseStatus)
assert.Contains(t, responseMessage, "Function call was not executed")
}

func TestNewProduceWithInvalidData(t *testing.T) {
testSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Bad Request", http.StatusBadRequest)
Expand Down

0 comments on commit 03a4c26

Please sign in to comment.