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

runtime: add static layer case to loader impl #7932

Merged
merged 5 commits into from
Aug 15, 2019
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
3 changes: 3 additions & 0 deletions source/common/runtime/runtime_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@ LoaderImpl::LoaderImpl(Event::Dispatcher& dispatcher, ThreadLocal::SlotAllocator
throw EnvoyException(absl::StrCat("Duplicate layer name: ", layer.name()));
}
switch (layer.layer_specifier_case()) {
case envoy::config::bootstrap::v2::RuntimeLayer::kStaticLayer:
// Nothing needs to be done here.
break;
case envoy::config::bootstrap::v2::RuntimeLayer::kAdminLayer:
if (admin_layer_ != nullptr) {
throw EnvoyException(
Expand Down
1 change: 1 addition & 0 deletions test/common/runtime/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ envoy_cc_test(
"//test/mocks/thread_local:thread_local_mocks",
"//test/mocks/upstream:upstream_mocks",
"//test/test_common:environment_lib",
"//test/test_common:logging_lib",
],
)

Expand Down
6 changes: 6 additions & 0 deletions test/common/runtime/runtime_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "test/mocks/thread_local/mocks.h"
#include "test/mocks/upstream/mocks.h"
#include "test/test_common/environment.h"
#include "test/test_common/logging.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"
Expand Down Expand Up @@ -496,6 +497,11 @@ TEST_F(StaticLoaderImplTest, All) {
testNewOverrides(*loader_, store_);
}

// Validate that Static Layer does not log as unsupported.
TEST_F(StaticLoaderImplTest, NoUnsupportedStaticLog) {
EXPECT_LOG_NOT_CONTAINS("warning", "Skipping unsupported runtime layer", setup());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you are in here can you add a test for the warning also? Thank you!

/wait

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, we actually shouldn't be able to get to this condition ever since there's a proto constraint that validates that we specify one of static/disk/admin/rtds. It'd run in to a proto validation error first. I suppose the warning would only come up if a new layered_runtime was added without support in LoaderImpl.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if there is a constraint, just remove the warning instead and use NOT_REACHED

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this test is useful anymore. Can you revert these changes? Thank you!

/wait

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that, should just be the NOT_REACHED case now (with proto validator).

}

// Validate proto parsing sanity.
TEST_F(StaticLoaderImplTest, ProtoParsing) {
base_ = TestUtility::parseYaml<ProtobufWkt::Struct>(R"EOF(
Expand Down