-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI - cancel execution upon signal reception #367
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b973b75
Extract SignalHandler
oschaaf fb5c434
Remove accidentally left in comment
oschaaf 1bd1d31
Fix format
oschaaf fcba594
Merge remote-tracking branch 'upstream/master' into extract-signal-ha…
oschaaf ce5ead6
Amend according to clang-tidy's complaints
oschaaf 3f99119
Pass const ref
oschaaf 111ba5d
Merge remote-tracking branch 'upstream/master' into extract-signal-ha…
oschaaf 89dfdf6
Merge remote-tracking branch 'upstream/master' into extract-signal-ha…
oschaaf c457af6
Merge remote-tracking branch 'upstream/master' into extract-signal-ha…
oschaaf 04eec56
CLI: Handle signals, allow cancellation of executions
oschaaf a11050f
Add lock guarding of the cancellation process + tests
oschaaf 781df87
Merge remote-tracking branch 'upstream/master' into execution-cancell…
oschaaf 2c04d10
s/cancel_requests/graceful_stop_requested/
oschaaf 55f694f
Eliminate the NullTerminationPredicate: dead code
oschaaf d1a696b
Remove debug print line
oschaaf 3c35f86
Merge remote-tracking branch 'upstream/master' into execution-cancell…
oschaaf 9e0d9b2
Merge remote-tracking branch 'upstream/master' into execution-cancell…
oschaaf 57d71f0
Merge remote-tracking branch 'upstream/master' into execution-cancell…
oschaaf 1fddbec
Partially address review feedback
oschaaf 20e6108
Review feedback pt II
oschaaf 3198623
Review feedback
oschaaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -80,6 +80,8 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger | |
*/ | ||
void shutdown() override; | ||
|
||
bool requestExecutionCancellation() override; | ||
|
||
private: | ||
/** | ||
* @brief Creates a cluster for usage by a remote request source. | ||
|
@@ -99,7 +101,13 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger | |
void maybeCreateTracingDriver(const envoy::config::trace::v3::Tracing& configuration); | ||
|
||
void configureComponentLogLevels(spdlog::level::level_enum level); | ||
const std::vector<ClientWorkerPtr>& createWorkers(const uint32_t concurrency); | ||
/** | ||
* Prepare the ProcessImpl instance by creating and configuring the workers it needs for execution | ||
* of the load test. | ||
* | ||
* @param concurrency the amount of workers that should be created. | ||
*/ | ||
void createWorkers(const uint32_t concurrency); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (optional) Is this a good time to document the method? |
||
std::vector<StatisticPtr> vectorizeStatisticPtrMap(const StatisticPtrMap& statistics) const; | ||
std::vector<StatisticPtr> | ||
mergeWorkerStatistics(const std::vector<ClientWorkerPtr>& workers) const; | ||
|
@@ -145,6 +153,8 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger | |
Envoy::Server::ValidationAdmin admin_; | ||
Envoy::ProtobufMessage::ProdValidationContextImpl validation_context_; | ||
bool shutdown_{true}; | ||
Envoy::Thread::MutexBasicLockable workers_lock_; | ||
bool cancelled_{false}; | ||
}; | ||
|
||
} // namespace Client | ||
|
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
import logging | ||
import os | ||
import subprocess | ||
import sys | ||
import pytest | ||
import time | ||
from threading import Thread | ||
|
||
from test.integration.common import IpVersion | ||
from test.integration.integration_test_fixtures import ( | ||
|
@@ -654,6 +658,35 @@ def test_http_request_release_timing(http_test_server_fixture, qps_parameterizat | |
assertCounterEqual(counters, "benchmark.http_2xx", (total_requests)) | ||
|
||
|
||
def _send_sigterm(process): | ||
# Sleep for a while, under tsan the client needs a lot of time | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a Python style docstring, since the function is public. |
||
# to start up. 10 seconds has been determined to work through | ||
# emperical observation. | ||
time.sleep(10) | ||
process.terminate() | ||
|
||
|
||
def test_cancellation(http_test_server_fixture): | ||
""" | ||
Make sure that we can use signals to cancel execution. | ||
""" | ||
args = [ | ||
http_test_server_fixture.nighthawk_client_path, "--concurrency", "2", | ||
http_test_server_fixture.getTestServerRootUri(), "--duration", "1000", "--output-format", | ||
"json" | ||
] | ||
client_process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
Thread(target=(lambda: _send_sigterm(client_process))).start() | ||
stdout, stderr = client_process.communicate() | ||
client_process.wait() | ||
output = stdout.decode('utf-8') | ||
assertEqual(client_process.returncode, 0) | ||
parsed_json = json.loads(output) | ||
counters = http_test_server_fixture.getNighthawkCounterMapFromJson(parsed_json) | ||
assertCounterEqual(counters, "graceful_stop_requested", 2) | ||
oschaaf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assertCounterGreaterEqual(counters, "benchmark.http_2xx", 1) | ||
|
||
|
||
def _run_client_with_args(args): | ||
return run_binary_with_args("nighthawk_client", args) | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to reviewers: The "hide whitespace" toggle in Github makes this a lot more fun to review.
(The scope introduced for the lock guard introduces a lot of whitespace noise).