@@ -3,10 +3,15 @@ package healthcheck_test
3
3
import (
4
4
"encoding/json"
5
5
"errors"
6
+ "io"
7
+ "log/slog"
6
8
"net/http"
7
9
"net/http/httptest"
8
10
"testing"
9
11
12
+ nic_glog "github.com/nginxinc/kubernetes-ingress/internal/logger/glog"
13
+ "github.com/nginxinc/kubernetes-ingress/internal/logger/levels"
14
+
10
15
"github.com/go-chi/chi/v5"
11
16
"github.com/google/go-cmp/cmp"
12
17
"github.com/nginxinc/kubernetes-ingress/internal/healthcheck"
@@ -25,6 +30,7 @@ func TestHealthCheckServer_Returns404OnMissingHostname(t *testing.T) {
25
30
hs := healthcheck.HealthServer {
26
31
UpstreamsForHost : getUpstreamsForHost ,
27
32
NginxUpstreams : getUpstreamsFromNGINXAllUp ,
33
+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
28
34
}
29
35
30
36
ts := httptest .NewServer (testHandler (& hs ))
@@ -45,6 +51,7 @@ func TestHealthCheckServer_ReturnsCorrectStatsForHostnameOnAllPeersUp(t *testing
45
51
hs := healthcheck.HealthServer {
46
52
UpstreamsForHost : getUpstreamsForHost ,
47
53
NginxUpstreams : getUpstreamsFromNGINXAllUp ,
54
+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
48
55
}
49
56
50
57
ts := httptest .NewServer (testHandler (& hs ))
@@ -78,6 +85,7 @@ func TestHealthCheckServer_ReturnsCorrectStatsForHostnameOnAllPeersDown(t *testi
78
85
hs := healthcheck.HealthServer {
79
86
UpstreamsForHost : getUpstreamsForHost ,
80
87
NginxUpstreams : getUpstreamsFromNGINXAllUnhealthy ,
88
+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
81
89
}
82
90
83
91
ts := httptest .NewServer (testHandler (& hs ))
@@ -112,6 +120,7 @@ func TestHealthCheckServer_ReturnsCorrectStatsForValidHostnameOnPartOfPeersDown(
112
120
hs := healthcheck.HealthServer {
113
121
UpstreamsForHost : getUpstreamsForHost ,
114
122
NginxUpstreams : getUpstreamsFromNGINXPartiallyUp ,
123
+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
115
124
}
116
125
117
126
ts := httptest .NewServer (testHandler (& hs ))
@@ -146,6 +155,7 @@ func TestHealthCheckServer_RespondsWith404OnNotExistingHostname(t *testing.T) {
146
155
hs := healthcheck.HealthServer {
147
156
UpstreamsForHost : getUpstreamsForHost ,
148
157
NginxUpstreams : getUpstreamsFromNGINXNotExistingHost ,
158
+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
149
159
}
150
160
151
161
ts := httptest .NewServer (testHandler (& hs ))
@@ -166,6 +176,7 @@ func TestHealthCheckServer_RespondsWith500OnErrorFromNGINXAPI(t *testing.T) {
166
176
hs := healthcheck.HealthServer {
167
177
UpstreamsForHost : getUpstreamsForHost ,
168
178
NginxUpstreams : getUpstreamsFromNGINXErrorFromAPI ,
179
+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
169
180
}
170
181
171
182
ts := httptest .NewServer (testHandler (& hs ))
@@ -186,6 +197,7 @@ func TestHealthCheckServer_Returns404OnMissingTransportServerActionName(t *testi
186
197
hs := healthcheck.HealthServer {
187
198
StreamUpstreamsForName : streamUpstreamsForName ,
188
199
NginxStreamUpstreams : streamUpstreamsFromNGINXAllUp ,
200
+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
189
201
}
190
202
191
203
ts := httptest .NewServer (testHandler (& hs ))
@@ -206,6 +218,7 @@ func TestHealthCheckServer_Returns404OnBogusTransportServerActionName(t *testing
206
218
hs := healthcheck.HealthServer {
207
219
StreamUpstreamsForName : streamUpstreamsForName ,
208
220
NginxStreamUpstreams : streamUpstreamsFromNGINXAllUp ,
221
+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
209
222
}
210
223
211
224
ts := httptest .NewServer (testHandler (& hs ))
@@ -226,6 +239,7 @@ func TestHealthCheckServer_ReturnsCorrectTransportServerStatsForNameOnAllPeersUp
226
239
hs := healthcheck.HealthServer {
227
240
StreamUpstreamsForName : streamUpstreamsForName ,
228
241
NginxStreamUpstreams : streamUpstreamsFromNGINXAllUp ,
242
+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
229
243
}
230
244
231
245
ts := httptest .NewServer (testHandler (& hs ))
@@ -259,6 +273,7 @@ func TestHealthCheckServer_ReturnsCorrectTransportServerStatsForNameOnSomePeersU
259
273
hs := healthcheck.HealthServer {
260
274
StreamUpstreamsForName : streamUpstreamsForName ,
261
275
NginxStreamUpstreams : streamUpstreamsFromNGINXPartiallyUp ,
276
+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
262
277
}
263
278
264
279
ts := httptest .NewServer (testHandler (& hs ))
@@ -292,6 +307,7 @@ func TestHealthCheckServer_ReturnsCorrectTransportServerStatsForNameOnAllPeersDo
292
307
hs := healthcheck.HealthServer {
293
308
StreamUpstreamsForName : streamUpstreamsForName ,
294
309
NginxStreamUpstreams : streamUpstreamsFromNGINXAllPeersDown ,
310
+ Logger : slog .New (nic_glog .New (io .Discard , & nic_glog.Options {Level : levels .LevelInfo })),
295
311
}
296
312
297
313
ts := httptest .NewServer (testHandler (& hs ))
0 commit comments