MCPcopy
hub / github.com/google/seesaw / TestExpandChecks

Function TestExpandChecks

engine/vserver_test.go:262–297  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

260}
261
262func TestExpandChecks(t *testing.T) {
263 vserver := newTestVserver(nil)
264 vserver.handleConfigUpdate(&vserverConfig)
265
266 // 1 vserver healthcheck x 2 backends x 2 IPs +
267 // 2 ventry healthchecks x 2 backends x 2 IPs x 2 ventries = 20
268 if len(vserver.checks) != 20 {
269 t.Errorf("Expected 20 total checks, got %d", len(vserver.checks))
270 }
271
272 count := 0
273 for _, s := range vserver.services {
274 for _, d := range s.dests {
275 // 1 vserver healthcheck + 2 ventry healthchecks = 3 dests
276 if len(d.checks) != 3 {
277 t.Errorf("Expected 3 checks, got %d", len(d.checks))
278 }
279 for _, c := range d.checks {
280 // vserver healthcheck
281 if c.healthcheck.Port == vserverHC.Port && len(c.dests) != 2 {
282 t.Errorf("Expected 2 dests for vserver healthcheck, got %d", len(c.dests))
283 }
284 // ventry healthcheck
285 if c.healthcheck.Port != 5 && len(c.dests) != 1 {
286 t.Errorf("Expected 1 dest for ventry healthcheck, got %d", len(c.dests))
287 }
288 count++
289 }
290 }
291 }
292 // 2 ventry x 2 IPs = 4 services
293 // 4 services x 2 dests x (1 vserver healthcheck + 2 ventry healthchecks) = 24
294 if count != 24 {
295 t.Errorf("Expected 24 non-unique checks, got %d", count)
296 }
297}
298
299type testStates struct {
300 active []bool

Callers

nothing calls this directly

Calls 2

newTestVserverFunction · 0.85
handleConfigUpdateMethod · 0.45

Tested by

no test coverage detected