Verified Commit 0f0377df authored by Dmitry Gruzd's avatar Dmitry Gruzd 2️⃣ Committed by GitLab
Browse files

fix(test): stabilize flaky cursor pagination determinism test

parent cb065970
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -326,18 +326,20 @@ impl ResponseView {
            .collect()
    }

    /// Return the set of distinct path_ids present in edges.
    /// Return the distinct path_ids present in edges, in first-seen order.
    ///
    /// Tests should use this to discover which paths exist, then call
    /// [`path`] for each one explicitly.
    /// Satisfies [`Requirement::PathFinding`].
    pub fn path_ids(&self) -> MustInspect<HashSet<usize>> {
    pub fn path_ids(&self) -> MustInspect<Vec<usize>> {
        self.tracker.satisfy(Requirement::PathFinding);
        let mut seen = HashSet::new();
        let ids = self
            .response
            .edges
            .iter()
            .filter_map(|e| e.path_id)
            .filter(|id| seen.insert(*id))
            .collect();
        MustInspect::new(ids, "path_ids()")
    }
@@ -993,7 +995,7 @@ pub(crate) mod tests {
            pagination: None,
        };
        let view = ResponseView::new(resp);
        assert_eq!(view.path_ids(), HashSet::from([0, 2]));
        assert_eq!(*view.path_ids(), vec![0, 2]);
    }

    #[test]
+2 −8
Original line number Diff line number Diff line
@@ -560,8 +560,8 @@ pub(super) async fn cursor_path_finding_pages_cover_all_paths(ctx: &TestContext)
}

pub(super) async fn cursor_path_finding_is_deterministic(ctx: &TestContext) {
    // Run the same cursored path finding query twice. The ORDER BY
    // (depth, _gkg_path, _gkg_edge_kinds) should produce identical results.
    // Run the same cursored path finding query twice and verify both runs
    // return the same set of destination nodes.
    let query = r#"{
        "query_type": "path_finding",
        "nodes": [
@@ -581,13 +581,7 @@ pub(super) async fn cursor_path_finding_is_deterministic(ctx: &TestContext) {

    let pids1 = resp1.path_ids();
    let pids2 = resp2.path_ids();
    assert_eq!(
        pids1.len(),
        pids2.len(),
        "same query should return same path count"
    );

    // Compare the destination nodes of each path to verify identical ordering.
    let dests1: Vec<i64> = pids1
        .iter()
        .map(|&pid| resp1.path(pid).last().unwrap().to_id)