diff --git a/source/extensions/common/wasm/wasm.cc b/source/extensions/common/wasm/wasm.cc index 46f40b69f3f28..837f770478e99 100644 --- a/source/extensions/common/wasm/wasm.cc +++ b/source/extensions/common/wasm/wasm.cc @@ -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( cluster_manager, init_manager, vm_config.code().remote(), dispatcher, random, true, diff --git a/test/extensions/filters/http/wasm/config_test.cc b/test/extensions/filters/http/wasm/config_test.cc index 67224a55cecad..7d9b5142ddd65 100644 --- a/test/extensions/filters/http/wasm/config_test.cc +++ b/test/extensions/filters/http/wasm/config_test.cc @@ -22,6 +22,9 @@ using testing::ReturnRef; namespace Envoy { namespace Extensions { + +using Common::Wasm::WasmException; + namespace HttpFilters { namespace Wasm { @@ -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) { @@ -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_); @@ -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); @@ -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_); @@ -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); @@ -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); @@ -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_);