Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
c226497
Save state on origin timeing
oschaaf Jun 15, 2020
c6697de
Merge remote-tracking branch 'upstream/master' into origin-timings
oschaaf Jun 15, 2020
28e0d34
Fix clang-tidy, format, and test build
oschaaf Jun 16, 2020
94ad984
Merge remote-tracking branch 'upstream/master' into origin-timings
oschaaf Aug 19, 2020
933c589
stats naming
oschaaf Aug 19, 2020
a1691ec
Merge remote-tracking branch 'upstream/master' into origin-timings
oschaaf Aug 21, 2020
740d0ca
Track request receipt deltas. Configure response header name.
oschaaf Aug 21, 2020
1afe2f1
Save state before context switching
oschaaf Aug 21, 2020
ae0c08e
Merge remote-tracking branch 'upstream/master' into origin-timings
oschaaf Aug 21, 2020
3487e19
Merge remote-tracking branch 'upstream/master' into origin-timings
oschaaf Aug 24, 2020
1d1f03a
Fix format
oschaaf Aug 24, 2020
a9d99eb
Suppress clang-tidy on MUTABLE_CONSTRUCT_ON_FIRST_USE
oschaaf Aug 24, 2020
0aa8630
Proper locking, add TODOs and doc comments.
oschaaf Aug 24, 2020
db01e40
Merge remote-tracking branch 'upstream/master' into origin-timings
oschaaf Aug 24, 2020
5e48513
Small fixes
oschaaf Aug 24, 2020
d9569cb
Add unit test for StreamDecoder
oschaaf Aug 25, 2020
cf1170c
Review feedback
oschaaf Aug 26, 2020
421feb8
check_format introduced proto comment issues. Add punctuation.
oschaaf Aug 26, 2020
af148ea
Merge remote-tracking branch 'upstream/master' into origin-timings
oschaaf Aug 27, 2020
e813e75
Review feedback
oschaaf Aug 27, 2020
505495c
Save state on splitting out a separate extension and stopwatch
oschaaf Aug 27, 2020
5405dc9
Merge remote-tracking branch 'upstream/master' into origin-timings
oschaaf Aug 27, 2020
d858b55
Small corrections
oschaaf Aug 28, 2020
3cf32b8
Add threaded spam test for stopwatch. Add doc comments.
oschaaf Aug 28, 2020
35aee47
clang-tidy: fix for loop
oschaaf Aug 28, 2020
027c00f
Merge remote-tracking branch 'upstream/master' into origin-timings
oschaaf Aug 29, 2020
70502e1
Review feedback: doc comments
oschaaf Aug 29, 2020
a55bbe7
Wire up proto option
oschaaf Aug 31, 2020
d199313
Wire up TCLAP, add OptionImpl tests, regen CLI docs.
oschaaf Aug 31, 2020
a16d8dd
Address clang-tidy nit, better CLI/proto option description.
oschaaf Aug 31, 2020
f3008d9
Build time-tracking extension into test sever. Add end-to-end test.
oschaaf Aug 31, 2020
7774e2d
review feedback
oschaaf Sep 1, 2020
937fd88
Merge branch 'origin-timings' into origin-timings-tracking-option
oschaaf Sep 1, 2020
8152829
Fix clang-tidy nit.
oschaaf Sep 1, 2020
64cb19c
Merge remote-tracking branch 'upstream/master' into origin-timings-tr…
oschaaf Sep 1, 2020
af60b8d
Replace stopwatch shared_ptr to unique_ptr
oschaaf Sep 1, 2020
3996c65
Fix a few small nits & improve option description.
oschaaf Sep 1, 2020
228934a
Merge remote-tracking branch 'upstream/master' into origin-timings-tr…
oschaaf Sep 5, 2020
00b6861
Fix todo
oschaaf Sep 5, 2020
7cf2edd
Server extension: start factoring out common code / functionality.
oschaaf Sep 5, 2020
68ed58a
Review feedback
oschaaf Sep 9, 2020
01e30e5
Merge branch 'origin-timings-tracking-option' into server-extension-r…
oschaaf Sep 9, 2020
74f9717
Merge remote-tracking branch 'upstream/master' into origin-timings-tr…
oschaaf Sep 9, 2020
699b156
Merge branch 'origin-timings-tracking-option' into server-extension-r…
oschaaf Sep 9, 2020
54ca814
Doc & refactor integration test base
oschaaf Sep 9, 2020
594bbbe
Review feedback: option rename
oschaaf Sep 9, 2020
e36e9c1
Merge branch 'origin-timings-tracking-option' into server-extension-r…
oschaaf Sep 9, 2020
86f5d98
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 9, 2020
eae77cc
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 10, 2020
dddc710
review feedback for the http filter config base
oschaaf Sep 10, 2020
b1993a1
Review feedback
oschaaf Sep 10, 2020
6778723
tidy up
oschaaf Sep 10, 2020
809715e
Tidy up more
oschaaf Sep 10, 2020
f5f92ab
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 10, 2020
83e7001
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 11, 2020
8b3db6c
Review feedback: simplify the filter integration test base some more.
oschaaf Sep 11, 2020
44496b9
Move over the test-server extension to the new extension test base.
oschaaf Sep 12, 2020
4022a79
tidy up
oschaaf Sep 12, 2020
3861456
Add http_filter_base_test
oschaaf Sep 14, 2020
9d333ac
apply clang-tidy fix
oschaaf Sep 14, 2020
7f432b8
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 14, 2020
87bd08d
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 14, 2020
988d62a
review feedback sync
oschaaf Sep 14, 2020
9345b66
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 14, 2020
9be5141
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 14, 2020
9f0229a
Review feedback
oschaaf Sep 14, 2020
c31a93e
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 16, 2020
c32c92b
Review feedback
oschaaf Sep 16, 2020
5cdb2a0
Fix a typo
oschaaf Sep 16, 2020
cf13178
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 17, 2020
a7a6aca
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 17, 2020
3292e2b
Sync review feedback
oschaaf Sep 17, 2020
079cd01
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 18, 2020
746ad1a
Sync changes to http_filter_base_test.cc
oschaaf Sep 22, 2020
2b945c2
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 22, 2020
a9617b7
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 23, 2020
79b2508
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Sep 24, 2020
815478d
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Oct 5, 2020
838f366
Merge remote-tracking branch 'upstream/master' into server-extension-…
oschaaf Oct 5, 2020
2529ea6
Review feedback
oschaaf Oct 6, 2020
2bcbb2b
bump coverage thresholds
oschaaf Oct 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ function do_clang_tidy() {

function do_unit_test_coverage() {
export TEST_TARGETS="//test/... -//test:python_test"
export COVERAGE_THRESHOLD=93.2
export COVERAGE_THRESHOLD=94.0
echo "bazel coverage build with tests ${TEST_TARGETS}"
test/run_nighthawk_bazel_coverage.sh ${TEST_TARGETS}
exit 0
}

function do_integration_test_coverage() {
export TEST_TARGETS="//test:python_test"
export COVERAGE_THRESHOLD=78.0
export COVERAGE_THRESHOLD=78.6
echo "bazel coverage build with tests ${TEST_TARGETS}"
test/run_nighthawk_bazel_coverage.sh ${TEST_TARGETS}
exit 0
Expand Down
59 changes: 26 additions & 33 deletions source/server/http_test_server_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,53 @@ namespace Nighthawk {
namespace Server {

HttpTestServerDecoderFilterConfig::HttpTestServerDecoderFilterConfig(
nighthawk::server::ResponseOptions proto_config)
: server_config_(std::move(proto_config)) {}
const nighthawk::server::ResponseOptions& proto_config)
: FilterConfigurationBase(proto_config, "test-server") {}

HttpTestServerDecoderFilter::HttpTestServerDecoderFilter(
HttpTestServerDecoderFilterConfigSharedPtr config)
: config_(std::move(config)) {}

void HttpTestServerDecoderFilter::onDestroy() {}

void HttpTestServerDecoderFilter::sendReply() {
if (!json_merge_error_) {
std::string response_body(base_config_.response_body_size(), 'a');
if (request_headers_dump_.has_value()) {
response_body += *request_headers_dump_;
}
decoder_callbacks_->sendLocalReply(
static_cast<Envoy::Http::Code>(200), response_body,
[this](Envoy::Http::ResponseHeaderMap& direct_response_headers) {
Configuration::applyConfigToResponseHeaders(direct_response_headers, base_config_);
},
absl::nullopt, "");
} else {
decoder_callbacks_->sendLocalReply(
static_cast<Envoy::Http::Code>(500),
fmt::format("test-server didn't understand the request: {}", error_message_), nullptr,
absl::nullopt, "");
void HttpTestServerDecoderFilter::sendReply(const nighthawk::server::ResponseOptions& options) {
std::string response_body(options.response_body_size(), 'a');
if (request_headers_dump_.has_value()) {
response_body += *request_headers_dump_;
}
decoder_callbacks_->sendLocalReply(
static_cast<Envoy::Http::Code>(200), response_body,
[options](Envoy::Http::ResponseHeaderMap& direct_response_headers) {
Configuration::applyConfigToResponseHeaders(direct_response_headers, options);
},
absl::nullopt, "");
}

Envoy::Http::FilterHeadersStatus
HttpTestServerDecoderFilter::decodeHeaders(Envoy::Http::RequestHeaderMap& headers,
bool end_stream) {
// TODO(oschaaf): Add functionality to clear fields
base_config_ = config_->server_config();
const auto* request_config_header = headers.get(TestServer::HeaderNames::get().TestServerConfig);
if (request_config_header) {
json_merge_error_ = !Configuration::mergeJsonConfig(
request_config_header->value().getStringView(), base_config_, error_message_);
}
if (base_config_.echo_request_headers()) {
std::stringstream headers_dump;
headers_dump << "\nRequest Headers:\n" << headers;
request_headers_dump_ = headers_dump.str();
}
config_->computeEffectiveConfiguration(headers);
if (end_stream) {
sendReply();
if (!config_->maybeSendErrorReply(*decoder_callbacks_)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that this is worth bothering with, but I did find it mildly confusing that the result of maybeSendErrorReply is true if it did send an error reply.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that this would easier to read if bool maybeSendErrorReply() would be split up into bool haveErrorReply() and void sendErrorReply()?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. I'm not sure if I'm alone in feeling uncertain on which boolean value to expect from a maybe naming scheme though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we called it validateOrSendError.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following up on this, I like the suggestion, but while doing that, I realised that the return value would have to be inverted. The maybeXXX "naming scheme" usually returns true iff it did what it said it might do (sendErrorReply() in this case). When we rename to validateOrSendError() the method should probably return true if the configuration was valid? I think this would still be a good change to make, but it would become a little intrusive as there's a bunch of places where this is used already. The good part is that when this PR gets merged, we are in a much better to position to make mechanical refactors like this across all extensions. Filed #558 to track following up.

const absl::StatusOr<EffectiveFilterConfigurationPtr> effective_config =
config_->getEffectiveConfiguration();
if (effective_config.value()->echo_request_headers()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check that the value is ok instead of just calling value() directly? Or do we prefer to throw an exception here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybeSendErrorReply() will have returned true if the value wasn't OK, so we can't hit this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it. I had missed the connection between getEffective config and maybeSendError.

std::stringstream headers_dump;
headers_dump << "\nRequest Headers:\n" << headers;
request_headers_dump_ = headers_dump.str();
}
sendReply(*effective_config.value());
}
}
return Envoy::Http::FilterHeadersStatus::StopIteration;
}

Envoy::Http::FilterDataStatus HttpTestServerDecoderFilter::decodeData(Envoy::Buffer::Instance&,
bool end_stream) {
if (end_stream) {
sendReply();
if (!config_->maybeSendErrorReply(*decoder_callbacks_)) {
sendReply(*config_->getEffectiveConfiguration().value());
}
}
return Envoy::Http::FilterDataStatus::StopIterationNoBuffer;
}
Expand Down
15 changes: 5 additions & 10 deletions source/server/http_test_server_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@

#include "api/server/response_options.pb.h"

#include "server/http_filter_config_base.h"

namespace Nighthawk {
namespace Server {

// Basically this is left in as a placeholder for further configuration.
class HttpTestServerDecoderFilterConfig {
class HttpTestServerDecoderFilterConfig : public FilterConfigurationBase {
public:
HttpTestServerDecoderFilterConfig(nighthawk::server::ResponseOptions proto_config);
const nighthawk::server::ResponseOptions& server_config() { return server_config_; }

private:
const nighthawk::server::ResponseOptions server_config_;
HttpTestServerDecoderFilterConfig(const nighthawk::server::ResponseOptions& proto_config);
};

using HttpTestServerDecoderFilterConfigSharedPtr =
Expand All @@ -36,12 +34,9 @@ class HttpTestServerDecoderFilter : public Envoy::Http::StreamDecoderFilter {
void setDecoderFilterCallbacks(Envoy::Http::StreamDecoderFilterCallbacks&) override;

private:
void sendReply();
void sendReply(const nighthawk::server::ResponseOptions& options);
const HttpTestServerDecoderFilterConfigSharedPtr config_;
Envoy::Http::StreamDecoderFilterCallbacks* decoder_callbacks_;
nighthawk::server::ResponseOptions base_config_;
bool json_merge_error_{false};
std::string error_message_;
absl::optional<std::string> request_headers_dump_;
};

Expand Down
3 changes: 2 additions & 1 deletion source/server/http_time_tracking_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Envoy::Http::FilterDataStatus HttpTimeTrackingFilter::decodeData(Envoy::Buffer::

Envoy::Http::FilterHeadersStatus
HttpTimeTrackingFilter::encodeHeaders(Envoy::Http::ResponseHeaderMap& response_headers, bool) {
const auto effective_config = config_->getEffectiveConfiguration();
const absl::StatusOr<EffectiveFilterConfigurationPtr> effective_config =
config_->getEffectiveConfiguration();
if (effective_config.ok()) {
const std::string previous_request_delta_in_response_header =
effective_config.value()->emit_previous_request_delta_in_response_header();
Expand Down
Loading