@@ -3,10 +3,15 @@ package healthcheck_test
33import (
44 "encoding/json"
55 "errors"
6+ "io"
7+ "log/slog"
68 "net/http"
79 "net/http/httptest"
810 "testing"
911
12+ nic_glog "github.com/nginxinc/kubernetes-ingress/internal/logger/glog"
13+ "github.com/nginxinc/kubernetes-ingress/internal/logger/levels"
14+
1015 "github.com/go-chi/chi/v5"
1116 "github.com/google/go-cmp/cmp"
1217 "github.com/nginxinc/kubernetes-ingress/internal/healthcheck"
@@ -25,6 +30,7 @@ func TestHealthCheckServer_Returns404OnMissingHostname(t *testing.T) {
2530 hs := healthcheck.HealthServer {
2631 UpstreamsForHost : getUpstreamsForHost ,
2732 NginxUpstreams : getUpstreamsFromNGINXAllUp ,
33+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
2834 }
2935
3036 ts := httptest .NewServer (testHandler (& hs ))
@@ -45,6 +51,7 @@ func TestHealthCheckServer_ReturnsCorrectStatsForHostnameOnAllPeersUp(t *testing
4551 hs := healthcheck.HealthServer {
4652 UpstreamsForHost : getUpstreamsForHost ,
4753 NginxUpstreams : getUpstreamsFromNGINXAllUp ,
54+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
4855 }
4956
5057 ts := httptest .NewServer (testHandler (& hs ))
@@ -78,6 +85,7 @@ func TestHealthCheckServer_ReturnsCorrectStatsForHostnameOnAllPeersDown(t *testi
7885 hs := healthcheck.HealthServer {
7986 UpstreamsForHost : getUpstreamsForHost ,
8087 NginxUpstreams : getUpstreamsFromNGINXAllUnhealthy ,
88+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
8189 }
8290
8391 ts := httptest .NewServer (testHandler (& hs ))
@@ -112,6 +120,7 @@ func TestHealthCheckServer_ReturnsCorrectStatsForValidHostnameOnPartOfPeersDown(
112120 hs := healthcheck.HealthServer {
113121 UpstreamsForHost : getUpstreamsForHost ,
114122 NginxUpstreams : getUpstreamsFromNGINXPartiallyUp ,
123+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
115124 }
116125
117126 ts := httptest .NewServer (testHandler (& hs ))
@@ -146,6 +155,7 @@ func TestHealthCheckServer_RespondsWith404OnNotExistingHostname(t *testing.T) {
146155 hs := healthcheck.HealthServer {
147156 UpstreamsForHost : getUpstreamsForHost ,
148157 NginxUpstreams : getUpstreamsFromNGINXNotExistingHost ,
158+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
149159 }
150160
151161 ts := httptest .NewServer (testHandler (& hs ))
@@ -166,6 +176,7 @@ func TestHealthCheckServer_RespondsWith500OnErrorFromNGINXAPI(t *testing.T) {
166176 hs := healthcheck.HealthServer {
167177 UpstreamsForHost : getUpstreamsForHost ,
168178 NginxUpstreams : getUpstreamsFromNGINXErrorFromAPI ,
179+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
169180 }
170181
171182 ts := httptest .NewServer (testHandler (& hs ))
@@ -186,6 +197,7 @@ func TestHealthCheckServer_Returns404OnMissingTransportServerActionName(t *testi
186197 hs := healthcheck.HealthServer {
187198 StreamUpstreamsForName : streamUpstreamsForName ,
188199 NginxStreamUpstreams : streamUpstreamsFromNGINXAllUp ,
200+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
189201 }
190202
191203 ts := httptest .NewServer (testHandler (& hs ))
@@ -206,6 +218,7 @@ func TestHealthCheckServer_Returns404OnBogusTransportServerActionName(t *testing
206218 hs := healthcheck.HealthServer {
207219 StreamUpstreamsForName : streamUpstreamsForName ,
208220 NginxStreamUpstreams : streamUpstreamsFromNGINXAllUp ,
221+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
209222 }
210223
211224 ts := httptest .NewServer (testHandler (& hs ))
@@ -226,6 +239,7 @@ func TestHealthCheckServer_ReturnsCorrectTransportServerStatsForNameOnAllPeersUp
226239 hs := healthcheck.HealthServer {
227240 StreamUpstreamsForName : streamUpstreamsForName ,
228241 NginxStreamUpstreams : streamUpstreamsFromNGINXAllUp ,
242+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
229243 }
230244
231245 ts := httptest .NewServer (testHandler (& hs ))
@@ -259,6 +273,7 @@ func TestHealthCheckServer_ReturnsCorrectTransportServerStatsForNameOnSomePeersU
259273 hs := healthcheck.HealthServer {
260274 StreamUpstreamsForName : streamUpstreamsForName ,
261275 NginxStreamUpstreams : streamUpstreamsFromNGINXPartiallyUp ,
276+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
262277 }
263278
264279 ts := httptest .NewServer (testHandler (& hs ))
@@ -292,6 +307,7 @@ func TestHealthCheckServer_ReturnsCorrectTransportServerStatsForNameOnAllPeersDo
292307 hs := healthcheck.HealthServer {
293308 StreamUpstreamsForName : streamUpstreamsForName ,
294309 NginxStreamUpstreams : streamUpstreamsFromNGINXAllPeersDown ,
310+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
295311 }
296312
297313 ts := httptest .NewServer (testHandler (& hs ))
0 commit comments