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

fix(telnet-host): properly crash; crash fails tests #341

Merged
merged 1 commit into from
Jun 29, 2024

Conversation

abesto
Copy link
Collaborator

@abesto abesto commented Jun 26, 2024

Setup

In one terminal, start moor-telnet-host and leave it running:

[abesto@keyrit-desktop moor]$ cargo run -p moor-telnet-host

Before

Attempting to start moor-telnet-host results in the new moor-telnet-host exiting cleanly with status 0:

[abesto@keyrit-desktop moor]$ cargo run -p moor-telnet-host
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/moor-telnet-host`
2024-06-26T22:15:26.478132Z  INFO main moor_telnet_host: crates/telnet-host/src/main.rs:87: Host started.
2024-06-26T22:15:26.478236Z  INFO main moor_telnet_host: crates/telnet-host/src/main.rs:90: ZMQ client loop exited, stopping...
2024-06-26T22:15:26.478274Z  INFO main moor_telnet_host: crates/telnet-host/src/main.rs:99: Done.
[abesto@keyrit-desktop moor]$ echo $?
0

As a side-effect, tests can get very confused - they can end up talking to the wrong telnet host / daemon / MOO server.

After

moor-telnet-host crashes correctly:

[abesto@keyrit-desktop moor]$ cargo run -p moor-telnet-host
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/moor-telnet-host`
2024-06-26T22:16:54.662057Z  INFO main moor_telnet_host: crates/telnet-host/src/main.rs:87: Host started.
Error: 
   0: Address already in use (os error 98)

Location:
   crates/telnet-host/src/telnet.rs:339

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Networked tests notice this, and act accordingly:

[abesto@keyrit-desktop moor]$ cargo test -p moor-telnet-host test_suspend_read_notify
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.09s
     Running unittests src/main.rs (target/debug/deps/moor_telnet_host-edc79f55e714fe1e)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/integration_test.rs (target/debug/deps/integration_test-f74627a034bcf313)

running 1 test
test test_suspend_read_notify ... FAILED

failures:

---- test_suspend_read_notify stdout ----
[daemon]: 2024-06-26T22:18:10.407089Z  INFO main moor_daemon: crates/daemon/src/main.rs:230: Daemon starting...
Test definition: /home/abesto/moor/crates/telnet-host/tests/moot/suspend_read_notify.moot
51038 >> connect #3
[telnet-host]: 2024-06-26T22:18:10.511314Z  INFO main moor_telnet_host: crates/telnet-host/src/main.rs:87: Host started.
[telnet-host]: Error: 
[telnet-host]:    0: Address already in use (os error 98)
[telnet-host]: 
[telnet-host]: Location:
[telnet-host]:    crates/telnet-host/src/telnet.rs:339
[telnet-host]: 
[telnet-host]: Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
[telnet-host]: Run with RUST_BACKTRACE=full to include source snippets.
[daemon]: 2024-06-26T22:18:10.524272Z  INFO main moor_daemon: crates/daemon/src/main.rs:235: Opened database path="test.db"
--- %< ---
51038 << *** Connected ***
51038 >> ; return 200; "moot-line:1"; "TelnetMootRunner::eval";
51038 << 200
thread 'test_suspend_read_notify' panicked at /home/abesto/moor/crates/moot/src/lib.rs:503:33:
Invalid state before processing line 2: Unexpected exit: telnet-host: Some(ExitStatus(unix_wait_status(256)))

Location:
    crates/moot/src/lib.rs:334:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Killing telnet-host (pid=580834)
Killing daemon (pid=580824)


failures:
    test_suspend_read_notify

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.48s

error: test failed, to rerun pass `-p moor-telnet-host --test integration_test`

@rdaum rdaum merged commit 9311b9a into rdaum:main Jun 29, 2024
5 checks passed
@rdaum
Copy link
Owner

rdaum commented Jun 29, 2024

Sorry took so long to merge this. I got distracted and confused and forgot about it.

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

Successfully merging this pull request may close these issues.

2 participants