Page MenuHomePhabricator

[Tunnelbroker] Add integration tests
ClosedPublic

Authored by jon on Apr 27 2023, 7:21 AM.
Tags
None
Referenced Files
F3368786: D7661.id25845.diff
Mon, Nov 25, 8:49 PM
F3368785: D7661.id.diff
Mon, Nov 25, 8:49 PM
F3368784: D7661.diff
Mon, Nov 25, 8:49 PM
Unknown Object (File)
Mon, Nov 4, 12:18 PM
Unknown Object (File)
Wed, Oct 30, 3:57 PM
Unknown Object (File)
Wed, Oct 30, 3:57 PM
Unknown Object (File)
Wed, Oct 30, 3:57 PM
Unknown Object (File)
Wed, Oct 30, 3:53 PM
Subscribers

Details

Summary

For some features, it's easier to just have a unittest demonstrate
the expected behavior. This sets up that framework, and modifies
the existing code to make it more explicit as to what is going on
when debugging.

Depends on D7659

Test Plan
(cd services/tunnelbroker && RUST_LOG=debug cargo run &)
cd services/commtest && cargo test --test tunnelbroker_integration_test

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

services/commtest/tests/tunnelbroker_integration_test.rs
4–5 ↗(On Diff #25845)

I know this is a "hello world" test, but just two considerations for future design:

  • Is this function intended to be a test? Or a utility to open a connection?
  • Isn't it better to keep the anyhow::Result<()> return type? Anyway, it's an easy change if ever needed. When opening a connection for tests, panicking makes sense
services/tunnelbroker/src/websockets/mod.rs
70 ↗(On Diff #25845)

I'd consider it trace! because it feels redundant as there's already a debug log in line 45

This revision is now accepted and ready to land.Apr 29 2023, 11:38 AM
jon added inline comments.
services/commtest/tests/tunnelbroker_integration_test.rs
4–5 ↗(On Diff #25845)

Is this function intended to be a test? Or a utility to open a connection?

It is meant to be a test. It's easier for me to iterate with rust than JS. So I've been implementing it first in rust to just to ensure that the rust is working before trying to debug stuff in JS.

Isn't it better to keep the anyhow::Result<()> return type?

The test is meant to a be a happy case, if it panics or returns an Err it will still fail the test. I don't feel super strongly about this, and might make the transition in the future to use anyhow. Still not sure if anyhow or retaining the original error is more beneficial

services/tunnelbroker/src/websockets/mod.rs
70 ↗(On Diff #25845)

line 45 doesn't get executed until a message is received, where as this gets emitted right before it begins polling for an event.

This revision was automatically updated to reflect the committed changes.
jon marked 2 inline comments as done.