Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 = "95038feabf260c3937465951d5da603d31ea3bd4" # Aug 12, 2021
ENVOY_SHA = "4a584b02c24ac24362eff2550977616f86a194e61106e15f723e1cf961ca145d"
ENVOY_COMMIT = "dee7021c605243bb0b422a63be4d1c7bc7191bd5" # Aug 18, 2021
ENVOY_SHA = "4107f68f080f53130c4c44677322a5844dc62c44743d394722af66a40da949f8"

HDR_HISTOGRAM_C_VERSION = "0.11.2" # October 12th, 2020
HDR_HISTOGRAM_C_SHA = "637f28b5f64de2e268131e4e34e6eef0b91cf5ff99167db447d9b2825eae6bad"
Expand Down
6 changes: 6 additions & 0 deletions include/nighthawk/common/request_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ class RequestSource {
* needed, for example).
*/
virtual void initOnThread() PURE;

/**
* Will be called on an initialized and running worker thread, after the work
* has been done and just before the worker gets destroyed.
*/
virtual void destroyOnThread() PURE;
};

using RequestSourcePtr = std::unique_ptr<RequestSource>;
Expand Down
5 changes: 4 additions & 1 deletion source/client/client_worker_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ void ClientWorkerImpl::work() {
// should be consistent.
}

void ClientWorkerImpl::shutdownThread() { benchmark_client_->terminate(); }
void ClientWorkerImpl::shutdownThread() {
benchmark_client_->terminate();
request_generator_->destroyOnThread();
}

void ClientWorkerImpl::requestExecutionCancellation() {
// We just bump a counter, which is watched by a static termination predicate.
Expand Down
6 changes: 6 additions & 0 deletions source/common/request_source_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ void RemoteRequestSourceImpl::connectToRequestStreamGrpcService() {

void RemoteRequestSourceImpl::initOnThread() { connectToRequestStreamGrpcService(); }

void RemoteRequestSourceImpl::destroyOnThread() {
// The RequestStreamGrpcClientImpl uses Envoy::Grpc::AsyncClient which demands
// to be destroyed on the same thread it was constructed from.
grpc_client_.reset();
}

RequestGenerator RemoteRequestSourceImpl::get() {
return [this]() -> RequestPtr { return grpc_client_->maybeDequeue(); };
}
Expand Down
2 changes: 2 additions & 0 deletions source/common/request_source_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class StaticRequestSourceImpl : public BaseRequestSourceImpl {
const uint64_t max_yields = UINT64_MAX);
RequestGenerator get() override;
void initOnThread() override{};
void destroyOnThread() override{};

private:
const HeaderMapPtr header_;
Expand Down Expand Up @@ -55,6 +56,7 @@ class RemoteRequestSourceImpl : public BaseRequestSourceImpl {
uint32_t header_buffer_length);
RequestGenerator get() override;
void initOnThread() override;
void destroyOnThread() override;

private:
void connectToRequestStreamGrpcService();
Expand Down
3 changes: 2 additions & 1 deletion source/request_source/request_options_list_plugin_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,6 @@ RequestGenerator OptionsListRequestSource::get() {
}

void OptionsListRequestSource::initOnThread() {}
void OptionsListRequestSource::destroyOnThread() {}

} // namespace Nighthawk
} // namespace Nighthawk
3 changes: 2 additions & 1 deletion source/request_source/request_options_list_plugin_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class OptionsListRequestSource : public RequestSource {

// default implementation
void initOnThread() override;
void destroyOnThread() override;

private:
Envoy::Http::RequestHeaderMapPtr header_;
Expand Down Expand Up @@ -104,4 +105,4 @@ class InLineOptionsListRequestSourceFactory : public virtual RequestSourcePlugin
// This factory will be activated through RequestSourceFactory in factories.h
DECLARE_FACTORY(InLineOptionsListRequestSourceFactory);

} // namespace Nighthawk
} // namespace Nighthawk
1 change: 1 addition & 0 deletions test/client_worker_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ClientWorkerTest : public Test {
.Times(1)
.WillOnce(Return(ByMove(std::unique_ptr<RequestSource>(request_generator_))));
EXPECT_CALL(*request_generator_, initOnThread());
EXPECT_CALL(*request_generator_, destroyOnThread());

EXPECT_CALL(termination_predicate_factory_, create(_, _, _))
.WillOnce(Return(ByMove(createMockTerminationPredicate())));
Expand Down
3 changes: 2 additions & 1 deletion test/mocks/common/mock_request_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class MockRequestSource : public RequestSource {
MockRequestSource();
MOCK_METHOD(RequestGenerator, get, ());
MOCK_METHOD(void, initOnThread, ());
MOCK_METHOD(void, destroyOnThread, ());
};

} // namespace Nighthawk
} // namespace Nighthawk
3 changes: 2 additions & 1 deletion test/request_source/stub_plugin_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ RequestGenerator StubRequestSource::get() {
}

void StubRequestSource::initOnThread() {}
void StubRequestSource::destroyOnThread() {}

} // namespace Nighthawk
} // namespace Nighthawk
3 changes: 2 additions & 1 deletion test/request_source/stub_plugin_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class StubRequestSource : public RequestSource {

// default implementation
void initOnThread() override;
void destroyOnThread() override;

private:
const double test_value_;
Expand Down Expand Up @@ -53,4 +54,4 @@ class StubRequestSourcePluginConfigFactory : public virtual RequestSourcePluginC

// This factory will be activated through RequestSourceFactory in factories.h
DECLARE_FACTORY(StubRequestSourcePluginConfigFactory);
} // namespace Nighthawk
} // namespace Nighthawk