MCPcopy Create free account
hub / github.com/zalando/skipper / TestLogging

Function TestLogging

routing/datasource_test.go:229–325  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

227}
228
229func TestLogging(t *testing.T) {
230 const routes = `
231 r1_1: Path("/foo") -> "https://foo.example.org";
232 r1_2: Path("/bar") -> "https://bar.example.org";
233 r1_3: Path("/baz") -> "https://baz.example.org";
234 r1_4: Path("/qux") -> "https://qux.example.org";
235 r1_5: Path("/quux") -> "https://quux.example.org";
236 `
237
238 init := func(l logging.Logger, client routing.DataClient, suppress bool) *routing.Routing {
239 return routing.New(routing.Options{
240 DataClients: []routing.DataClient{client},
241 Log: l,
242 SuppressLogs: suppress,
243 })
244 }
245
246 testUpdate := func(
247 t *testing.T, suppress bool,
248 initQuery string, initCount int,
249 upsertQuery string, upsertCount int,
250 deleteQuery string, deleteCount int,
251 ) {
252 client, err := testdataclient.NewDoc(routes)
253 if err != nil {
254 t.Error(err)
255 return
256 }
257 defer client.Close()
258
259 testLog := loggingtest.New()
260 defer testLog.Close()
261
262 rt := init(testLog, client, suppress)
263 defer rt.Close()
264
265 if err := testLog.WaitFor("route settings applied", 120*time.Millisecond); err != nil {
266 t.Error(err)
267 return
268 }
269
270 count := testLog.Count(initQuery)
271 if count != initCount {
272 t.Error("unexpected count of log entries", count)
273 t.Log("expected", initCount, initQuery)
274 t.Log("got ", count)
275 return
276 }
277
278 testLog.Reset()
279
280 client.UpdateDoc(
281 `r1_1: Path("/foo_mod") -> "https://foo.example.org";
282 r1_4: Path("/qux_mod") -> "https://qux.example.org"`,
283 []string{"r1_2"},
284 )
285
286 if err := testLog.WaitFor("route settings applied", 120*time.Millisecond); err != nil {

Callers

nothing calls this directly

Calls 11

NewFunction · 0.92
NewDocFunction · 0.92
NewFunction · 0.92
LogMethod · 0.80
UpdateDocMethod · 0.80
ErrorMethod · 0.65
CloseMethod · 0.65
ResetMethod · 0.65
initFunction · 0.50
WaitForMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…