Skip to content
This repository was archived by the owner on Dec 16, 2020. It is now read-only.

2 initial stress tests for the http wasm filters#72

Closed
duderino wants to merge 1 commit intoenvoyproxy:masterfrom
duderino:jblatt_wasm_stress_test
Closed

2 initial stress tests for the http wasm filters#72
duderino wants to merge 1 commit intoenvoyproxy:masterfrom
duderino:jblatt_wasm_stress_test

Conversation

@duderino
Copy link
Contributor

@duderino duderino commented Jul 16, 2019

@jplevyak this should get you started and I'll keep adding additional test cases.

Test it like so:

bazel test --define wasm=enabled  //test/extensions/filters/http/wasm:wasm_filter_stress_test 

there's a basic grpc callout test that mostly works... except the wasm filter thinks the grpc response is bad. It logs this for every grpc response it receives:

[2019-07-16 04:36:18.547][55][info][wasm] [source/extensions/common/wasm/wasm.cc:1272] wasm log: failure 2

The http callout test throws an exception inside the wasm bundle. that one is currently skipped.

@duderino duderino requested review from PiotrSikora and jplevyak July 16, 2019 04:45
static Registry::RegisterFactory<WasmFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(WasmFilterConfig, Server::Configuration::NamedHttpFilterConfigFactory);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

And all the other filters used this REGISTER_FACTORY macro so added that too

Copy link
Contributor

Choose a reason for hiding this comment

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

TIL


StringView callout_url{data->toString()};

logInfo("Forwarding to: " + std::string(callout_url));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jplevyak take note. After 20 or so iterations the callout_url will log something that looks corrupted

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we can use fmt::format here

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this is disable for the exception issue.

for (auto& upstream : fake_upstreams_) {
if (upstream->localAddress()->ip()) {
ports.push_back(upstream->localAddress()->ip()->port());
ports_.push_back(upstream->localAddress()->ip()->port());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the StressTest subclass needs to set these ports without creating FakeUpstreams

* Test fixture for all integration tests.
*/
class BaseIntegrationTest : Logger::Loggable<Logger::Id::testing> {
class BaseIntegrationTest : protected Logger::Loggable<Logger::Id::testing> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lets the StressTest subclass use ENVOY_LOG

@duderino duderino force-pushed the jblatt_wasm_stress_test branch from 9683bdf to 097ccb9 Compare July 16, 2019 05:48
public:
MyGrpcCallHandler(ExampleContext *context)
: GrpcCallHandler<google::protobuf::Value>(context), context_(context) {}
void onCreateInitialMetadata() override {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we convert these from pure virtuals to having a default implementation of {} so that we can avoid requiring handlers which are used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, would you like me to do that in this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing, just wondering if you thought that was a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I'm pretty neutral on that. Most people will copy the boilerplate anyways and then hack it up.

Copy link
Contributor

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

comments for the topmost files

static Registry::RegisterFactory<WasmFilterConfig,
Server::Configuration::NamedHttpFilterConfigFactory>
register_;
REGISTER_FACTORY(WasmFilterConfig, Server::Configuration::NamedHttpFilterConfigFactory);
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL

return FilterHeadersStatus::Continue;
}

StringView callout_url{data->toString()};
Copy link
Contributor

Choose a reason for hiding this comment

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

always prefer data->view() since it's a string_view


StringView callout_url{data->toString()};

logInfo("Forwarding to: " + std::string(callout_url));
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we can use fmt::format here

@duderino duderino force-pushed the jblatt_wasm_stress_test branch from f3c8023 to 7b20bbc Compare July 18, 2019 21:38
@duderino duderino changed the title 2 initial stress tests for the http wasm filters WIP 2 initial stress tests for the http wasm filters Jul 18, 2019
@jplevyak
Copy link
Contributor

It seems that exception support in emscripten is... poor. First, in order to get exception support we need to add "-s DISABLE_EXCEPTION_CATCHING=0" to the Makefile.

After that, we would need a great deal of support, implementing a raft of invoke_XXX and dynCall_XXX functions in addition to __cxa calls.

All this is likely to change as well when we move to the new upstream (LLVM) based backend for emscripten.

The upshot is that I think we should drop exception support within the VM until this gets sorted out.

Thoughts?

@duderino duderino force-pushed the jblatt_wasm_stress_test branch 2 times, most recently from 5b59d88 to f6eb3a8 Compare July 22, 2019 22:16
@duderino
Copy link
Contributor Author

It seems that exception support in emscripten is... poor. First, in order to get exception support we need to add "-s DISABLE_EXCEPTION_CATCHING=0" to the Makefile.

After that, we would need a great deal of support, implementing a raft of invoke_XXX and dynCall_XXX functions in addition to __cxa calls.

All this is likely to change as well when we move to the new upstream (LLVM) based backend for emscripten.

The upshot is that I think we should drop exception support within the VM until this gets sorted out.

Thoughts?

@jplevyak if we drop exception support, what happens if third party code, etc in a wasm bundle throws an exception?

Signed-off-by: Joshua Blatt <jblatt@google.com>
Signed-off-by: Joshua Blatt <jtblatt@gmail.com>
@duderino duderino force-pushed the jblatt_wasm_stress_test branch from f6eb3a8 to 9549c42 Compare July 22, 2019 22:26
@duderino duderino changed the title WIP 2 initial stress tests for the http wasm filters 2 initial stress tests for the http wasm filters Jul 22, 2019
TestEnvironment::runfilesDirectory(),
"/test/extensions/filters/http/wasm/test_data/grpc_callout_", wasmLang(), ".wasm");
// Must match cluster name in the wasm bundle:
const std::string callout_cluster_name{"callout_cluster"};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mandarjog Here is an example wasm test case. The link between this test case and the wasm bundle is this 'callout_cluster' name.

This test case creates two clusters: a 'callout_cluster' to simulate some random upstream that the wasm bundle can callout to and a 'origin_cluster' which the data plane request will be forwarded to. The grpc_callout_cpp.cc file passes the 'callout_cluster' name to the grpc library and Envoy does the rest

@lambdai
Copy link
Contributor

lambdai commented Jul 23, 2019

@duderino Could you split the PR? Even we exclude the generated code this PR is no doubt a huge one. Very hard to review

@duderino
Copy link
Contributor Author

@duderino Could you split the PR? Even we exclude the generated code this PR is no doubt a huge one. Very hard to review

The test framework was already reviewed by @jplevyak back in the istio/proxy repo, so I though we could just not review the framework part (everything under stress/)?

Once this is merged and has a few additional test cases I'm planning on sending the framework to envoyproxy/envoy where it'll experience another batch of reviews

@duderino
Copy link
Contributor Author

Closing in favor of the split in #89 and #90

@duderino duderino closed this Jul 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants