Skip to content
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
26 changes: 25 additions & 1 deletion bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ config_setting(
)

config_setting(
name = "wasm_none",
name = "wasm_disabled",
values = {"define": "wasm=disabled"},
)

Expand Down Expand Up @@ -591,6 +591,30 @@ selects.config_setting_group(
],
)

selects.config_setting_group(
name = "not_x86",
match_any = [
":darwin_arm64",
":ios_arm64",
":ios_arm64e",
":ios_armv7",
":ios_armv7s",
":ios_i386",
":linux_aarch64",
":linux_mips64",
":linux_ppc",
":linux_s390x",
],
)

selects.config_setting_group(
name = "not_x86_or_wasm_disabled",
match_any = [
":not_x86",
":wasm_disabled",
],
)

alias(
name = "remote_jdk11",
actual = "@bazel_tools//tools/jdk:remote_jdk11",
Expand Down
10 changes: 4 additions & 6 deletions bazel/envoy_select.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,15 @@ def envoy_select_hot_restart(xs, repository = ""):
# and the ability to build tests using Proxy-Wasm C++ SDK on the current platform.
def envoy_select_wasm_cpp_tests(xs):
return select({
"@envoy//bazel:darwin_arm64": [],
"@envoy//bazel:linux_aarch64": [],
"@envoy//bazel:wasm_none": [],
"@envoy//bazel:not_x86_or_wasm_disabled": [],
"//conditions:default": xs,
})

# Selects the given values depending on the Wasm runtimes enabled in the current build,
# and the ability to build tests using Proxy-Wasm Rust SDK on the current platform.
def envoy_select_wasm_rust_tests(xs):
return select({
"@envoy//bazel:wasm_none": [],
"@envoy//bazel:wasm_disabled": [],
"//conditions:default": xs,
})

Expand All @@ -64,7 +62,7 @@ def envoy_select_wasm_v8(xs):
"@envoy//bazel:wasm_wamr": [],
"@envoy//bazel:wasm_wasmtime": [],
"@envoy//bazel:wasm_wavm": [],
"@envoy//bazel:wasm_none": [],
"@envoy//bazel:wasm_disabled": [],
"//conditions:default": xs, # implicit default (v8)
})

Expand All @@ -75,7 +73,7 @@ def envoy_select_wasm_v8_bool():
"@envoy//bazel:wasm_wamr": False,
"@envoy//bazel:wasm_wasmtime": False,
"@envoy//bazel:wasm_wavm": False,
"@envoy//bazel:wasm_none": False,
"@envoy//bazel:wasm_disabled": False,
"//conditions:default": True, # implicit default (v8)
})

Expand Down
16 changes: 6 additions & 10 deletions test/extensions/access_loggers/wasm/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ class TestFactoryContext : public NiceMock<Server::Configuration::MockServerFact
Stats::Scope& scope_;
};

class WasmAccessLogConfigTest : public testing::TestWithParam<std::string> {};
class WasmAccessLogConfigTest
: public testing::TestWithParam<std::tuple<std::string, std::string>> {};

INSTANTIATE_TEST_SUITE_P(Runtimes, WasmAccessLogConfigTest,
Envoy::Extensions::Common::Wasm::runtime_values);
Envoy::Extensions::Common::Wasm::runtime_and_cpp_values,
Envoy::Extensions::Common::Wasm::wasmTestParamsToString);

TEST_P(WasmAccessLogConfigTest, CreateWasmFromEmpty) {
auto factory =
Expand All @@ -56,22 +58,16 @@ TEST_P(WasmAccessLogConfigTest, CreateWasmFromEmpty) {
}

TEST_P(WasmAccessLogConfigTest, CreateWasmFromWASM) {
#if defined(__aarch64__)
// TODO(PiotrSikora): There are no Emscripten releases for arm64.
if (GetParam() != "null") {
return;
}
#endif
auto factory =
Registry::FactoryRegistry<Server::Configuration::AccessLogInstanceFactory>::getFactory(
"envoy.access_loggers.wasm");
ASSERT_NE(factory, nullptr);

envoy::extensions::access_loggers::wasm::v3::WasmAccessLog config;
config.mutable_config()->mutable_vm_config()->set_runtime(
absl::StrCat("envoy.wasm.runtime.", GetParam()));
absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())));
std::string code;
if (GetParam() != "null") {
if (std::get<0>(GetParam()) != "null") {
code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/access_loggers/wasm/test_data/test_cpp.wasm"));
} else {
Expand Down
59 changes: 6 additions & 53 deletions test/extensions/bootstrap/wasm/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ namespace Wasm {

using Extensions::Bootstrap::Wasm::WasmServicePtr;

class WasmFactoryTest : public testing::TestWithParam<std::string> {
class WasmFactoryTest : public testing::TestWithParam<std::tuple<std::string, std::string>> {
protected:
WasmFactoryTest() {
config_.mutable_config()->mutable_vm_config()->set_runtime(
absl::StrCat("envoy.wasm.runtime.", GetParam()));
if (GetParam() != "null") {
absl::StrCat("envoy.wasm.runtime.", std::get<0>(GetParam())));
if (std::get<0>(GetParam()) != "null") {
config_.mutable_config()->mutable_vm_config()->mutable_code()->mutable_local()->set_filename(
TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/start_cpp.wasm"));
Expand Down Expand Up @@ -69,15 +69,10 @@ class WasmFactoryTest : public testing::TestWithParam<std::string> {
};

INSTANTIATE_TEST_SUITE_P(Runtimes, WasmFactoryTest,
Envoy::Extensions::Common::Wasm::runtime_values);
Envoy::Extensions::Common::Wasm::runtime_and_cpp_values,
Envoy::Extensions::Common::Wasm::wasmTestParamsToString);

TEST_P(WasmFactoryTest, CreateWasmFromWasm) {
#if defined(__aarch64__)
// TODO(PiotrSikora): There are no Emscripten releases for arm64.
if (GetParam() != "null") {
return;
}
#endif
auto factory = std::make_unique<Bootstrap::Wasm::WasmFactory>();
auto empty_config = factory->createEmptyConfigProto();

Expand All @@ -90,12 +85,6 @@ TEST_P(WasmFactoryTest, CreateWasmFromWasm) {
}

TEST_P(WasmFactoryTest, CreateWasmFromWasmPerThread) {
#if defined(__aarch64__)
// TODO(PiotrSikora): There are no Emscripten releases for arm64.
if (GetParam() != "null") {
return;
}
#endif
config_.set_singleton(false);
initializeWithConfig(config_);

Expand All @@ -105,13 +94,7 @@ TEST_P(WasmFactoryTest, CreateWasmFromWasmPerThread) {
}

TEST_P(WasmFactoryTest, MissingImport) {
#if defined(__aarch64__)
// TODO(PiotrSikora): There are no Emscripten releases for arm64.
if (GetParam() != "null") {
return;
}
#endif
if (GetParam() == "null") {
if (std::get<0>(GetParam()) == "null") {
return;
}
config_.mutable_config()->mutable_vm_config()->mutable_code()->mutable_local()->set_filename(
Expand All @@ -122,12 +105,6 @@ TEST_P(WasmFactoryTest, MissingImport) {
}

TEST_P(WasmFactoryTest, UnspecifiedRuntime) {
#if defined(__aarch64__)
// TODO(PiotrSikora): There are no Emscripten releases for arm64.
if (GetParam() != "null") {
return;
}
#endif
config_.mutable_config()->mutable_vm_config()->set_runtime("");

EXPECT_THROW_WITH_REGEX(
Expand All @@ -136,25 +113,13 @@ TEST_P(WasmFactoryTest, UnspecifiedRuntime) {
}

TEST_P(WasmFactoryTest, UnknownRuntime) {
#if defined(__aarch64__)
// TODO(PiotrSikora): There are no Emscripten releases for arm64.
if (GetParam() != "null") {
return;
}
#endif
config_.mutable_config()->mutable_vm_config()->set_runtime("envoy.wasm.runtime.invalid");

EXPECT_THROW_WITH_MESSAGE(initializeWithConfig(config_), Extensions::Common::Wasm::WasmException,
"Unable to create Wasm service test");
}

TEST_P(WasmFactoryTest, StartFailed) {
#if defined(__aarch64__)
// TODO(PiotrSikora): There are no Emscripten releases for arm64.
if (GetParam() != "null") {
return;
}
#endif
ProtobufWkt::StringValue plugin_configuration;
plugin_configuration.set_value("bad");
config_.mutable_config()->mutable_vm_config()->mutable_configuration()->PackFrom(
Expand All @@ -165,12 +130,6 @@ TEST_P(WasmFactoryTest, StartFailed) {
}

TEST_P(WasmFactoryTest, StartFailedOpen) {
#if defined(__aarch64__)
// TODO(PiotrSikora): There are no Emscripten releases for arm64.
if (GetParam() != "null") {
return;
}
#endif
ProtobufWkt::StringValue plugin_configuration;
plugin_configuration.set_value("bad");
config_.mutable_config()->mutable_vm_config()->mutable_configuration()->PackFrom(
Expand All @@ -182,12 +141,6 @@ TEST_P(WasmFactoryTest, StartFailedOpen) {
}

TEST_P(WasmFactoryTest, ConfigureFailed) {
#if defined(__aarch64__)
// TODO(PiotrSikora): There are no Emscripten releases for arm64.
if (GetParam() != "null") {
return;
}
#endif
ProtobufWkt::StringValue plugin_configuration;
plugin_configuration.set_value("bad");
config_.mutable_config()->mutable_configuration()->PackFrom(plugin_configuration);
Expand Down
13 changes: 4 additions & 9 deletions test/extensions/bootstrap/wasm/wasm_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace Extensions {
namespace Wasm {
namespace {

class WasmIntegrationTest : public HttpIntegrationTest, public testing::TestWithParam<std::string> {
class WasmIntegrationTest : public HttpIntegrationTest,
public testing::TestWithParam<std::tuple<std::string, std::string>> {
public:
WasmIntegrationTest()
: HttpIntegrationTest(Http::CodecType::HTTP1, Network::Address::IpVersion::v4) {}
Expand Down Expand Up @@ -58,7 +59,7 @@ name: envoy.filters.http.wasm
local:
filename: {}
)EOF",
GetParam(), httpwasm));
std::get<0>(GetParam()), httpwasm));
HttpIntegrationTest::initialize();
}

Expand All @@ -68,17 +69,11 @@ name: envoy.filters.http.wasm
};

INSTANTIATE_TEST_SUITE_P(Runtimes, WasmIntegrationTest,
Envoy::Extensions::Common::Wasm::sandbox_runtime_values,
Envoy::Extensions::Common::Wasm::sandbox_runtime_and_cpp_values,
Envoy::Extensions::Common::Wasm::wasmTestParamsToString);
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(WasmIntegrationTest);

TEST_P(WasmIntegrationTest, FilterMakesCallInConfigureTime) {
#if defined(__aarch64__)
// TODO(PiotrSikora): There are no Emscripten releases for arm64.
if (GetParam() != "null") {
return;
}
#endif
initialize();
ASSERT_TRUE(fake_upstreams_.back()->waitForHttpConnection(*dispatcher_, wasm_connection_));

Expand Down
Loading