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

How do you use this repository to test? #11

Open
janitha09 opened this issue Aug 11, 2021 · 3 comments
Open

How do you use this repository to test? #11

janitha09 opened this issue Aug 11, 2021 · 3 comments

Comments

@janitha09
Copy link

janitha09 commented Aug 11, 2021

I tried this
~/gh/proxy-wasm/proxy-wasm-rust-sdk$ bazel build //examples:hello_world

the output looks like this

WARNING: Download from https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz failed: class javax.net.ssl.SSLHandshakeException PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO: Analyzed target //examples:hello_world (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //examples:hello_world up-to-date:
  bazel-bin/examples/hello_world.wasm

Then in the test-framework project I did this

cargo run --example hello_world
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/examples/hello_world`
error: The following required arguments were not provided:
    <wasm-path>

USAGE:
    hello_world [FLAGS] <wasm-path>

For more information try --help

following that I tried this

cargo run --example hello_world ~/gh/proxy-wasm/proxy-wasm-rust-sdk/bazel-bin/examples/hello_world.wasm

The output looks like this

    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/examples/hello_world /home/janitha/gh/proxy-wasm/proxy-wasm-rust-sdk/bazel-bin/examples/hello_world.wasm`
thread 'main' panicked at 'Error: test-framework does not support proxy-wasm modules of this abi version', src/hostcalls.rs:47:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Why is this saying the abi version is unsupported?

The backtrace implies that I am calling improperly i.e. the wasm is not loaded

RUST_BACKTRACE=1 cargo run --example hello_world /home/janitha/gh/proxy-wasm/proxy-wasm-rust-sdk/bazel-bin/examples/hello_world.wasm
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/examples/hello_world /home/janitha/gh/proxy-wasm/proxy-wasm-rust-sdk/bazel-bin/examples/hello_world.wasm`
thread 'main' panicked at 'Error: test-framework does not support proxy-wasm modules of this abi version', src/hostcalls.rs:47:9
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:541:12
   1: proxy_wasm_test_framework::hostcalls::get_abi_version
             at ./src/hostcalls.rs:47:9
   2: proxy_wasm_test_framework::tester::mock
             at ./src/tester.rs:47:23
   3: hello_world::main
             at ./examples/hello_world.rs:24:32
   4: core::ops::function::FnOnce::call_once
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/ops/function.rs:227:5

What is the correct way to call it?

@PiotrSikora
Copy link
Member

This framework currently implements only Proxy-Wasm ABI v0.1.0, wheras all existing SDKs implement Proxy-Wasm ABI v0.2.x.

You might try using it with Proxy-Wasm Rust SDK v0.1.4 (latest release, still using Proxy-Wasm ABI v0.1.0) instead of the master branch, but I'm not sure if that still works, since the test framework is currently unmaintained (although, I hope to revive it later this year).

@janitha09
Copy link
Author

janitha09 commented Aug 12, 2021

Thanks for the info. I saw this issue #2 but ignored it when I saw the if else statements.

Have you guys looked at what kubebuilder does in terms of setting up a ready to go project. https://github.com/kubernetes-sigs/kubebuilder. I have spun up a few operators using this and the scaffolding and annotation driven approach makes it fast to write, test and get into production.

I would like to help. I suck at writing code that I cannot test in a lazy way.

I haven't quite understood why rust's #[cfg(test)] is not being used/extended here. I noticed a stack dump when trying to run a test linked to #[no_mangle] that I do not know how to work around

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}
$ cargo test
   Compiling primes v0.3.0
   Compiling http-metrics-envoy-filter v0.1.0 (/workspaces/http-metrics-envoy-filter)
warning: unused imports: `debug`, `trace`
 --> src/lib.rs:7:11
  |
7 | use log::{debug, info, trace, error};
  |           ^^^^^        ^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-Wl,--as-needed" "-L" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.0.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.1.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.10.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.11.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.12.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.13.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.14.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.15.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.2.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.3.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.4.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.5.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.6.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.7.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.8.rcgu.o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.9.rcgu.o" "-o" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e" "/workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.2x6qarlzyhsa8gko.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/workspaces/http-metrics-envoy-filter/target/debug/deps" "-L" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-f9857d82e715db01.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libterm-ec0a0bca4ec735a2.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-a9c0ac60f102f521.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode_width-a44cb01dee9bd0b4.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_std-baabb9a435cbac5d.rlib" "/workspaces/http-metrics-envoy-filter/target/debug/deps/libproxy_wasm-ca465ac593f2d890.rlib" "/workspaces/http-metrics-envoy-filter/target/debug/deps/libhashbrown-b5ac0d000610a0b1.rlib" "/workspaces/http-metrics-envoy-filter/target/debug/deps/libahash-99000129f9a79579.rlib" "/workspaces/http-metrics-envoy-filter/target/debug/deps/libgetrandom-0138c7a56a442680.rlib" "/workspaces/http-metrics-envoy-filter/target/debug/deps/liblibc-1157e3ec59adeda6.rlib" "/workspaces/http-metrics-envoy-filter/target/debug/deps/libonce_cell-c351a2101b09b51f.rlib" "/workspaces/http-metrics-envoy-filter/target/debug/deps/libprimes-ae53e8da43b24afd.rlib" "/workspaces/http-metrics-envoy-filter/target/debug/deps/liblog-bda932c7a9968e0a.rlib" "/workspaces/http-metrics-envoy-filter/target/debug/deps/libcfg_if-0a6225dcb261749c.rlib" "-Wl,--start-group" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-b6b48477bfa8c673.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-f560ec02638f7ffe.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-9c8eadb7013c9e0b.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-8b0ec8dbdb85d0bf.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-ba5d5ee707c805d2.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-55166126dbdd5e46.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-c327b365eae3b2f3.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-416439b546a0d033.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-2581188d29552e15.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-da7b2635bfcce6ef.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-09200ed1945e7b2b.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-223ac369b29f5000.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-39562fe6600dd936.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-9b411bb7a19f81b3.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-64ea0581d80339f7.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-b2dbda88b377d685.rlib" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-2a8415a96ed1d7dc.rlib" "-Wl,--end-group" "/usr/local/rustup/toolchains/1.53.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-c4d9a5b072ee3191.rlib" "-Wl,-Bdynamic" "-lc" "-lm" "-lrt" "-lpthread" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
  = note: /usr/bin/ld: /workspaces/http-metrics-envoy-filter/target/debug/deps/http_metrics_envoy_filter-2281d3848d86e56e.http_metrics_envoy_filter.ao6p4y8c-cgu.0.rcgu.o: in function `_start':
          /workspaces/http-metrics-envoy-filter/src/lib.rs:13: multiple definition of `_start'; /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o:(.text+0x0): first defined here
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error; 1 warning emitted

error: could not compile `http-metrics-envoy-filter`

To learn more, run the command again with --verbose.

@alexhu20
Copy link

@janitha09 Have you resolved this issue yet? I don't see the test framework being pulished, do we have to pull this repo locally and build with our implementation together?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants