-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add jds_should_not_panic_if_jdc_shutsdown integration test
- Loading branch information
1 parent
8525f4e
commit 9047933
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use integration_tests_sv2::*; | ||
|
||
use roles_logic_sv2::parsers::{CommonMessages, PoolMessages}; | ||
|
||
// This test verifies that the `jds` (Job Distributor Server) does not panic when the `jdc` | ||
// (Job Distributor Client) shuts down. | ||
// | ||
// The test follows these steps: | ||
// 1. Start a Template Provider (`tp`) and a Pool. | ||
// 2. Start the `jds` and the `jdc`, ensuring the `jdc` connects to the `jds`. | ||
// 3. Shut down the `jdc` and ensure the `jds` remains operational without panicking. | ||
// 4. Verify that the `jdc`'s address can be reused by asserting that a new `TcpListener` can bind | ||
// to the same address. | ||
// 5. Start a Sniffer as a proxy for observing messages exchanged between the `jds` and other | ||
// components. | ||
// 6. Reconnect a new `jdc` to the Sniffer and ensure the expected `SetupConnection` message is | ||
// received from the `jdc`. | ||
// | ||
// This ensures that the shutdown of the `jdc` is handled gracefully by the `jds`, and subsequent | ||
// connections or operations continue without issues. | ||
// | ||
// # Notes | ||
// - The test waits for a brief duration (`1 second`) after shutting down the `jdc` to allow for any | ||
// internal cleanup or reconnection attempts. | ||
#[tokio::test] | ||
async fn jds_should_not_panic_if_jdc_shutsdown() { | ||
let (_tp, tp_addr) = start_template_provider(None).await; | ||
let (_pool, pool_addr) = start_pool(Some(tp_addr)).await; | ||
let (_jds, jds_addr) = start_jds(tp_addr).await; | ||
let (jdc, jdc_addr) = start_jdc(pool_addr, tp_addr, jds_addr).await; | ||
jdc.shutdown(); | ||
tokio::time::sleep(std::time::Duration::from_secs(1)).await; | ||
assert!(tokio::net::TcpListener::bind(jdc_addr).await.is_ok()); | ||
let (sniffer, sniffer_addr) = start_sniffer("0".to_string(), jds_addr, false, None).await; | ||
let (_jdc, _jdc_addr) = start_jdc(pool_addr, tp_addr, sniffer_addr).await; | ||
assert_common_message!(sniffer.next_message_from_downstream(), SetupConnection); | ||
} |