Skip to content

Commit

Permalink
[test] convert Outlier Detection test stubs to v2 YAML (envoyproxy#7485)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Argueta <dereka@pinterest.com>
  • Loading branch information
derekargueta authored and alyssawilk committed Jul 8, 2019
1 parent 18b8f19 commit 91b4c9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
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

0 comments on commit 91b4c9c

Please sign in to comment.