Skip to content

Commit 846b9e7

Browse files
authored
Increase test timeout from 1s -> 10s (#672)
* Increase test timeout from 1s -> 10s * Up the timeout in the data explorer tests Again, the test is not about speed, it's just about blowing up at some point when it looks like we are really hung * Use named constant in data explorer tests
1 parent fedc74c commit 846b9e7

File tree

2 files changed

+27
-29
lines changed

2 files changed

+27
-29
lines changed

crates/amalthea/src/fixtures/dummy_frontend.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,16 @@ impl DummyFrontend {
231231
}
232232

233233
pub fn recv(socket: &Socket) -> Message {
234-
// It's important to wait with a timeout because the kernel thread might
235-
// have panicked, preventing it from sending the expected message. The
236-
// tests would then hang indefinitely.
234+
// It's important to wait with a timeout because the kernel thread might have
235+
// panicked, preventing it from sending the expected message. The tests would then
236+
// hang indefinitely. We wait a decently long time (10s), as test processes are
237+
// run in parallel and we think they seem to slow each other down occasionally
238+
// (we've definitely seen false positive failures with a timeout of just 1s,
239+
// particularly when running with nextest).
237240
//
238-
// Note that the panic hook will still have run to record the panic, so
239-
// we'll get expected panic information in the test output.
240-
if socket.poll_incoming(1000).unwrap() {
241+
// Note that the panic hook will still have run to record the panic, so we'll get
242+
// expected panic information in the test output.
243+
if socket.poll_incoming(10000).unwrap() {
241244
return Message::read_from_socket(socket).unwrap();
242245
}
243246

crates/ark/tests/data_explorer.rs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ use libr::R_GlobalEnv;
7171
use libr::Rf_eval;
7272
use stdext::assert_match;
7373

74+
// We don't care about events coming back quickly, we just don't want to deadlock
75+
// in case something has gone wrong, so we pick a pretty long timeout to use throughout
76+
// the tests.
77+
static RECV_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10);
78+
7479
/// Test helper method to open a built-in dataset in the data explorer.
7580
///
7681
/// Parameters:
@@ -89,9 +94,7 @@ fn open_data_explorer(dataset: String) -> socket::comm::CommSocket {
8994
});
9095

9196
// Wait for the new comm to show up.
92-
let msg = comm_manager_rx
93-
.recv_timeout(std::time::Duration::from_secs(1))
94-
.unwrap();
97+
let msg = comm_manager_rx.recv_timeout(RECV_TIMEOUT).unwrap();
9598
match msg {
9699
CommManagerEvent::Opened(socket, _value) => {
97100
assert_eq!(socket.comm_name, "positron.dataExplorer");
@@ -122,9 +125,7 @@ fn open_data_explorer_from_expression(
122125
})?;
123126

124127
// Release the R lock and wait for the new comm to show up.
125-
let msg = comm_manager_rx
126-
.recv_timeout(std::time::Duration::from_secs(1))
127-
.unwrap();
128+
let msg = comm_manager_rx.recv_timeout(RECV_TIMEOUT).unwrap();
128129

129130
match msg {
130131
CommManagerEvent::Opened(socket, _value) => {
@@ -196,10 +197,7 @@ fn expect_column_profile_results(
196197
let msg = CommMsg::Rpc(id, json);
197198
socket.incoming_tx.send(msg).unwrap();
198199

199-
let msg = socket
200-
.outgoing_rx
201-
.recv_timeout(std::time::Duration::from_secs(1))
202-
.unwrap();
200+
let msg = socket.outgoing_rx.recv_timeout(RECV_TIMEOUT).unwrap();
203201

204202
// Because during tests, no threads are created with r_task::spawn_idle, the messages are in
205203
// an incorrect order. We first receive the DataExplorerFrontndEvent with the column profiles
@@ -217,10 +215,7 @@ fn expect_column_profile_results(
217215
}
218216
);
219217

220-
let msg = socket
221-
.outgoing_rx
222-
.recv_timeout(std::time::Duration::from_secs(1))
223-
.unwrap();
218+
let msg = socket.outgoing_rx.recv_timeout(RECV_TIMEOUT).unwrap();
224219

225220
let reply: DataExplorerBackendReply = match msg {
226221
CommMsg::Rpc(_id, value) => {
@@ -1081,7 +1076,7 @@ fn test_live_updates() {
10811076
EVENTS.console_prompt.emit(());
10821077

10831078
// Wait for an update event to arrive
1084-
assert_match!(socket.outgoing_rx.recv_timeout(std::time::Duration::from_secs(1)).unwrap(),
1079+
assert_match!(socket.outgoing_rx.recv_timeout(RECV_TIMEOUT).unwrap(),
10851080
CommMsg::Data(value) => {
10861081
// Make sure it's a data update event.
10871082
assert_match!(serde_json::from_value::<DataExplorerFrontendEvent>(value).unwrap(),
@@ -1123,7 +1118,7 @@ DataExplorerBackendReply::SetSortColumnsReply() => {});
11231118
EVENTS.console_prompt.emit(());
11241119

11251120
// Wait for an update event to arrive
1126-
assert_match!(socket.outgoing_rx.recv_timeout(std::time::Duration::from_secs(1)).unwrap(),
1121+
assert_match!(socket.outgoing_rx.recv_timeout(RECV_TIMEOUT).unwrap(),
11271122
CommMsg::Data(value) => {
11281123
// Make sure it's a data update event.
11291124
assert_match!(serde_json::from_value::<DataExplorerFrontendEvent>(value).unwrap(),
@@ -1153,7 +1148,7 @@ DataExplorerBackendReply::SetSortColumnsReply() => {});
11531148
EVENTS.console_prompt.emit(());
11541149

11551150
// This should trigger a schema update event.
1156-
assert_match!(socket.outgoing_rx.recv_timeout(std::time::Duration::from_secs(1)).unwrap(),
1151+
assert_match!(socket.outgoing_rx.recv_timeout(RECV_TIMEOUT).unwrap(),
11571152
CommMsg::Data(value) => {
11581153
// Make sure it's schema update event.
11591154
assert_match!(serde_json::from_value::<DataExplorerFrontendEvent>(value).unwrap(),
@@ -1182,7 +1177,7 @@ DataExplorerBackendReply::SetSortColumnsReply() => {});
11821177
EVENTS.console_prompt.emit(());
11831178

11841179
// Wait for an close event to arrive
1185-
assert_match!(socket.outgoing_rx.recv_timeout(std::time::Duration::from_secs(1)).unwrap(),
1180+
assert_match!(socket.outgoing_rx.recv_timeout(RECV_TIMEOUT).unwrap(),
11861181
CommMsg::Close => {}
11871182
);
11881183
}
@@ -1369,7 +1364,7 @@ fn test_invalid_filters_preserved() {
13691364
EVENTS.console_prompt.emit(());
13701365

13711366
// Wait for an update event to arrive
1372-
assert_match!(socket.outgoing_rx.recv_timeout(std::time::Duration::from_secs(1)).unwrap(),
1367+
assert_match!(socket.outgoing_rx.recv_timeout(RECV_TIMEOUT).unwrap(),
13731368
CommMsg::Data(value) => {
13741369
// Make sure it's a data update event.
13751370
assert_match!(serde_json::from_value::<DataExplorerFrontendEvent>(value).unwrap(),
@@ -1397,7 +1392,7 @@ fn test_invalid_filters_preserved() {
13971392
EVENTS.console_prompt.emit(());
13981393

13991394
// Wait for an update event to arrive
1400-
assert_match!(socket.outgoing_rx.recv_timeout(std::time::Duration::from_secs(1)).unwrap(),
1395+
assert_match!(socket.outgoing_rx.recv_timeout(RECV_TIMEOUT).unwrap(),
14011396
CommMsg::Data(value) => {
14021397
// Make sure it's a data update event.
14031398
assert_match!(serde_json::from_value::<DataExplorerFrontendEvent>(value).unwrap(),
@@ -1425,7 +1420,7 @@ fn test_invalid_filters_preserved() {
14251420
EVENTS.console_prompt.emit(());
14261421

14271422
// Wait for an update event to arrive
1428-
assert_match!(socket.outgoing_rx.recv_timeout(std::time::Duration::from_secs(1)).unwrap(),
1423+
assert_match!(socket.outgoing_rx.recv_timeout(RECV_TIMEOUT).unwrap(),
14291424
CommMsg::Data(value) => {
14301425
// Make sure it's a data update event.
14311426
assert_match!(serde_json::from_value::<DataExplorerFrontendEvent>(value).unwrap(),
@@ -1673,7 +1668,7 @@ fn test_update_data_filters_reapplied() {
16731668

16741669
// Wait for an update event to arrive
16751670
// Since only data changed, we expect a Data Update Event
1676-
assert_match!(socket.outgoing_rx.recv_timeout(std::time::Duration::from_secs(1)).unwrap(),
1671+
assert_match!(socket.outgoing_rx.recv_timeout(RECV_TIMEOUT).unwrap(),
16771672
CommMsg::Data(value) => {
16781673
// Make sure it's a data update event.
16791674
assert_match!(serde_json::from_value::<DataExplorerFrontendEvent>(value).unwrap(),
@@ -1769,7 +1764,7 @@ fn test_data_update_num_rows() {
17691764
EVENTS.console_prompt.emit(());
17701765

17711766
// Wait for an update event to arrive
1772-
assert_match!(socket.outgoing_rx.recv_timeout(std::time::Duration::from_secs(1)).unwrap(),
1767+
assert_match!(socket.outgoing_rx.recv_timeout(RECV_TIMEOUT).unwrap(),
17731768
CommMsg::Data(value) => {
17741769
// Make sure it's a data update event.
17751770
assert_match!(serde_json::from_value::<DataExplorerFrontendEvent>(value).unwrap(),

0 commit comments

Comments
 (0)