Skip to content

Commit

Permalink
Added serial annotation for test_partial_content to prevent test stat…
Browse files Browse the repository at this point in the history
…e intermingling and retry loops for merge tests that observe state between transactions to prevent flakey failures
  • Loading branch information
criminosis committed Nov 13, 2024
1 parent 5a4931b commit 97ca6c1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 21 deletions.
3 changes: 3 additions & 0 deletions gremlin-client/tests/integration_client_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod aio {

use rstest::*;
use rstest_reuse::{self, *};
use serial_test::serial;

use crate::common;

Expand Down Expand Up @@ -63,6 +64,7 @@ mod aio {
}

#[apply(common::serializers)]
#[serial(test_session_empty_query)]
#[cfg(feature = "async-std-runtime")]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
async fn test_session_empty_query(protocol: IoProtocol) {
Expand Down Expand Up @@ -118,6 +120,7 @@ mod aio {
}

#[apply(common::serializers)]
#[serial(test_partial_content)]
#[cfg(feature = "async-std-runtime")]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
async fn test_partial_content(protocol: IoProtocol) {
Expand Down
63 changes: 42 additions & 21 deletions gremlin-client/tests/integration_traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,19 +373,30 @@ mod merge_tests {
injection_map.insert("match_params".into(), on_match_map.into());

let do_merge_edge = |g: GraphTraversalSource<SyncTerminator>| -> Map {
g.inject(vec![injection_map.clone().into()])
.unfold()
.as_("payload")
.merge_e(__.select("payload").select("merge_params"))
.option((
Merge::OnCreate,
__.select("payload").select("create_params"),
))
.option((Merge::OnMatch, __.select("payload").select("match_params")))
.element_map(())
.next()
.expect("Should get a response")
.expect("Should return a edge properties")
let mut attempt = 0;
loop {
attempt += 1;
let response = g
.inject(vec![injection_map.clone().into()])
.unfold()
.as_("payload")
.merge_e(__.select("payload").select("merge_params"))
.option((
Merge::OnCreate,
__.select("payload").select("create_params"),
))
.option((Merge::OnMatch, __.select("payload").select("match_params")))
.element_map(())
.next();
if response.is_ok() {
break response;
} else if attempt > 10 {
std::panic!("mergeE vertices not observed before attempt exhaustion")
}
std::thread::sleep(std::time::Duration::from_millis(10));
}
.expect("Should get a response")
.expect("Should return a edge properties")
};

let on_create_edge_properties = do_merge_edge(g.clone());
Expand Down Expand Up @@ -436,14 +447,24 @@ mod merge_tests {
assignment_map.insert(Direction::Out.into(), vertex_b.id().into());
assignment_map.insert(T::Label.into(), expected_edge_label.into());

let anonymous_merge_e_properties = g
.inject(1)
.unfold()
.coalesce::<Edge, _>([__.merge_e(assignment_map)])
.element_map(())
.next()
.expect("Should get a response")
.expect("Should return a edge properties");
let mut attempt = 0;
let anonymous_merge_e_properties = loop {
attempt += 1;
let response = g
.inject(1)
.unfold()
.coalesce::<Edge, _>([__.merge_e(assignment_map.clone())])
.element_map(())
.next();
if response.is_ok() {
break response;
} else if attempt > 10 {
std::panic!("mergeE vertices not observed before attempt exhaustion")
}
std::thread::sleep(std::time::Duration::from_millis(10));
}
.expect("Should get a response")
.expect("Should return a edge properties");

let incoming_vertex: &Map = anonymous_merge_e_properties
.get(Direction::In)
Expand Down

0 comments on commit 97ca6c1

Please sign in to comment.