Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion test/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ envoy_cc_test(
"//test/config/integration/certs",
],
deps = [
"//source/common/config:utility_lib",
"//source/common/protobuf:utility_lib",
"//source/server:lds_api_lib",
"//test/mocks/server:server_mocks",
"//test/test_common:environment_lib",
Expand Down
39 changes: 21 additions & 18 deletions test/server/lds_api_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "envoy/api/v2/lds.pb.h"

#include "common/config/utility.h"
#include "common/http/message_impl.h"
#include "common/protobuf/utility.h"

#include "server/lds_api.h"

Expand Down Expand Up @@ -35,15 +35,16 @@ class LdsApiTest : public testing::Test {
void setup() {
const std::string config_json = R"EOF(
{
"api_type": "REST",
"cluster": "foo_cluster",
"refresh_delay_ms": 1000
"api_config_source": {
"api_type": "REST",
"cluster_names": ["foo_cluster"],
"refresh_delay": "1s"
}
}
)EOF";

Json::ObjectSharedPtr config = Json::Factory::loadFromString(config_json);
envoy::api::v2::core::ConfigSource lds_config;
Config::Utility::translateLdsConfig(*config, lds_config);
MessageUtil::loadFromJson(config_json, lds_config);
lds_config.mutable_api_config_source()->set_api_type(
envoy::api::v2::core::ApiConfigSource::REST);
Upstream::ClusterManager::ClusterInfoMap cluster_map;
Expand Down Expand Up @@ -161,15 +162,16 @@ TEST_F(LdsApiTest, ValidateFail) {
TEST_F(LdsApiTest, UnknownCluster) {
const std::string config_json = R"EOF(
{
"api_type": "REST",
"cluster": "foo_cluster",
"refresh_delay_ms": 1000
}
"api_config_source": {
"api_type": "REST",
"cluster_names": ["foo_cluster"],
"refresh_delay": "1s"
}
}
)EOF";

Json::ObjectSharedPtr config = Json::Factory::loadFromString(config_json);
envoy::api::v2::core::ConfigSource lds_config;
Config::Utility::translateLdsConfig(*config, lds_config);
MessageUtil::loadFromJson(config_json, lds_config);
Upstream::ClusterManager::ClusterInfoMap cluster_map;
EXPECT_CALL(cluster_manager_, clusters()).WillOnce(Return(cluster_map));
EXPECT_THROW_WITH_MESSAGE(
Expand Down Expand Up @@ -275,15 +277,16 @@ TEST_F(LdsApiTest, BadLocalInfo) {
interval_timer_ = new Event::MockTimer(&dispatcher_);
const std::string config_json = R"EOF(
{
"api_type": "REST",
"cluster": "foo_cluster",
"refresh_delay_ms": 1000
}
"api_config_source": {
"api_type": "REST",
"cluster_names": ["foo_cluster"],
"refresh_delay": "1s"
}
}
)EOF";

Json::ObjectSharedPtr config = Json::Factory::loadFromString(config_json);
envoy::api::v2::core::ConfigSource lds_config;
Config::Utility::translateLdsConfig(*config, lds_config);
MessageUtil::loadFromJson(config_json, lds_config);
Upstream::ClusterManager::ClusterInfoMap cluster_map;
Upstream::MockClusterMockPrioritySet cluster;
cluster_map.emplace("foo_cluster", cluster);
Expand Down