From 91b4c9c013d4e57a107993d884027427acfbb82c Mon Sep 17 00:00:00 2001 From: Derek Argueta Date: Mon, 8 Jul 2019 09:31:26 -0700 Subject: [PATCH] [test] convert Outlier Detection test stubs to v2 YAML (#7485) Signed-off-by: Derek Argueta --- test/common/upstream/BUILD | 1 + .../upstream/outlier_detection_impl_test.cc | 26 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/test/common/upstream/BUILD b/test/common/upstream/BUILD index 8ced77fcc2c4..7bbf8314c71e 100644 --- a/test/common/upstream/BUILD +++ b/test/common/upstream/BUILD @@ -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", ], ) diff --git a/test/common/upstream/outlier_detection_impl_test.cc b/test/common/upstream/outlier_detection_impl_test.cc index bccf463c5e91..c7a3cb08abf3 100644 --- a/test/common/upstream/outlier_detection_impl_test.cc +++ b/test/common/upstream/outlier_detection_impl_test.cc @@ -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" @@ -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 detector(DetectorImpl::create( cluster_, outlier_detection, dispatcher_, runtime_, time_system_, event_logger_));