def test_make_probe_should_fail_when_no_healthcheck_is_defined(): check_spec = CheckSpec(tcp=None, execute=None, http=None, initial_delay_seconds=30, period_seconds=60, success_threshold=3, failure_threshold=3, timeout_seconds=10) with pytest.raises(RuntimeError): _make_probe(check_spec)
def test_make_tcp_probe(): check_spec = CheckSpec(tcp=TcpCheckSpec(port=31337), http=None, execute=None, initial_delay_seconds=30, period_seconds=60, success_threshold=3, failure_threshold=3, timeout_seconds=10) probe = _make_probe(check_spec) assert probe.tcpSocket.port == 31337 assert probe.initialDelaySeconds == 30 assert probe.periodSeconds == 60 assert probe.successThreshold == 3 assert probe.timeoutSeconds == 10
def test_make_http_probe(): check_spec = CheckSpec(http=HttpCheckSpec(path="/", port=8080, http_headers={"Authorization": "ZmlubjpqdXN0aW5iaWViZXJfeG94bw=="}), tcp=None, execute=None, initial_delay_seconds=30, period_seconds=60, success_threshold=3, failure_threshold=3, timeout_seconds=10) probe = _make_probe(check_spec) assert probe.httpGet.path == "/" assert probe.httpGet.port == 8080 assert probe.httpGet.scheme == "HTTP" assert len(probe.httpGet.httpHeaders) == 1 assert probe.httpGet.httpHeaders[0].name == "Authorization" assert probe.httpGet.httpHeaders[0].value == "ZmlubjpqdXN0aW5iaWViZXJfeG94bw==" assert probe.initialDelaySeconds == 30 assert probe.periodSeconds == 60 assert probe.successThreshold == 3 assert probe.timeoutSeconds == 10