def test_https_h2(https_test_server_fixture): """ Runs the CLI configured to use HTTP/2 (using https) against our test server, and sanity checks statistics from both client and server. """ parsed_json, _ = https_test_server_fixture.runNighthawkClient( ["--h2", https_test_server_fixture.getTestServerRootUri()]) counters = https_test_server_fixture.getNighthawkCounterMapFromJson( parsed_json) assertCounterEqual(counters, "benchmark.http_2xx", 25) assertCounterEqual(counters, "upstream_cx_destroy", 1) assertCounterEqual(counters, "upstream_cx_destroy_local", 1) assertCounterEqual(counters, "upstream_cx_http2_total", 1) assertCounterGreaterEqual(counters, "upstream_cx_rx_bytes_total", 1145) assertCounterEqual(counters, "upstream_cx_total", 1) assertCounterGreaterEqual(counters, "upstream_cx_tx_bytes_total", 403) assertCounterEqual(counters, "upstream_rq_pending_total", 1) assertCounterEqual(counters, "upstream_rq_total", 25) assertCounterEqual(counters, "ssl.ciphers.ECDHE-RSA-AES128-GCM-SHA256", 1) assertCounterEqual(counters, "ssl.curves.X25519", 1) assertCounterEqual(counters, "ssl.handshake", 1) assertCounterEqual(counters, "ssl.sigalgs.rsa_pss_rsae_sha256", 1) assertCounterEqual(counters, "ssl.versions.TLSv1.2", 1) assertEqual(len(counters), 18)
def test_https_h1(https_test_server_fixture): """ Runs the CLI configured to use HTTP/1 over https against our test server, and sanity checks statistics from both client and server. """ parsed_json, _ = https_test_server_fixture.runNighthawkClient( [https_test_server_fixture.getTestServerRootUri()]) counters = https_test_server_fixture.getNighthawkCounterMapFromJson( parsed_json) assertCounterEqual(counters, "benchmark.http_2xx", 25) assertCounterEqual(counters, "upstream_cx_destroy", 1) assertCounterEqual(counters, "upstream_cx_destroy_local", 1) assertCounterEqual(counters, "upstream_cx_http1_total", 1) assertCounterEqual(counters, "upstream_cx_rx_bytes_total", 3400) assertCounterEqual(counters, "upstream_cx_total", 1) assertCounterEqual( counters, "upstream_cx_tx_bytes_total", 1400 if https_test_server_fixture.ip_version == IpVersion.IPV6 else 1500) assertCounterEqual(counters, "upstream_rq_pending_total", 1) assertCounterEqual(counters, "upstream_rq_total", 25) assertCounterEqual(counters, "ssl.ciphers.ECDHE-RSA-AES128-GCM-SHA256", 1) assertCounterEqual(counters, "ssl.curves.X25519", 1) assertCounterEqual(counters, "ssl.handshake", 1) assertCounterEqual(counters, "ssl.sigalgs.rsa_pss_rsae_sha256", 1) assertCounterEqual(counters, "ssl.versions.TLSv1.2", 1) assertEqual(len(counters), 18) server_stats = https_test_server_fixture.getTestServerStatisticsJson() assertEqual( https_test_server_fixture.getServerStatFromJson( server_stats, "http.ingress_http.downstream_rq_2xx"), 25)
def test_https_log_verbosity(https_test_server_fixture): """ Test that that the specified log verbosity level is respected. This tests for a sentinel we know is only right when the level is set to 'trace'. """ # TODO(oschaaf): this is kind of fragile. Can we improve? trace_level_sentinel = "nighthawk_service_zone" _, logs = https_test_server_fixture.runNighthawkClient( ["--duration 1", "--rps 1", "-v debug", https_test_server_fixture.getTestServerRootUri()]) assertNotIn(trace_level_sentinel, logs) _, logs = https_test_server_fixture.runNighthawkClient( ["--duration 1", "--rps 1", "-v trace", https_test_server_fixture.getTestServerRootUri()]) assertIn(trace_level_sentinel, logs)
def test_https_h2_tls_context_configuration(https_test_server_fixture): """ Verifies specifying tls cipher suites works with the h2 pool """ parsed_json, _ = https_test_server_fixture.runNighthawkClient([ "--duration 1", "--tls-context {common_tls_context:{tls_params:{cipher_suites:[\"-ALL:ECDHE-RSA-AES128-SHA\"]}}}", https_test_server_fixture.getTestServerRootUri() ]) counters = https_test_server_fixture.getNighthawkCounterMapFromJson(parsed_json) assertEqual(counters["ssl.ciphers.ECDHE-RSA-AES128-SHA"], 1) parsed_json, _ = https_test_server_fixture.runNighthawkClient([ "--h2", "--duration 1", "--tls-context {common_tls_context:{tls_params:{cipher_suites:[\"-ALL:ECDHE-RSA-AES256-GCM-SHA384\"]}}}", https_test_server_fixture.getTestServerRootUri() ]) counters = https_test_server_fixture.getNighthawkCounterMapFromJson(parsed_json) assertEqual(counters["ssl.ciphers.ECDHE-RSA-AES256-GCM-SHA384"], 1)
def test_https_prefetching(https_test_server_fixture): """ Test we prefetch connections. We test for 1 second at 1 rps, which should result in 1 connection max without prefetching. However, we specify 50 connections and the prefetching flag, so we ought to see 50 http1 connections created. """ parsed_json, _ = https_test_server_fixture.runNighthawkClient([ "--duration 1", "--rps 1", "--prefetch-connections", "--connections 50", https_test_server_fixture.getTestServerRootUri() ]) counters = https_test_server_fixture.getNighthawkCounterMapFromJson(parsed_json) assertEqual(counters["upstream_cx_http1_total"], 50)