(t *testing.T)
| 422 | } |
| 423 | |
| 424 | func TestHealthcheckNotification(t *testing.T) { |
| 425 | vserver := newTestVserver(nil) |
| 426 | vserver.handleConfigUpdate(&vserverConfig) |
| 427 | checkStates(0, vserver, t) |
| 428 | |
| 429 | // One healthcheck reports healthy, but there are two other |
| 430 | // healthchecks per destination, so services and vservers should |
| 431 | // still be inactive. |
| 432 | key := CheckKey{ |
| 433 | VserverIP: seesaw.ParseIP("192.168.255.1"), |
| 434 | BackendIP: seesaw.ParseIP("1.1.1.10"), |
| 435 | HealthcheckPort: 5, |
| 436 | Name: "NONE/5_0", |
| 437 | } |
| 438 | n := &checkNotification{key: key, status: statusHealthy} |
| 439 | vserver.handleCheckNotification(n) |
| 440 | checkStates(1, vserver, t) |
| 441 | |
| 442 | // Bringing up all destinations should bring up all services and |
| 443 | // vservers. All services and destinations should now be healthy. |
| 444 | for _, c := range vserver.checks { |
| 445 | n := &checkNotification{key: c.key, status: statusHealthy} |
| 446 | vserver.handleCheckNotification(n) |
| 447 | } |
| 448 | checkStates(2, vserver, t) |
| 449 | |
| 450 | // One backend is unhealthy, all services should still be active. |
| 451 | // All services should be healthy and destinations for other backends |
| 452 | // should still be healthy. |
| 453 | key = CheckKey{ |
| 454 | VserverIP: seesaw.ParseIP("192.168.255.1"), |
| 455 | BackendIP: seesaw.ParseIP("1.1.1.10"), |
| 456 | ServiceProtocol: seesaw.IPProtoUDP, |
| 457 | ServicePort: 53, |
| 458 | HealthcheckPort: 1, |
| 459 | Name: "NONE/1_0", |
| 460 | } |
| 461 | n = &checkNotification{key: key, status: statusUnhealthy} |
| 462 | vserver.handleCheckNotification(n) |
| 463 | checkStates(3, vserver, t) |
| 464 | |
| 465 | // The other backend is also unhealthy. 192.168.255.1 is anycast, so all |
| 466 | // services and the VIP should be inactive. 2012::1 should be unchanged. |
| 467 | key.BackendIP = seesaw.ParseIP("1.1.1.11") |
| 468 | n = &checkNotification{key: key, status: statusUnhealthy} |
| 469 | vserver.handleCheckNotification(n) |
| 470 | checkStates(4, vserver, t) |
| 471 | |
| 472 | // Both backends are unhealthy for one service. 2012::1 is unicast so the |
| 473 | // other service and the VIP should still be active. |
| 474 | key.VserverIP = seesaw.ParseIP("2012::1") |
| 475 | key.BackendIP = seesaw.ParseIP("2012::10") |
| 476 | n = &checkNotification{key: key, status: statusUnhealthy} |
| 477 | vserver.handleCheckNotification(n) |
| 478 | key.BackendIP = seesaw.ParseIP("2012::11") |
| 479 | n = &checkNotification{key: key, status: statusUnhealthy} |
| 480 | vserver.handleCheckNotification(n) |
| 481 | checkStates(5, vserver, t) |
nothing calls this directly
no test coverage detected