Exemplo n.º 1
0
def test_count_log_lines_with_substring_counts_only_lines_with_substring():
    """Test that only lines with substring are counted."""
    logs = """
  DEBUG: log example 1 \r\n
  ERROR: log example 2 \r\n
  ERROR: log example 3 \r\n
  INFO: log example 1 \r\n
  """
    count = utility.count_log_lines_with_substring(logs, "ERROR")
    assert count == 2
Exemplo n.º 2
0
def test_count_log_lines_with_substring_returns_zero_for_no_matches():
    """Test that returns zero if there are no matching lines."""
    logs = """
  DEBUG: log example 1 \r\n
  ERROR: log example 2 \r\n
  ERROR: log example 3 \r\n
  INFO: log example 1 \r\n
  """
    count = utility.count_log_lines_with_substring(logs, "log example 4")
    assert count == 0
def test_h1_pool_strategy_lru(http_test_server_fixture):
    """Test connection re-use strategies of the http 1 connection pool.

  Test that with the "least recently used" (lru) strategy all connections are used with roughly equal distribution.
  """
    requests = 12
    connections = 3
    _, logs = http_test_server_fixture.runNighthawkClient([
        "--rps",
        "5",
        "-v trace",
        "--duration",
        "20",
        "--connections",
        str(connections),
        "--prefetch-connections",
        "--experimental-h1-connection-reuse-strategy",
        "lru",
        "--termination-predicate",
        # termination-predicate takes affect when it exceeds the limit. Therefore, set the limit to 1 less than the desired number of requests.
        "benchmark.http_2xx:%d" % (requests - 1),
        http_test_server_fixture.getTestServerRootUri()
    ])

    line_counts = []
    for i in range(1, connections):
        line_counts.append(
            float(
                utility.count_log_lines_with_substring(
                    logs, "[C%d] message complete" % i)))

    average_line_count = sum(line_counts) / len(line_counts)
    for line_count in line_counts:
        asserts.assertBetweenInclusive(
            line_count,
            # provide a little slack. Minimum of 2 as envoy logs "message complete" twice per request.
            average_line_count - 2,
            average_line_count + 2)
Exemplo n.º 4
0
def test_count_log_lines_with_substring_returns_zero_with_empty_logs():
    """Test that returns zero if there are no logs."""
    logs = ""
    count = utility.count_log_lines_with_substring(logs, "log example 4")
    assert count == 0