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
34 changes: 34 additions & 0 deletions test/server/server_corpus/invalid_lb_subset_config

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions test/server/server_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,34 @@ makeHermeticPathsAndPorts(Fuzz::PerTestEnvironment& test_env,
return output;
}

// When single_host_per_subset is set to be true, only expect 1 subset selector and 1 key inside the
// selector.
bool validateLbSubsetConfig(const envoy::config::bootstrap::v3::Bootstrap& input) {
for (auto& cluster : input.static_resources().clusters()) {
bool use_single_host_per_subset = 0;
int subset_selectors = 0;
for (auto& subset_selector : cluster.lb_subset_config().subset_selectors()) {
subset_selectors++;
if (subset_selector.single_host_per_subset()) {
use_single_host_per_subset = true;
if (subset_selector.keys().size() != 1) {
return false;
}
}
}
if (use_single_host_per_subset && subset_selectors != 1) {
Comment thread
asraa marked this conversation as resolved.
Outdated
return false;
}
}
return true;
}

DEFINE_PROTO_FUZZER(const envoy::config::bootstrap::v3::Bootstrap& input) {

if (!validateLbSubsetConfig(input)) {
Comment thread
asraa marked this conversation as resolved.
return;
}

testing::NiceMock<MockOptions> options;
DefaultListenerHooks hooks;
testing::NiceMock<MockHotRestart> restart;
Expand Down