Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 bazel/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

ENVOY_COMMIT = "2c0e1f21837fdf78cc91d2eb8c3735731d510f7e" # June 2, 2021
ENVOY_SHA = "3b3a3f2c6cddcd0d9650e50b294ca211f4171c09b8ac7a3af86847329b24281b"
ENVOY_COMMIT = "ff2c0e517c8677dd1c553e1c6ef55d2b14cdd996" # June 2, 2021
ENVOY_SHA = "ebeba4ff8f54e9a7f9f86997b696d4b647a2471685e569af9bbc38dd9b496dbb"

HDR_HISTOGRAM_C_VERSION = "0.11.2" # October 12th, 2020
HDR_HISTOGRAM_C_SHA = "637f28b5f64de2e268131e4e34e6eef0b91cf5ff99167db447d9b2825eae6bad"
Expand Down
20 changes: 12 additions & 8 deletions source/client/benchmark_client_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,21 @@ BenchmarkClientHttpImpl::BenchmarkClientHttpImpl(
}

void BenchmarkClientHttpImpl::terminate() {
if (pool() != nullptr && pool()->hasActiveConnections()) {
absl::optional<Envoy::Upstream::HttpPoolData> pool_data = pool();
if (pool_data.has_value() &&
Envoy::Upstream::HttpPoolDataPeer(pool_data.value()).getPool()->hasActiveConnections()) {
// We don't report what happens after this call in the output, but latencies may still be
// reported via callbacks. This may happen after a long time (60s), which HdrHistogram can't
// track the way we configure it today, as that exceeds the max that it can record.
// No harm is done, but it does result in log lines warning about it. Avoid that, by
// disabling latency measurement here.
setShouldMeasureLatencies(false);
pool()->addDrainedCallback([this]() -> void {
drain_timer_->disableTimer();
dispatcher_.exit();
});
Envoy::Upstream::HttpPoolDataPeer(pool_data.value())
.getPool()
->addDrainedCallback([this]() -> void {
drain_timer_->disableTimer();
dispatcher_.exit();
});
// Set up a timer with a callback which caps the time we wait for the pool to drain.
drain_timer_ = dispatcher_.createTimer([this]() -> void {
ENVOY_LOG(info, "Wait for the connection pool drain timed out, proceeding to hard shutdown.");
Expand Down Expand Up @@ -147,8 +151,8 @@ StatisticPtrMap BenchmarkClientHttpImpl::statistics() const {
};

bool BenchmarkClientHttpImpl::tryStartRequest(CompletionCallback caller_completion_callback) {
auto* pool_ptr = pool();
if (pool_ptr == nullptr) {
absl::optional<Envoy::Upstream::HttpPoolData> pool_data = pool();
if (!pool_data.has_value()) {
return false;
}
if (provide_resource_backpressure_) {
Expand Down Expand Up @@ -185,7 +189,7 @@ bool BenchmarkClientHttpImpl::tryStartRequest(CompletionCallback caller_completi
*statistic_.origin_latency_statistic, request->header(), shouldMeasureLatencies(),
content_length, generator_, http_tracer_, latency_response_header_name_);
requests_initiated_++;
pool_ptr->newStream(*stream_decoder, *stream_decoder);
pool_data.value().newStream(*stream_decoder, *stream_decoder);
return true;
}

Expand Down
20 changes: 19 additions & 1 deletion source/client/benchmark_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,26 @@

#include "common/statistic_impl.h"

#include "source/client/stream_decoder.h"
#include "source/common/statistic_impl.h"

#include "client/stream_decoder.h"

// TODO(#695): temporary hack to until Envoy::Upstream::HttpPoolData supports
// hasActiveConnections
namespace Envoy {
namespace Upstream {
class HttpPoolDataPeer {
public:
HttpPoolDataPeer(HttpPoolData& data) : data_(data) {}
Http::ConnectionPool::Instance* getPool() { return data_.pool_; };

private:
HttpPoolData& data_;
};
} // namespace Upstream
} // namespace Envoy

namespace Nighthawk {
namespace Client {

Expand Down Expand Up @@ -135,7 +153,7 @@ class BenchmarkClientHttpImpl : public BenchmarkClient,
void exportLatency(const uint32_t response_code, const uint64_t latency_ns) override;

// Helpers
Envoy::Http::ConnectionPool::Instance* pool() {
absl::optional<::Envoy::Upstream::HttpPoolData> pool() {
auto proto = use_h2_ ? Envoy::Http::Protocol::Http2 : Envoy::Http::Protocol::Http11;
const auto thread_local_cluster = cluster_manager_->getThreadLocalCluster(cluster_name_);
return thread_local_cluster->httpConnPool(Envoy::Upstream::ResourcePriority::Default, proto,
Expand Down
3 changes: 2 additions & 1 deletion test/benchmark_http_client_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class BenchmarkClientHttpTest : public Test {
EXPECT_CALL(cluster_manager(), getThreadLocalCluster(_))
.WillRepeatedly(Return(&thread_local_cluster_));
EXPECT_CALL(thread_local_cluster_, info()).WillRepeatedly(Return(cluster_info_));
EXPECT_CALL(thread_local_cluster_, httpConnPool(_, _, _)).WillRepeatedly(Return(&pool_));
EXPECT_CALL(thread_local_cluster_, httpConnPool(_, _, _))
.WillRepeatedly(Return(Envoy::Upstream::HttpPoolData([]() {}, &pool_)));

auto& tracer = static_cast<Envoy::Tracing::MockHttpTracer&>(*http_tracer_);
EXPECT_CALL(tracer, startSpan_(_, _, _, _))
Expand Down