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

[test] convert Outlier Detection test stubs to v2 YAML #7485

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/upstream/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ envoy_cc_test(
"//test/mocks/runtime:runtime_mocks",
"//test/mocks/upstream:upstream_mocks",
"//test/test_common:simulated_time_system_lib",
"//test/test_common:utility_lib",
],
)

Expand Down
26 changes: 12 additions & 14 deletions test/common/upstream/outlier_detection_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "test/mocks/runtime/mocks.h"
#include "test/mocks/upstream/mocks.h"
#include "test/test_common/simulated_time_system.h"
#include "test/test_common/utility.h"

#include "absl/types/optional.h"
#include "gmock/gmock.h"
Expand Down Expand Up @@ -118,23 +119,20 @@ class OutlierDetectorImplTest : public testing::Test {
};

TEST_F(OutlierDetectorImplTest, DetectorStaticConfig) {
const std::string json = R"EOF(
{
"interval_ms" : 100,
"base_ejection_time_ms" : 10000,
"consecutive_5xx" : 10,
"max_ejection_percent" : 50,
"enforcing_consecutive_5xx" : 10,
"enforcing_success_rate": 20,
"success_rate_minimum_hosts": 50,
"success_rate_request_volume": 200,
"success_rate_stdev_factor": 3000
}
const std::string yaml = R"EOF(
interval: 0.1s
base_ejection_time: 10s
consecutive_5xx: 10
max_ejection_percent: 50
enforcing_consecutive_5xx: 10
enforcing_success_rate: 20
success_rate_minimum_hosts: 50
success_rate_request_volume: 200
success_rate_stdev_factor: 3000
)EOF";

envoy::api::v2::cluster::OutlierDetection outlier_detection;
Json::ObjectSharedPtr custom_config = Json::Factory::loadFromString(json);
Config::CdsJson::translateOutlierDetection(*custom_config, outlier_detection);
TestUtility::loadFromYaml(yaml, outlier_detection);
EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(100)));
std::shared_ptr<DetectorImpl> detector(DetectorImpl::create(
cluster_, outlier_detection, dispatcher_, runtime_, time_system_, event_logger_));
Expand Down