Skip to content

Commit

Permalink
address failures
Browse files Browse the repository at this point in the history
  • Loading branch information
zpzhuSplunk committed Mar 25, 2024
1 parent f8de4f9 commit 213b3eb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 0 additions & 2 deletions cmd/oteltestbedcol/go.mod
Expand Up @@ -394,5 +394,3 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil
replace github.com/openshift/api v3.9.0+incompatible => github.com/openshift/api v0.0.0-20180801171038-322a19404e37

replace github.com/outcaste-io/ristretto v0.2.0 => github.com/outcaste-io/ristretto v0.2.1

replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/ackextension => ../../extension/ackextension
2 changes: 2 additions & 0 deletions cmd/oteltestbedcol/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions receiver/splunkhecreceiver/receiver.go
Expand Up @@ -42,7 +42,6 @@ const (
responseOKWithAckID = `{"text": "Success", "code": 0, "ackId": %d}`
responseHecHealthy = `{"text": "HEC is healthy", "code": 17}`
responseInvalidMethodPostOnly = `"Only \"POST\" method is supported"`
responseInvalidMethodGetOnly = `"Only \"GET\" method is supported"`
responseInvalidEncoding = `"\"Content-Encoding\" must be \"gzip\" or empty"`
responseInvalidDataFormat = `{"text":"Invalid data format","code":6}`
responseErrEventRequired = `{"text":"Event field is required","code":12}`
Expand Down Expand Up @@ -79,7 +78,6 @@ var (
invalidEncodingRespBody = []byte(responseInvalidEncoding)
invalidFormatRespBody = []byte(responseInvalidDataFormat)
invalidMethodRespBodyPostOnly = []byte(responseInvalidMethodPostOnly)
invalidMethodRespBodyGetOnly = []byte(responseInvalidMethodGetOnly)
errGzipReaderRespBody = []byte(responseErrGzipReader)
errUnmarshalBodyRespBody = []byte(responseErrUnmarshalBody)
errInternalServerError = []byte(responseErrInternalServerError)
Expand Down Expand Up @@ -293,7 +291,7 @@ func (r *splunkReceiver) handleAck(resp http.ResponseWriter, req *http.Request)

// check that the channel exists
partitionID := req.Header.Get(splunk.HTTPSplunkChannelHeader)
if len(partitionID) <= 0 {
if len(partitionID) == 0 {
r.failRequest(ctx, resp, http.StatusBadRequest, requiredDataChannelHeader, 0, nil)
return
}
Expand Down Expand Up @@ -337,7 +335,7 @@ func (r *splunkReceiver) handleRawReq(resp http.ResponseWriter, req *http.Reques
if r.ackExt != nil {
// check channel header exists
partitionID = req.Header.Get(splunk.HTTPSplunkChannelHeader)
if len(partitionID) <= 0 {
if len(partitionID) == 0 {
r.failRequest(ctx, resp, http.StatusBadRequest, requiredDataChannelHeader, 0, nil)
return
}
Expand Down Expand Up @@ -439,7 +437,7 @@ func (r *splunkReceiver) handleReq(resp http.ResponseWriter, req *http.Request)
if r.ackExt != nil {
// check channel header exists
partitionID = req.Header.Get(splunk.HTTPSplunkChannelHeader)
if len(partitionID) <= 0 {
if len(partitionID) == 0 {
r.failRequest(ctx, resp, http.StatusBadRequest, requiredDataChannelHeader, 0, nil)
return
}
Expand Down
8 changes: 4 additions & 4 deletions receiver/splunkhecreceiver/receiver_test.go
Expand Up @@ -1401,12 +1401,12 @@ func Test_splunkhecReceiver_handleRawReq_WithAck(t *testing.T) {
rcv, err := newLogsReceiver(receivertest.NewNopCreateSettings(), *config, sink)
assert.NoError(t, err)

mockHost := mockHost{extensions: map[component.ID]component.Component{
mh := mockHost{extensions: map[component.ID]component.Component{
id: tt.setupMockAckExtension(t),
}}

r := rcv.(*splunkReceiver)
assert.NoError(t, r.Start(context.Background(), mockHost))
assert.NoError(t, r.Start(context.Background(), mh))
defer func() {
assert.NoError(t, r.Shutdown(context.Background()))
}()
Expand Down Expand Up @@ -1519,11 +1519,11 @@ func Test_splunkhecReceiver_handleReq_WithAck(t *testing.T) {
r := rcv.(*splunkReceiver)
w := httptest.NewRecorder()

mockHost := mockHost{extensions: map[component.ID]component.Component{
mh := mockHost{extensions: map[component.ID]component.Component{
id: tt.setupMockAckExtension(t),
}}

assert.NoError(t, r.Start(context.Background(), mockHost))
assert.NoError(t, r.Start(context.Background(), mh))
defer func() {
assert.NoError(t, r.Shutdown(context.Background()))
}()
Expand Down

0 comments on commit 213b3eb

Please sign in to comment.