コード例 #1
0
def test_multiple_backends_https_h1(multi_https_test_server_fixture):
    """
  Runs the CLI configured to use HTTP/1 with TLS against multiple test servers, and sanity
  checks statistics from both client and server.
  """
    nighthawk_client_args = [
        "--multi-target-use-https", "--multi-target-path", "/", "--duration",
        "100", "--termination-predicate", "benchmark.http_2xx:24"
    ]
    for uri in multi_https_test_server_fixture.getAllTestServerRootUris():
        nighthawk_client_args.append("--multi-target-endpoint")
        nighthawk_client_args.append(
            uri.replace("https://", "").replace("/", ""))

    parsed_json, stderr = multi_https_test_server_fixture.runNighthawkClient(
        nighthawk_client_args)

    counters = multi_https_test_server_fixture.getNighthawkCounterMapFromJson(
        parsed_json)
    assertCounterEqual(counters, "benchmark.http_2xx", 25)
    assertCounterEqual(counters, "upstream_cx_http1_total", 3)
    assertCounterGreater(counters, "upstream_cx_rx_bytes_total", 0)
    assertCounterEqual(counters, "upstream_cx_total", 3)
    assertCounterGreater(counters, "upstream_cx_tx_bytes_total", 0)
    assertCounterEqual(counters, "upstream_rq_pending_total", 3)
    assertCounterEqual(counters, "upstream_rq_total", 25)
    assertCounterEqual(counters, "default.total_match_count", 3)
    total_2xx = 0
    for parsed_server_json in multi_https_test_server_fixture.getAllTestServerStatisticsJsons(
    ):
        single_2xx = multi_https_test_server_fixture.getServerStatFromJson(
            parsed_server_json, "http.ingress_http.downstream_rq_2xx")
        assertBetweenInclusive(single_2xx, 8, 9)
        total_2xx += single_2xx
    assertBetweenInclusive(total_2xx, 24, 25)
コード例 #2
0
def test_multiple_backends_https_h1(multi_https_test_server_fixture):
  """Test that we can load-test multiple backends on https.

  Runs the CLI configured to use HTTP/1 with TLS against multiple test servers, and sanity
  checks statistics from both client and server.
  """
  nighthawk_client_args = [
      "--multi-target-use-https", "--multi-target-path", "/", "--duration", "100",
      "--termination-predicate", "benchmark.http_2xx:24"
  ]
  for uri in multi_https_test_server_fixture.getAllTestServerRootUris():
    nighthawk_client_args.append("--multi-target-endpoint")
    nighthawk_client_args.append(uri.replace("https://", "").replace("/", ""))

  parsed_json, stderr = multi_https_test_server_fixture.runNighthawkClient(nighthawk_client_args)

  counters = multi_https_test_server_fixture.getNighthawkCounterMapFromJson(parsed_json)
  asserts.assertCounterEqual(counters, "benchmark.http_2xx", 25)
  asserts.assertCounterGreater(counters, "upstream_cx_rx_bytes_total", 0)
  # Assert that we at least have 1 connection per backend. It is possible that
  # the # of upstream_cx > # of backend connections for H1 as new connections
  # will spawn if the existing clients cannot keep up with the RPS.
  asserts.assertCounterGreaterEqual(counters, "upstream_cx_http1_total", 3)
  asserts.assertCounterGreaterEqual(counters, "upstream_cx_total", 3)
  asserts.assertCounterGreaterEqual(counters, "upstream_rq_pending_total", 3)
  asserts.assertCounterGreater(counters, "upstream_cx_tx_bytes_total", 0)
  asserts.assertCounterEqual(counters, "upstream_rq_total", 25)
  asserts.assertCounterEqual(counters, "default.total_match_count", 3)
  for parsed_server_json in multi_https_test_server_fixture.getAllTestServerStatisticsJsons():
    single_2xx = multi_https_test_server_fixture.getServerStatFromJson(
        parsed_server_json, "http.ingress_http.downstream_rq_2xx")
    # Confirm that each backend receives some traffic
    asserts.assertGreaterEqual(single_2xx, 1)