-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factory plugin implementation (#566)
Adding implementation in the factory_impl class for loading request source plugins. This also introduces python tests for the previous PR and undoes the temporary hack to reduce test_integration_coverage threshold in issue #564. Signed-off-by: William Juan <66322422+wjuan-AFK@users.noreply.github.com>
- Loading branch information
Showing
8 changed files
with
231 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Tests for the nighthawk_service binary.""" | ||
|
||
import pytest | ||
import os | ||
|
||
from test.integration.integration_test_fixtures import (http_test_server_fixture, server_config) | ||
from test.integration import utility | ||
from test.integration import asserts | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"request_source_config,expected_min,expected_max", | ||
[ | ||
pytest.param(""" | ||
{ | ||
name:"nighthawk.in-line-options-list-request-source-plugin", | ||
typed_config:{ | ||
"@type":"type.googleapis.com/nighthawk.request_source.InLineOptionsListRequestSourceConfig", | ||
options_list:{ | ||
options:[ | ||
{request_method:"1",request_body_size:"1",request_headers:[{header:{"key":"x-nighthawk-test-server-config","value":"{response_body_size:13}"}}]}, | ||
{request_method:"1",request_body_size:"2",request_headers:[{header:{"key":"x-nighthawk-test-server-config","value":"{response_body_size:17}"}}]}, | ||
] | ||
}, | ||
} | ||
}""", | ||
13, | ||
17, | ||
id="in-line"), | ||
pytest.param(""" | ||
{ | ||
name:"nighthawk.file-based-request-source-plugin", | ||
typed_config:{ | ||
"@type":"type.googleapis.com/nighthawk.request_source.FileBasedOptionsListRequestSourceConfig", | ||
file_path:"%s", | ||
} | ||
}""" % (os.path.dirname(os.path.abspath(os.path.dirname(__file__))) + | ||
"/request_source/test_data/test-config.yaml"), | ||
13, | ||
17, | ||
id="file-based"), | ||
], | ||
) | ||
def test_request_source_plugin_happy_flow_parametrized(http_test_server_fixture, | ||
request_source_config, expected_min, | ||
expected_max): | ||
"""Test that the nighthawkClient can run with request-source-plugin option.""" | ||
parsed_json, _ = http_test_server_fixture.runNighthawkClient([ | ||
"--termination-predicate", "benchmark.http_2xx:5", "--rps 10", | ||
"--request-source-plugin-config %s" % request_source_config, | ||
http_test_server_fixture.getTestServerRootUri(), "--request-header", "host: sni.com" | ||
]) | ||
counters = http_test_server_fixture.getNighthawkCounterMapFromJson(parsed_json) | ||
global_histograms = http_test_server_fixture.getNighthawkGlobalHistogramsbyIdFromJson(parsed_json) | ||
asserts.assertGreaterEqual(counters["benchmark.http_2xx"], 5) | ||
asserts.assertEqual(int(global_histograms["benchmark_http_client.response_body_size"]["raw_max"]), | ||
expected_max) | ||
asserts.assertEqual(int(global_histograms["benchmark_http_client.response_body_size"]["raw_min"]), | ||
expected_min) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
options: | ||
- request_body_size: 10 | ||
- request_method: 1 | ||
request_body_size: 10 | ||
request_headers: | ||
- { header: { key: ":path", value: "/a" } } | ||
- { header: { key: "foo", value: "bar" } } | ||
- { header: { key: "foo", value: "bar2" } } | ||
- { header: { key: "x-nh", value: "1" } } | ||
- request_body_size: 10 | ||
- { header: { key: ":path", value: "/a" } } | ||
- { header: { key: "x-nighthawk-test-server-config", value: "{response_body_size:13}" } } | ||
- request_method: 1 | ||
request_body_size: 10 | ||
request_headers: | ||
- { header: { key: ":path", value: "/b" } } | ||
- { header: { key: "bar", value: "foo" } } | ||
- { header: { key: "bar", value: "foo2" } } | ||
- { header: { key: "x-nh", value: "2" } } | ||
- { header: { key: ":path", value: "/b" } } | ||
- { header: { key: "x-nighthawk-test-server-config", value: "{response_body_size:17}" } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters