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

Error when testing on macOS #51

Closed
huntc opened this issue Oct 9, 2023 · 15 comments
Closed

Error when testing on macOS #51

huntc opened this issue Oct 9, 2023 · 15 comments

Comments

@huntc
Copy link

huntc commented Oct 9, 2023

Just trying this out on macOS, and I get an error. My steps:

just build-test-server
just start-test-server &
just test-headless

The output:

Set timeout to 20 seconds...
Running headless tests in Chrome on `http://127.0.0.1:65264/`
Try find `webdriver.json` for configure browser's capabilities:
Not found
driver status: signal: 9 (SIGKILL)                
driver stdout:
    Starting ChromeDriver 114.0.5735.90 (386bc09e8f4f2e025eddae123f36f6263096ae49-refs/branch-heads/5735@{#1052}) on port 65264
    Only local connections are allowed.
    Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
    ChromeDriver was started successfully.

Error: non-200 response code: 404                 
{"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"0   chromedriver                        0x00000001045436b8 chromedriver + 4937400\n1   chromedriver                        0x000000010453ab73 chromedriver + 4901747\n2   chromedriver                        0x00000001040f8490 chromedriver + 435344\n3   chromedriver                        0x000000010412d44b chromedriver + 652363\n4   chromedriver                        0x000000010415ff16 chromedriver + 859926\n5   chromedriver                        0x000000010415bc9d chromedriver + 842909\n6   chromedriver                        0x000000010415b2e7 chromedriver + 840423\n7   chromedriver                        0x00000001040c22da chromedriver + 213722\n8   chromedriver                        0x00000001044ff2ad chromedriver + 4657837\n9   chromedriver                        0x0000000104504130 chromedriver + 4677936\n10  chromedriver                        0x000000010450adef chromedriver + 4705775\n11  chromedriver                        0x000000010450505a chromedriver + 4681818\n12  chromedriver                        0x00000001044d792c chromedriver + 4495660\n13  chromedriver                        0x00000001040c0d33 chromedriver + 208179\n14  dyld                                0x00000002053e441f start + 1903\n"}}
error: test failed, to rerun pass `--test web`

Caused by:
  process didn't exit successfully: `/Users/huntc/Library/Caches/.wasm-pack/wasm-bindgen-4d1072dec3d41ff6/wasm-bindgen-test-runner /Users/huntc/Projects/hacking/tonic-web-wasm-client/test-suite/simple/client/target/wasm32-unknown-unknown/debug/deps/web-f7c16b38ca1aa59e.wasm` (exit status: 1)
Error: Running Wasm tests with wasm-bindgen-test failed
Caused by: Running Wasm tests with wasm-bindgen-test failed
Caused by: failed to execute `cargo test`: exited with exit status: 1
  full command: cd "/Users/huntc/Projects/hacking/tonic-web-wasm-client/test-suite/simple/client" && CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER="/Users/huntc/Library/Caches/.wasm-pack/wasm-bindgen-4d1072dec3d41ff6/wasm-bindgen-test-runner" CHROMEDRIVER="/Users/huntc/Library/Caches/.wasm-pack/chromedriver-1b467be6b1263401/chromedriver" WASM_BINDGEN_TEST_ONLY_WEB="1" "cargo" "test" "--target" "wasm32-unknown-unknown"
error: Recipe `test-headless` failed on line 24 with exit code 1

Any guidance?

@devashishdxt
Copy link
Owner

Make sure you follow these steps to setup local testing environment: https://rustwasm.github.io/docs/wasm-bindgen/wasm-bindgen-test/browsers.html

@devashishdxt
Copy link
Owner

If you're testing on your local machine. You can skip headless testing and test it with just test and open the URL in any browser of your choice.

@huntc
Copy link
Author

huntc commented Oct 9, 2023

Make sure you follow these steps to setup local testing environment: https://rustwasm.github.io/docs/wasm-bindgen/wasm-bindgen-test/browsers.html

Yeah, I kinda have... and I took inspiration from the GH action scripts...

@huntc
Copy link
Author

huntc commented Oct 9, 2023

If you're testing on your local machine. You can skip headless testing and test it with just test and open the URL in any browser of your choice.

Unfortunately, this spews out errors too e.g.:

---- web::test_error_response output ----
    error output:
        panicked at 'assertion failed: `(left == right)`
          left: `Unknown`,
         right: `Unauthenticated`', tests/web.rs:89:5
        
        Stack:
        
        Error
            at http://localhost:8000/wasm-bindgen-test:864:21
            at logError (http://localhost:8000/wasm-bindgen-test:220:18)
            at imports.wbg.__wbg_new_abda76e883ba8a5f (http://localhost:8000/wasm-bindgen-test:863:66)
            at console_error_panic_hook::Error::new::h8409619050267aa7 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[4164]:0x177d13)
            at console_error_panic_hook::hook_impl::h27a96e4a19ad8e17 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[825]:0xf15c4)
            at console_error_panic_hook::hook::h8b3ff1e43c638b1a (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[4471]:0x17c0f8)
            at wasm_bindgen_test::__rt::Context::new::{{closure}}::{{closure}}::hef9ededc9344e104 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[2285]:0x14bbb4)
            at std::panicking::rust_panic_with_hook::he017c20114c82dea (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[1803]:0x1361cc)
            at std::panicking::begin_panic_handler::{{closure}}::h5e23c6f065badef5 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[2243]:0x14a214)
            at std::sys_common::backtrace::__rust_end_short_backtrace::hff4b03aa315e3d86 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[5544]:0x185c9d)
        
        
    
    JS exception that was thrown:
        RuntimeError: unreachable
            at __rust_start_panic (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[5585]:0x185d99)
            at rust_panic (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[5456]:0x185880)
            at std::panicking::rust_panic_with_hook::he017c20114c82dea (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[1803]:0x1361f9)
            at std::panicking::begin_panic_handler::{{closure}}::h5e23c6f065badef5 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[2243]:0x14a214)
            at std::sys_common::backtrace::__rust_end_short_backtrace::hff4b03aa315e3d86 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[5544]:0x185c9d)
            at rust_begin_unwind (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[3426]:0x16a8b9)
            at core::panicking::panic_fmt::h7859ddfa497c0e61 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[4398]:0x17b1ee)
            at core::panicking::assert_failed_inner::haac5d1272989e52a (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[802]:0xef1a9)
            at core::panicking::assert_failed::h3274c2672a8b22f8 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[1639]:0x12d3f3)
            at web::test_error_response::{{closure}}::hc38ad285938eeeb2 (http://localhost:8000/wasm-bindgen-test_bg.wasm:wasm-function[336]:0xa9f4f)

@devashishdxt
Copy link
Owner

Can you also post network request and response from your browser?

@huntc
Copy link
Author

huntc commented Oct 9, 2023

huntc@MacBook-Pro-3 /tmp % curl 'http://localhost:50051/echo.Echo/EchoErrorResponse' \
  -H 'sec-ch-ua: "Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' \
  -H 'content-type: application/grpc-web+proto' \
  -H 'accept: application/grpc-web+proto' \
  -H 'x-grpc-web: 1' \
  -H 'Referer: http://localhost:8000/' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --data-raw $'\u0000\u0000\u0000\u0000\u0006\n\u0004John' \
  --compressed
curl: (7) Failed to connect to localhost port 50051 after 3 ms: Couldn't connect to server

@huntc
Copy link
Author

huntc commented Oct 9, 2023

I just realised that I had to run just start-test-server & before just test. So, all is well there...

One of the first things I like to do when looking at a crate I might heavily depend on is to see if I can build it ok. I'll add some doc to your README to remind myself what to do and then send it through as a PR. Thanks.

@devashishdxt
Copy link
Owner

I just realised that I had to run just start-test-server & before just test. So, all is well there...

I don't understand. Is there still an issue that you're facing while running tests?

@huntc
Copy link
Author

huntc commented Oct 9, 2023

I just realised that I had to run just start-test-server & before just test. So, all is well there...

I don't understand. Is there still an issue that you're facing while running tests?

Foreground tests now appear to be ok.

I'm now back to figuring out how to run the headless tests. I'll play around a bit.

@devashishdxt
Copy link
Owner

Thanks for testing. Also, can you please create a PR with some documentation on how to run headless tests (once you're able to run them)? Even I'm not able to run headless tests on my local machine now 😅.

@huntc
Copy link
Author

huntc commented Oct 9, 2023

Sure, I'll create a PR. Meanwhile, what's the error you're getting. This looks ominous to me:

driver status: signal: 9 (SIGKILL)                
driver stdout:
    Starting ChromeDriver 114.0.5735.90 (386bc09e8f4f2e025eddae123f36f6263096ae49-refs/branch-heads/5735@{#1052}) on port 52151
    Only local connections are allowed.
    Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
    ChromeDriver was started successfully.

@huntc
Copy link
Author

huntc commented Oct 9, 2023

Could be related: rustwasm/wasm-bindgen#2151

@devashishdxt
Copy link
Owner

I'm also getting error similar to yours:

Set timeout to 20 seconds...
Running headless tests in Chrome on `http://127.0.0.1:50983/`
Try find `webdriver.json` for configure browser's capabilities:
Not found
driver status: signal: 9 (SIGKILL)                
driver stdout:
    Starting ChromeDriver 111.0.5563.64 (c710e93d5b63b7095afe8c2c17df34408078439d-refs/branch-heads/5563@{#995}) on port 50983
    Only local connections are allowed.
    Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
    ChromeDriver was started successfully.

Error: non-200 response code: 404                 
{"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"0   chromedriver                        0x0000000100936d3c chromedriver + 4222268\n1   chromedriver                        0x00000001008bd8e8 chromedriver + 3725544\n2   chromedriver                        0x0000000100573c28 chromedriver + 277544\n3   chromedriver                        0x00000001005a1148 chromedriver + 463176\n4   chromedriver                        0x00000001005cbaf8 chromedriver + 637688\n5   chromedriver                        0x00000001005caf60 chromedriver + 634720\n6   chromedriver                        0x0000000100545078 chromedriver + 86136\n7   chromedriver                        0x0000000100907788 chromedriver + 4028296\n8   chromedriver                        0x000000010090bc1c chromedriver + 4045852\n9   chromedriver                        0x0000000100911c98 chromedriver + 4070552\n10  chromedriver                        0x000000010090c8d8 chromedriver + 4049112\n11  chromedriver                        0x00000001008e3d84 chromedriver + 3882372\n12  chromedriver                        0x0000000100543908 chromedriver + 80136\n13  dyld                                0x000000019751ff28 start + 2236\n"}}
error: test failed, to rerun pass `--test web`

Caused by:
  process didn't exit successfully: `/Users/devashishdixit/Library/Caches/.wasm-pack/wasm-bindgen-4d1072dec3d41ff6/wasm-bindgen-test-runner /Users/devashishdixit/workspace/tonic-web-wasm-client/test-suite/simple/client/target/wasm32-unknown-unknown/debug/deps/web-88a16ccc71d88d8c.wasm` (exit status: 1)
note: test exited abnormally; to see the full output pass --nocapture to the harness.
Error: Running Wasm tests with wasm-bindgen-test failed
Caused by: Running Wasm tests with wasm-bindgen-test failed
Caused by: failed to execute `cargo test`: exited with exit status: 1
  full command: cd "/Users/devashishdixit/workspace/tonic-web-wasm-client/test-suite/simple/client" && CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER="/Users/devashishdixit/Library/Caches/.wasm-pack/wasm-bindgen-4d1072dec3d41ff6/wasm-bindgen-test-runner" CHROMEDRIVER="/usr/local/bin/chromedriver" WASM_BINDGEN_TEST_ONLY_WEB="1" "cargo" "test" "--target" "wasm32-unknown-unknown"
error: Recipe `test-headless` failed on line 24 with exit code 1

@huntc
Copy link
Author

huntc commented Oct 9, 2023

Looks as though the chromedriver that wasm-pack installs is incompatible with the version of Chrome I have installed.

See here: https://github.com/rustwasm/wasm-pack/blob/master/src/test/webdriver/chromedriver.rs

My chrome is 117.0.5938.149, whereas chromedriver is 114.0.5735.90.

There appears to be an issue in relation to this: rustwasm/wasm-pack#1315

My workaround is to avoid chrome and use firefox for testing.

@devashishdxt
Copy link
Owner

Closing this issue

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

2 participants