Skip to content

Commit

Permalink
Add log level test
Browse files Browse the repository at this point in the history
Changelog
  • Loading branch information
Marcel Ludwig committed Jun 22, 2021
1 parent 719ea97 commit 1d6fa58
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

Unreleased changes are available as `avenga/couper:edge` container.

* **Changed**
* `Error` log-level for upstream responses with status `500` to `Info` log-level ([#258](https://github.com/avenga/couper/pull/258))

---

## [1.3](https://github.com/avenga/couper/compare/1.2...1.3)
Expand All @@ -21,8 +24,6 @@ Unreleased changes are available as `avenga/couper:edge` container.
* Upstream requests with a known body-size have a `Content-Length` HTTP header field instead of `Transfer-Encoding: chunked` ([#163](https://github.com/avenga/couper/issues/163))
* Exit endpoint if an error is occurred in `request` or `proxy` instead of processing a defined `response` ([#233](https://github.com/avenga/couper/pull/233))

---

## [1.2](https://github.com/avenga/couper/compare/1.1.1...1.2)

Release date: 2021-05-19
Expand Down
3 changes: 3 additions & 0 deletions internal/test/test_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func NewBackend() *Backend {
b.mux.HandleFunc("/", createAnythingHandler(http.StatusNotFound))
b.mux.HandleFunc("/ws", echo)
b.mux.HandleFunc("/pdf", pdf)
b.mux.HandleFunc("/error", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
})

return b
}
Expand Down
27 changes: 27 additions & 0 deletions server/http_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2585,3 +2585,30 @@ func TestCORS_Configuration(t *testing.T) {
})
}
}

func TestLog_Level(t *testing.T) {
shutdown, hook := newCouper("testdata/integration/logging/01_couper.hcl", test.New(t))
defer shutdown()

client := newClient()

helper := test.New(t)

req, err := http.NewRequest(http.MethodGet, "http://my.upstream:8080/", nil)
helper.Must(err)

hook.Reset()

res, err := client.Do(req)
helper.Must(err)

if res.StatusCode != http.StatusInternalServerError {
t.Errorf("Expected status: %d, got: %d", http.StatusInternalServerError, res.StatusCode)
}

for _, entry := range hook.AllEntries() {
if entry.Level != logrus.InfoLevel {
t.Errorf("Expected info level, got: %v", entry.Level)
}
}
}
21 changes: 21 additions & 0 deletions server/testdata/integration/logging/01_couper.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
server "couper" {
error_file = "./../server_error.html"

api {
error_file = "./../api_error.json"

endpoint "/" {
proxy {
backend = "anything"
}
}
}
}

definitions {
# backend origin within a definition block gets replaced with the integration test "anything" server.
backend "anything" {
path = "/error"
origin = env.COUPER_TEST_BACKEND_ADDR
}
}

0 comments on commit 1d6fa58

Please sign in to comment.