Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
debug event
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoandredinis committed Oct 12, 2023
1 parent 328ffc1 commit a3c16bd
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions event-handler/fake_fluentd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"net/http"
"net/http/httptest"
"os"
"path"
"strings"
"time"

"github.com/gravitational/teleport/integrations/lib/logger"
Expand Down Expand Up @@ -153,17 +153,14 @@ func (f *FakeFluentd) GetURL() string {

// Respond is the response function
func (f *FakeFluentd) Respond(w http.ResponseWriter, r *http.Request) {
var req = make([]byte, r.ContentLength)

_, err := r.Body.Read(req)
// We omit err here because it always returns weird EOF.
// It has something to do with httptest, known bug.
// TODO: find out and resolve.
if !trace.IsEOF(err) {
logger.Standard().WithError(err).Error("FakeFluentd Respond() failed")
req, err := io.ReadAll(r.Body)
if err != nil {
logger.Standard().WithError(err).Error("FakeFluentd Respond() failed to read body")
fmt.Fprintln(w, "NOK")
return
}

f.chMessages <- strings.TrimSpace(string(req))
f.chMessages <- string(req)
fmt.Fprintln(w, "OK")
}

Expand Down

0 comments on commit a3c16bd

Please sign in to comment.