MAIN: Add test for connect timeout#596
Merged
Enet4 merged 2 commits intoEnet4:masterfrom Nov 18, 2024
Merged
Conversation
Enet4
reviewed
Nov 15, 2024
Owner
Enet4
left a comment
There was a problem hiding this comment.
The extra timeout tolerance was too short for my machine, which would often exceed by a few milliseconds. I made a few tweaks to clarify when this happens and increase the tolerance from 10ms to 25ms. I can push them to this branch soon, if that's okay with you.
ul/tests/association.rs --- 1/3 --- Rust
2 use dicom_ul::ClientAssociationOptions;
3 use rstest::rstest;
4 use std::time::Instant;
6 const TIMEOUT_TOLERANCE: u64 = 25;
7
8 #[rstest]
9 #[case(100)]
10 #[case(500)]
ul/tests/association.rs --- 2/3 --- Rust
16
17 let now = Instant::now();
18 let _res = scu_init.establish_with("RANDOM@167.167.167.167:11111");
19 let elapsed = now.elapsed();
20 assert!(elapsed.as_millis() < (timeout + 10).into());
22 assert!(
23 elapsed.as_millis() < (timeout + TIMEOUT_TOLERANCE).into(),
24 "Elapsed time {}ms exceeded the timeout {}", elapsed.as_millis(), timeout
25 );
26 }
27
28 #[cfg(feature = "async")]
ul/tests/association.rs --- 3/3 --- Rust
38 .await;
39 assert!(res.is_err());
40 let elapsed = now.elapsed();
41 println!("Elapsed time: {:?}", elapsed);
42 assert!(elapsed.as_millis() < (timeout + 10).into());
47 assert!(
48 elapsed.as_millis() < (timeout + TIMEOUT_TOLERANCE).into(),
49 "Elapsed time {}ms exceeded the timeout {}ms", elapsed.as_millis(), timeout
50 );
51 }- the connection timeout limit may be overshot on some machines (windows) - also improve assertion message
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.