Skip to content
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

bpf_metadata: add unit-test for proxylib l7 proto #1131

Merged
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
35 changes: 35 additions & 0 deletions tests/metadata_config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <cstdint>
#include <list>
#include <memory>
#include <string>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -481,6 +482,40 @@ TEST_F(MetadataConfigTest, EastWestL7LbMetadataNoOriginalSource) {
(cilium_mark_socket_option->mark_ >> 16) == 8);
}

TEST_F(MetadataConfigTest, ProxyLibNotConfigured) {
::cilium::BpfMetadata config{};

EXPECT_NO_THROW(initialize(config));

auto socket_metadata = config_->extractSocketMetadata(socket_);
EXPECT_TRUE(socket_metadata);

EXPECT_CALL(socket_, setRequestedApplicationProtocols(_)).Times(0);
mhofstetter marked this conversation as resolved.
Show resolved Hide resolved

socket_metadata->configureProxyLibApplicationProtocol(socket_);
}

TEST_F(MetadataConfigTest, ProxyLibConfigured) {
::cilium::BpfMetadata config{};

EXPECT_NO_THROW(initialize(config));

auto socket_metadata = config_->extractSocketMetadata(socket_);
EXPECT_TRUE(socket_metadata);

// set proxylib proto manually
socket_metadata->proxylib_l7_proto_ = "r2d2";

std::vector<std::string> protocols = {"h2c"};
EXPECT_CALL(socket_, requestedApplicationProtocols).WillOnce(testing::ReturnRef(protocols));

// proxylib protocol should be appended to the list of existing requested application protocols
const auto protos = std::vector<absl::string_view>{"h2c", "r2d2"};
EXPECT_CALL(socket_, setRequestedApplicationProtocols(protos));

socket_metadata->configureProxyLibApplicationProtocol(socket_);
}

} // namespace
} // namespace Cilium
} // namespace Envoy
Loading