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

wasm: allow execution of multiple instances of the same plugin. #13753

Merged
merged 26 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
697dc19
wasm: allow execution of multiple instances of the same plugin.
PiotrSikora Oct 25, 2020
672c1ff
review: fix clang-tidy.
PiotrSikora Oct 29, 2020
8d49c1d
wasm: remove the gap between rust and cpp test code for logging
mathetake Oct 30, 2020
9f98a40
review: use merged commit.
PiotrSikora Oct 30, 2020
60003c1
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasm_co…
PiotrSikora Oct 30, 2020
6f3392a
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasm_co…
PiotrSikora Nov 2, 2020
33f8b48
review: mark destructors virtual.
PiotrSikora Nov 2, 2020
375b02d
reivew: use tls_slot_->currentThreadRegistered().
PiotrSikora Nov 2, 2020
8ad9cbd
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasm_co…
PiotrSikora Nov 3, 2020
3a89a49
review: use ThreadLocal::TypedSlot<WasmHandle>.
PiotrSikora Nov 3, 2020
2facb41
review: re-add currentThreadRegistered() check.
PiotrSikora Nov 3, 2020
4c0ed76
review: style.
PiotrSikora Nov 4, 2020
88d5dc0
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasm_co…
PiotrSikora Nov 4, 2020
40015d0
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasm_co…
PiotrSikora Nov 4, 2020
e94fd82
review: use OptRef<WasmHandle>.
PiotrSikora Nov 4, 2020
6d978fc
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasm_co…
PiotrSikora Nov 5, 2020
62a015e
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasm_co…
PiotrSikora Nov 6, 2020
487d930
review: add shutdown for a singleton Wasm Service.
PiotrSikora Nov 6, 2020
930282d
review: add comments.
PiotrSikora Nov 6, 2020
cd04f3b
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasm_co…
PiotrSikora Nov 9, 2020
9965dcd
review: use PluginHandle for shutdown-on-destroy semantics.
PiotrSikora Nov 9, 2020
f16ba7d
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasm_co…
PiotrSikora Nov 10, 2020
3d4e28e
review: point at merged commit.
PiotrSikora Nov 10, 2020
d128aaf
review: update release date.
PiotrSikora Nov 10, 2020
7bc7c9a
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasm_co…
PiotrSikora Nov 11, 2020
e15e498
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasm_co…
PiotrSikora Nov 12, 2020
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
6 changes: 3 additions & 3 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,8 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "WebAssembly for Proxies (C++ host implementation)",
project_desc = "WebAssembly for Proxies (C++ host implementation)",
project_url = "https://github.com/proxy-wasm/proxy-wasm-cpp-host",
version = "40fd3d03842c07d65fed907a6b6ed0f89d68d531",
sha256 = "b5ae746e66b6209ea0cce86d6c21de99dacbec1da9cdadd53a9ec46bc296a3ba",
version = "f08baacadbe656674414f0878e18852bed67b795",
sha256 = "dc3239c674d19198f71becf5d1c2bf159128af3c72ec2f9c532b3153ecb6d5a1",
strip_prefix = "proxy-wasm-cpp-host-{version}",
urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-host/archive/{version}.tar.gz"],
use_category = ["dataplane_ext"],
Expand All @@ -842,7 +842,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
"envoy.filters.network.wasm",
"envoy.stat_sinks.wasm",
],
release_date = "2020-10-27",
release_date = "2020-10-30",
cpe = "N/A",
),
emscripten_toolchain = dict(
Expand Down
4 changes: 2 additions & 2 deletions source/extensions/access_loggers/wasm/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ WasmAccessLogFactory::createAccessLogInstance(const Protobuf::Message& proto_con
const auto& config = MessageUtil::downcastAndValidate<
const envoy::extensions::access_loggers::wasm::v3::WasmAccessLog&>(
proto_config, context.messageValidationVisitor());
auto access_log =
std::make_shared<WasmAccessLog>(config.config().root_id(), nullptr, std::move(filter));

// Create a base WASM to verify that the code loads before setting/cloning the for the
// individual threads.
Expand All @@ -35,6 +33,8 @@ WasmAccessLogFactory::createAccessLogInstance(const Protobuf::Message& proto_con
envoy::config::core::v3::TrafficDirection::UNSPECIFIED, context.localInfo(),
nullptr /* listener_metadata */);

auto access_log = std::make_shared<WasmAccessLog>(plugin, nullptr, std::move(filter));

auto callback = [access_log, &context, plugin](Common::Wasm::WasmHandleSharedPtr base_wasm) {
auto tls_slot = context.threadLocal().allocateSlot();

Expand Down
20 changes: 16 additions & 4 deletions source/extensions/access_loggers/wasm/wasm_access_log_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ namespace Extensions {
namespace AccessLoggers {
namespace Wasm {

using Envoy::Extensions::Common::Wasm::PluginSharedPtr;
using Envoy::Extensions::Common::Wasm::WasmHandle;

class WasmAccessLog : public AccessLog::Instance {
public:
WasmAccessLog(absl::string_view root_id, ThreadLocal::SlotPtr tls_slot,
WasmAccessLog(const PluginSharedPtr& plugin, ThreadLocal::SlotPtr tls_slot,
AccessLog::FilterPtr filter)
: root_id_(root_id), tls_slot_(std::move(tls_slot)), filter_(std::move(filter)) {}
: plugin_(plugin), tls_slot_(std::move(tls_slot)), filter_(std::move(filter)) {}

void log(const Http::RequestHeaderMap* request_headers,
const Http::ResponseHeaderMap* response_headers,
const Http::ResponseTrailerMap* response_trailers,
Expand All @@ -31,7 +33,7 @@ class WasmAccessLog : public AccessLog::Instance {
}

if (tls_slot_->get()) {
tls_slot_->getTyped<WasmHandle>().wasm()->log(root_id_, request_headers, response_headers,
tls_slot_->getTyped<WasmHandle>().wasm()->log(plugin_, request_headers, response_headers,
response_trailers, stream_info);
}
}
Expand All @@ -41,8 +43,18 @@ class WasmAccessLog : public AccessLog::Instance {
tls_slot_ = std::move(tls_slot);
}

~WasmAccessLog() override {
if (tls_slot_->get()) {
PiotrSikora marked this conversation as resolved.
Show resolved Hide resolved
tls_slot_->runOnAllThreads([plugin = plugin_](ThreadLocal::ThreadLocalObjectSharedPtr object)
-> ThreadLocal::ThreadLocalObjectSharedPtr {
object->asType<WasmHandle>().wasm()->startShutdown(plugin);
Copy link
Member

Choose a reason for hiding this comment

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

Can you merge main to pick up @jmarantz changes on this? We have the typed wrappers now.

Copy link
Contributor Author

@PiotrSikora PiotrSikora Nov 3, 2020

Choose a reason for hiding this comment

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

Done, although it doesn't look like the typed wrappers support storing nullptr.

Copy link
Contributor

Choose a reason for hiding this comment

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

correct. having nullptr as a possibility was not a requirement for any of the existing uses, unless you are not storing a value at all. Is that a problem?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see you added a layer of indirection through a handle which seems like a waste. We could change runOnAllThreads send in a typed pointer allowing nullptr or absl::optional ref or add a couple of new variants of runOnAllThreads. @PiotrSikora I'm not sure what the use-case is though for allowing null. Wouldn't you want to always set() your tls container on startup?

@mattklein123 WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

It seems like allowing storing nullptr in the slot should be OK? Should we just fix that?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah my preference would be for not having new variants. Maybe I'm missing something but can't we just make it so that shared_ptr that is stored can be null?

Copy link
Contributor

Choose a reason for hiding this comment

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

The shared_ptr can be stored as null, but the call to asType() in the template wrapper does a dynamic cast and ASSERT. That's easy to fix but then we have to pass the thing as something that can be checked for null T* or absl::optional

Copy link
Member

Choose a reason for hiding this comment

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

I see. Yeah I would probably just do optional shared_ptr.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry optional reference.

Copy link
Contributor

Choose a reason for hiding this comment

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

#13883 prototypes that change. Would like to get some quick feedback on the direction prior to filling out comments and adding a unit test for new thin abstraction struct OptRef.

return object;
});
}
}

private:
std::string root_id_;
Common::Wasm::PluginSharedPtr plugin_;
ThreadLocal::SlotPtr tls_slot_;
AccessLog::FilterPtr filter_;
};
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/bootstrap/wasm/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void WasmFactory::createWasm(const envoy::extensions::wasm::v3::WasmService& con
return std::static_pointer_cast<ThreadLocal::ThreadLocalObject>(
Common::Wasm::getOrCreateThreadLocalWasm(base_wasm, plugin, dispatcher));
});
cb(std::make_unique<WasmService>(std::move(tls_slot)));
cb(std::make_unique<WasmService>(plugin, std::move(tls_slot)));
};

if (!Common::Wasm::createWasm(
Expand Down
14 changes: 13 additions & 1 deletion source/extensions/bootstrap/wasm/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,21 @@ namespace Wasm {
class WasmService {
public:
WasmService(Common::Wasm::WasmHandleSharedPtr singleton) : singleton_(std::move(singleton)) {}
WasmService(ThreadLocal::SlotPtr tls_slot) : tls_slot_(std::move(tls_slot)) {}
WasmService(Common::Wasm::PluginSharedPtr plugin, ThreadLocal::SlotPtr tls_slot)
: plugin_(plugin), tls_slot_(std::move(tls_slot)) {}

~WasmService() {
PiotrSikora marked this conversation as resolved.
Show resolved Hide resolved
if (tls_slot_ && tls_slot_->get()) {
PiotrSikora marked this conversation as resolved.
Show resolved Hide resolved
tls_slot_->runOnAllThreads([plugin = plugin_](ThreadLocal::ThreadLocalObjectSharedPtr object)
-> ThreadLocal::ThreadLocalObjectSharedPtr {
object->asType<Common::Wasm::WasmHandle>().wasm()->startShutdown(plugin);
return object;
});
}
}

private:
Common::Wasm::PluginSharedPtr plugin_;
Common::Wasm::WasmHandleSharedPtr singleton_;
ThreadLocal::SlotPtr tls_slot_;
};
Expand Down
12 changes: 6 additions & 6 deletions source/extensions/common/wasm/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,8 @@ BufferInterface* Context::getBuffer(WasmBufferType type) {
case WasmBufferType::VmConfiguration:
return buffer_.set(wasm()->vm_configuration());
case WasmBufferType::PluginConfiguration:
if (plugin_) {
return buffer_.set(plugin_->plugin_configuration_);
if (temp_plugin_) {
return buffer_.set(temp_plugin_->plugin_configuration_);
}
return nullptr;
PiotrSikora marked this conversation as resolved.
Show resolved Hide resolved
case WasmBufferType::HttpRequestBody:
Expand Down Expand Up @@ -1182,18 +1182,18 @@ bool Context::validateConfiguration(absl::string_view configuration,
if (!wasm()->validate_configuration_) {
return true;
}
plugin_ = plugin_base;
temp_plugin_ = plugin_base;
auto result =
wasm()
->validate_configuration_(this, id_, static_cast<uint32_t>(configuration.size()))
.u64_ != 0;
plugin_.reset();
temp_plugin_.reset();
return result;
}

absl::string_view Context::getConfiguration() {
if (plugin_) {
return plugin_->plugin_configuration_;
if (temp_plugin_) {
return temp_plugin_->plugin_configuration_;
} else {
return wasm()->vm_configuration();
}
Expand Down
8 changes: 4 additions & 4 deletions source/extensions/common/wasm/wasm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,16 @@ ContextBase* Wasm::createRootContext(const std::shared_ptr<PluginBase>& plugin)

ContextBase* Wasm::createVmContext() { return new Context(this); }

void Wasm::log(absl::string_view root_id, const Http::RequestHeaderMap* request_headers,
void Wasm::log(const PluginSharedPtr& plugin, const Http::RequestHeaderMap* request_headers,
const Http::ResponseHeaderMap* response_headers,
const Http::ResponseTrailerMap* response_trailers,
const StreamInfo::StreamInfo& stream_info) {
auto context = getRootContext(root_id);
auto context = getRootContext(plugin, true);
context->log(request_headers, response_headers, response_trailers, stream_info);
}

void Wasm::onStatsUpdate(absl::string_view root_id, Envoy::Stats::MetricSnapshot& snapshot) {
auto context = getRootContext(root_id);
void Wasm::onStatsUpdate(const PluginSharedPtr& plugin, Envoy::Stats::MetricSnapshot& snapshot) {
auto context = getRootContext(plugin, true);
context->onStatsUpdate(snapshot);
}

Expand Down
9 changes: 5 additions & 4 deletions source/extensions/common/wasm/wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class Wasm : public WasmBase, Logger::Loggable<Logger::Id::wasm> {

Upstream::ClusterManager& clusterManager() const { return cluster_manager_; }
Event::Dispatcher& dispatcher() { return dispatcher_; }
Context* getRootContext(absl::string_view root_id) {
return static_cast<Context*>(WasmBase::getRootContext(root_id));
Context* getRootContext(const std::shared_ptr<PluginBase>& plugin, bool allow_closed) {
return static_cast<Context*>(WasmBase::getRootContext(plugin, allow_closed));
}
void setTimerPeriod(uint32_t root_context_id, std::chrono::milliseconds period) override;
virtual void tickHandler(uint32_t root_context_id);
Expand All @@ -72,12 +72,13 @@ class Wasm : public WasmBase, Logger::Loggable<Logger::Id::wasm> {
void getFunctions() override;

// AccessLog::Instance
void log(absl::string_view root_id, const Http::RequestHeaderMap* request_headers,
void log(const PluginSharedPtr& plugin, const Http::RequestHeaderMap* request_headers,
const Http::ResponseHeaderMap* response_headers,
const Http::ResponseTrailerMap* response_trailers,
const StreamInfo::StreamInfo& stream_info);

void onStatsUpdate(absl::string_view root_id, Envoy::Stats::MetricSnapshot& snapshot);
void onStatsUpdate(const PluginSharedPtr& plugin, Envoy::Stats::MetricSnapshot& snapshot);

virtual std::string buildVersion() { return BUILD_VERSION_NUMBER; }

void initializeLifecycle(Server::ServerLifecycleNotifier& lifecycle_notifier);
Expand Down
19 changes: 10 additions & 9 deletions source/extensions/filters/http/wasm/wasm_filter.cc
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
#include "extensions/filters/http/wasm/wasm_filter.h"

#include "envoy/http/codes.h"

#include "common/buffer/buffer_impl.h"
#include "common/common/assert.h"
#include "common/common/enum_to_int.h"
#include "common/http/header_map_impl.h"
#include "common/http/message_impl.h"
#include "common/http/utility.h"

namespace Envoy {
namespace Extensions {
namespace HttpFilters {
Expand Down Expand Up @@ -46,6 +37,16 @@ FilterConfig::FilterConfig(const envoy::extensions::filters::http::wasm::v3::Was
}
}

FilterConfig::~FilterConfig() {
if (tls_slot_->get()) {
PiotrSikora marked this conversation as resolved.
Show resolved Hide resolved
tls_slot_->runOnAllThreads([plugin = plugin_](ThreadLocal::ThreadLocalObjectSharedPtr object)
-> ThreadLocal::ThreadLocalObjectSharedPtr {
object->asType<WasmHandle>().wasm()->startShutdown(plugin);
return object;
});
}
}

} // namespace Wasm
} // namespace HttpFilters
} // namespace Extensions
Expand Down
3 changes: 2 additions & 1 deletion source/extensions/filters/http/wasm/wasm_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class FilterConfig : Logger::Loggable<Logger::Id::wasm> {
public:
FilterConfig(const envoy::extensions::filters::http::wasm::v3::Wasm& proto_config,
Server::Configuration::FactoryContext& context);
~FilterConfig();
PiotrSikora marked this conversation as resolved.
Show resolved Hide resolved

std::shared_ptr<Context> createFilter() {
Wasm* wasm = nullptr;
Expand All @@ -33,7 +34,7 @@ class FilterConfig : Logger::Loggable<Logger::Id::wasm> {
return nullptr;
}
if (wasm && !root_context_id_) {
root_context_id_ = wasm->getRootContext(plugin_->root_id_)->id();
root_context_id_ = wasm->getRootContext(plugin_, false)->id();
}
return std::make_shared<Context>(wasm, root_context_id_, plugin_);
}
Expand Down
14 changes: 10 additions & 4 deletions source/extensions/filters/network/wasm/wasm_filter.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include "extensions/filters/network/wasm/wasm_filter.h"

#include "common/buffer/buffer_impl.h"
#include "common/common/assert.h"
#include "common/common/enum_to_int.h"

namespace Envoy {
namespace Extensions {
namespace NetworkFilters {
Expand Down Expand Up @@ -41,6 +37,16 @@ FilterConfig::FilterConfig(const envoy::extensions::filters::network::wasm::v3::
}
}

FilterConfig::~FilterConfig() {
if (tls_slot_->get()) {
PiotrSikora marked this conversation as resolved.
Show resolved Hide resolved
tls_slot_->runOnAllThreads([plugin = plugin_](ThreadLocal::ThreadLocalObjectSharedPtr object)
-> ThreadLocal::ThreadLocalObjectSharedPtr {
object->asType<WasmHandle>().wasm()->startShutdown(plugin);
return object;
});
}
}

} // namespace Wasm
} // namespace NetworkFilters
} // namespace Extensions
Expand Down
6 changes: 4 additions & 2 deletions source/extensions/filters/network/wasm/wasm_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class FilterConfig : Logger::Loggable<Logger::Id::wasm> {
public:
FilterConfig(const envoy::extensions::filters::network::wasm::v3::Wasm& proto_config,
Server::Configuration::FactoryContext& context);
~FilterConfig();

std::shared_ptr<Context> createFilter() {
Wasm* wasm = nullptr;
Expand All @@ -33,11 +34,12 @@ class FilterConfig : Logger::Loggable<Logger::Id::wasm> {
return nullptr;
}
if (wasm && !root_context_id_) {
root_context_id_ = wasm->getRootContext(plugin_->root_id_)->id();
root_context_id_ = wasm->getRootContext(plugin_, false)->id();
PiotrSikora marked this conversation as resolved.
Show resolved Hide resolved
}
return std::make_shared<Context>(wasm, root_context_id_, plugin_);
}
Envoy::Extensions::Common::Wasm::Wasm* wasm() {

Envoy::Extensions::Common::Wasm::Wasm* wasmForTest() {
return tls_slot_->getTyped<WasmHandle>().wasm().get();
}

Expand Down
4 changes: 2 additions & 2 deletions source/extensions/stat_sinks/wasm/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ WasmSinkFactory::createStatsSink(const Protobuf::Message& proto_config,
MessageUtil::downcastAndValidate<const envoy::extensions::stat_sinks::wasm::v3::Wasm&>(
proto_config, context.messageValidationContext().staticValidationVisitor());

auto wasm_sink = std::make_unique<WasmStatSink>(config.config().root_id(), nullptr);

auto plugin = std::make_shared<Common::Wasm::Plugin>(
config.config().name(), config.config().root_id(), config.config().vm_config().vm_id(),
config.config().vm_config().runtime(),
Common::Wasm::anyToBytes(config.config().configuration()), config.config().fail_open(),
envoy::config::core::v3::TrafficDirection::UNSPECIFIED, context.localInfo(), nullptr);

auto wasm_sink = std::make_unique<WasmStatSink>(plugin, nullptr);

auto callback = [&wasm_sink, &context, plugin](Common::Wasm::WasmHandleSharedPtr base_wasm) {
if (!base_wasm) {
if (plugin->fail_open_) {
Expand Down
9 changes: 5 additions & 4 deletions source/extensions/stat_sinks/wasm/wasm_stat_sink_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ namespace Extensions {
namespace StatSinks {
namespace Wasm {

using Envoy::Extensions::Common::Wasm::PluginSharedPtr;
using Envoy::Extensions::Common::Wasm::WasmHandle;

class WasmStatSink : public Stats::Sink {
public:
WasmStatSink(absl::string_view root_id, Common::Wasm::WasmHandleSharedPtr singleton)
: root_id_(root_id), singleton_(std::move(singleton)) {}
WasmStatSink(const PluginSharedPtr& plugin, Common::Wasm::WasmHandleSharedPtr singleton)
: plugin_(plugin), singleton_(std::move(singleton)) {}

void flush(Stats::MetricSnapshot& snapshot) override {
singleton_->wasm()->onStatsUpdate(root_id_, snapshot);
singleton_->wasm()->onStatsUpdate(plugin_, snapshot);
}

void setSingleton(Common::Wasm::WasmHandleSharedPtr singleton) {
Expand All @@ -31,7 +32,7 @@ class WasmStatSink : public Stats::Sink {
}

private:
std::string root_id_;
Common::Wasm::PluginSharedPtr plugin_;
Common::Wasm::WasmHandleSharedPtr singleton_;
};

Expand Down
5 changes: 1 addition & 4 deletions test/extensions/bootstrap/wasm/test_data/logging_cpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ extern "C" PROXY_WASM_KEEPALIVE uint32_t proxy_on_configure(uint32_t, uint32_t c

extern "C" PROXY_WASM_KEEPALIVE void proxy_on_context_create(uint32_t, uint32_t) {}

extern "C" PROXY_WASM_KEEPALIVE uint32_t proxy_on_vm_start(uint32_t, uint32_t) {
proxy_set_tick_period_milliseconds(10);
return 1;
}
extern "C" PROXY_WASM_KEEPALIVE uint32_t proxy_on_vm_start(uint32_t, uint32_t) { return 1; }

extern "C" PROXY_WASM_KEEPALIVE void proxy_on_tick(uint32_t) {
const char* root_id = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions test/extensions/bootstrap/wasm/wasm_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ TEST_P(WasmTest, Segv) {
auto context = static_cast<TestContext*>(wasm_->start(plugin_));
EXPECT_CALL(*context, log_(spdlog::level::err, Eq("before badptr")));
EXPECT_FALSE(wasm_->configure(context, plugin_));
wasm_->isFailed();
EXPECT_TRUE(wasm_->isFailed());
}

TEST_P(WasmTest, DivByZero) {
Expand All @@ -219,7 +219,7 @@ TEST_P(WasmTest, DivByZero) {
auto context = static_cast<TestContext*>(wasm_->start(plugin_));
EXPECT_CALL(*context, log_(spdlog::level::err, Eq("before div by zero")));
context->onLog();
wasm_->isFailed();
EXPECT_TRUE(wasm_->isFailed());
}

TEST_P(WasmTest, IntrinsicGlobals) {
Expand Down
4 changes: 4 additions & 0 deletions test/extensions/common/wasm/test_data/test_cpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ WASM_EXPORT(uint32_t, proxy_on_done, (uint32_t)) {
return 0;
}

WASM_EXPORT(void, proxy_on_tick, (uint32_t)) {
proxy_done();
}

WASM_EXPORT(void, proxy_on_delete, (uint32_t)) {
std::string message = "on_delete logging";
proxy_log(LogLevel::info, message.c_str(), message.size());
Expand Down
Loading