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
1 change: 1 addition & 0 deletions test/common/grpc/grpc_client_integration_test_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class HelloworldStream : public MockAsyncStreamCallbacks<helloworld::HelloReply>
reply_headers->addReference(value.first, value.second);
}
expectInitialMetadata(metadata);
fake_stream_->startGrpcStream(false);
fake_stream_->encodeHeaders(Http::TestResponseHeaderMapImpl(*reply_headers), false);
}

Expand Down
8 changes: 6 additions & 2 deletions test/integration/fake_upstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,12 @@ AssertionResult FakeStream::waitForReset(milliseconds timeout) {
return AssertionSuccess();
}

void FakeStream::startGrpcStream() {
encodeHeaders(Http::TestResponseHeaderMapImpl{{":status", "200"}}, false);
void FakeStream::startGrpcStream(bool send_headers) {
ASSERT(!grpc_stream_started_, "gRPC stream should not be started more than once");
grpc_stream_started_ = true;
if (send_headers) {
encodeHeaders(Http::TestResponseHeaderMapImpl{{":status", "200"}}, false);
}
}

void FakeStream::finishGrpcStream(Grpc::Status::GrpcStatus status) {
Expand Down
5 changes: 4 additions & 1 deletion test/integration/fake_upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ class FakeStream : public Http::RequestDecoder,
waitForReset(std::chrono::milliseconds timeout = TestUtility::DefaultTimeout);

// gRPC convenience methods.
void startGrpcStream();
void startGrpcStream(bool send_headers = true);
void finishGrpcStream(Grpc::Status::GrpcStatus status);
template <class T> void sendGrpcMessage(const T& message) {
ASSERT(grpc_stream_started_,
"start gRPC stream by calling startGrpcStream before sending a message");
auto serialized_response = Grpc::Common::serializeToGrpcFrame(message);
encodeData(*serialized_response, false);
ENVOY_LOG(debug, "Sent gRPC message: {}", message.DebugString());
Expand Down Expand Up @@ -249,6 +251,7 @@ class FakeStream : public Http::RequestDecoder,
absl::node_hash_map<std::string, uint64_t> duplicated_metadata_key_count_;
std::unique_ptr<StreamInfo::StreamInfo> stream_info_;
bool received_data_{false};
bool grpc_stream_started_{false};
};

using FakeStreamPtr = std::unique_ptr<FakeStream>;
Expand Down
1 change: 1 addition & 0 deletions test/integration/health_check_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ class GrpcHealthCheckIntegrationTest : public Event::TestUsingSimulatedTime,
void sendGrpcResponse(uint32_t cluster_idx,
const Http::TestResponseHeaderMapImpl& response_headers,
const grpc::health::v1::HealthCheckResponse& health_check_response) {
clusters_[cluster_idx].host_stream_->startGrpcStream(false);
clusters_[cluster_idx].host_stream_->encodeHeaders(response_headers, false);
clusters_[cluster_idx].host_stream_->sendGrpcMessage(health_check_response);
clusters_[cluster_idx].host_stream_->finishGrpcStream(Grpc::Status::WellKnownGrpcStatus::Ok);
Expand Down