Skip to content
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 source/extensions/common/wasm/wasm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ static bool createWasmInternal(const VmConfig& vm_config, const PluginSharedPtr&
ENVOY_LOG_TO_LOGGER(Envoy::Logger::Registry::getLog(Envoy::Logger::Id::wasm), trace,
fmt::format("Failed to load Wasm code (fetching) from {}", source));
cb(nullptr);
return false;
} else {
remote_data_provider = std::make_unique<Config::DataSource::RemoteAsyncDataProvider>(
cluster_manager, init_manager, vm_config.code().remote(), dispatcher, random, true,
Expand Down
23 changes: 15 additions & 8 deletions test/extensions/filters/http/wasm/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ using testing::ReturnRef;

namespace Envoy {
namespace Extensions {

using Common::Wasm::WasmException;

namespace HttpFilters {
namespace Wasm {

Expand Down Expand Up @@ -162,8 +165,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadInlineBadCode) {
TestUtility::loadFromYaml(yaml, proto_config);
WasmFilterConfig factory;
EXPECT_THROW_WITH_MESSAGE(factory.createFilterFactoryFromProto(proto_config, "stats", context_),
Extensions::Common::Wasm::WasmException,
"Unable to create Wasm HTTP filter ");
WasmException, "Unable to create Wasm HTTP filter ");
}

TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasm) {
Expand Down Expand Up @@ -253,7 +255,8 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailOnUncachedThenSucceed) {
return &request;
}));

factory.createFilterFactoryFromProto(proto_config, "stats", context_);
EXPECT_THROW_WITH_MESSAGE(factory.createFilterFactoryFromProto(proto_config, "stats", context_),
WasmException, "Unable to create Wasm HTTP filter ");

EXPECT_CALL(init_watcher_, ready());
context_.initManager().initialize(init_watcher_);
Expand All @@ -264,7 +267,7 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailOnUncachedThenSucceed) {

EXPECT_CALL(context_, initManager()).WillRepeatedly(ReturnRef(init_manager2));

Http::FilterFactoryCb cb = factory.createFilterFactoryFromProto(proto_config, "stats", context_);
auto cb = factory.createFilterFactoryFromProto(proto_config, "stats", context_);

EXPECT_CALL(init_watcher2, ready());
init_manager2.initialize(init_watcher2);
Expand Down Expand Up @@ -320,7 +323,8 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailCachedThenSucceed) {
}));

// Case 1: fail and fetch in the background, got 503, cache failure.
factory.createFilterFactoryFromProto(proto_config, "stats", context_);
EXPECT_THROW_WITH_MESSAGE(factory.createFilterFactoryFromProto(proto_config, "stats", context_),
WasmException, "Unable to create Wasm HTTP filter ");

EXPECT_CALL(init_watcher_, ready());
context_.initManager().initialize(init_watcher_);
Expand All @@ -331,7 +335,8 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailCachedThenSucceed) {
Init::ExpectableWatcherImpl init_watcher2;

EXPECT_CALL(context_, initManager()).WillRepeatedly(ReturnRef(init_manager2));
factory.createFilterFactoryFromProto(proto_config, "stats", context_);
EXPECT_THROW_WITH_MESSAGE(factory.createFilterFactoryFromProto(proto_config, "stats", context_),
WasmException, "Unable to create Wasm HTTP filter ");

EXPECT_CALL(init_watcher2, ready());
init_manager2.initialize(init_watcher2);
Expand All @@ -358,7 +363,8 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailCachedThenSucceed) {

EXPECT_CALL(context_, initManager()).WillRepeatedly(ReturnRef(init_manager3));

factory.createFilterFactoryFromProto(proto_config, "stats", context_);
EXPECT_THROW_WITH_MESSAGE(factory.createFilterFactoryFromProto(proto_config, "stats", context_),
WasmException, "Unable to create Wasm HTTP filter ");

EXPECT_CALL(init_watcher3, ready());
init_manager3.initialize(init_watcher3);
Expand Down Expand Up @@ -412,7 +418,8 @@ TEST_P(WasmFilterConfigTest, YamlLoadFromRemoteWasmFailCachedThenSucceed) {

EXPECT_CALL(context_, initManager()).WillRepeatedly(ReturnRef(init_manager5));

factory.createFilterFactoryFromProto(proto_config2, "stats", context_);
EXPECT_THROW_WITH_MESSAGE(factory.createFilterFactoryFromProto(proto_config2, "stats", context_),
WasmException, "Unable to create Wasm HTTP filter ");

EXPECT_CALL(init_watcher_, ready());
context_.initManager().initialize(init_watcher_);
Expand Down