MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / test_cache_clearing_procedure

Function test_cache_clearing_procedure

graphlite/tests/cache_tests.rs:15–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14#[test]
15fn test_cache_clearing_procedure() {
16 log::debug!("🧪 Testing cache clearing procedure");
17
18 // Use isolated fixture instead of shared one to avoid cache clearing interference
19 // when tests run in parallel
20 let fixture = TestFixture::new().expect("Failed to create test fixture");
21
22 // Create test graph - use a completely separate schema to avoid conflicts
23 let unique_id = std::time::SystemTime::now()
24 .duration_since(std::time::UNIX_EPOCH)
25 .unwrap()
26 .as_nanos();
27 let test_schema = format!("cache_test_schema_{}", unique_id);
28 let test_graph = format!("{}/cache_test_graph", test_schema);
29
30 fixture
31 .query(&format!("CREATE SCHEMA IF NOT EXISTS {}", test_schema))
32 .unwrap();
33 fixture
34 .query(&format!("SESSION SET SCHEMA {}", test_schema))
35 .unwrap();
36 fixture
37 .query(&format!("CREATE GRAPH {}", test_graph))
38 .unwrap();
39 fixture
40 .query(&format!("SESSION SET GRAPH {}", test_graph))
41 .unwrap();
42
43 log::debug!(" 📊 Setting up test data...");
44
45 // Insert test data
46 fixture.assert_query_succeeds("INSERT (:TestNode {id: 1, name: 'cache_test_node1'})");
47 fixture.assert_query_succeeds("INSERT (:TestNode {id: 2, name: 'cache_test_node2'})");
48 fixture.assert_query_succeeds(
49 "MATCH (n1:TestNode {id: 1}), (n2:TestNode {id: 2}) INSERT (n1)-[:TEST_EDGE {type: 'cache_test'}]->(n2)"
50 );
51
52 // Query data to ensure it gets cached
53 log::debug!(" 📋 Querying data to populate cache...");
54 fixture.assert_query_succeeds("MATCH (n:TestNode) RETURN n.id, n.name ORDER BY n.id");
55 fixture.assert_query_succeeds(
56 "MATCH (n1:TestNode)-[r:TEST_EDGE]->(n2:TestNode) RETURN n1.name, n2.name",
57 );
58
59 // Check cache stats before clearing
60 log::debug!(" 📈 Checking cache stats before clearing...");
61 let cache_stats_before = fixture.query("CALL gql.cache_stats()").unwrap();
62 log::debug!(
63 " Cache stats before: {} rows",
64 cache_stats_before.rows.len()
65 );
66 assert!(
67 !cache_stats_before.rows.is_empty(),
68 "Should have cache stats"
69 );
70
71 // Find storage cache entry
72 let mut storage_cache_found = false;

Callers

nothing calls this directly

Calls 4

unwrapMethod · 0.80
queryMethod · 0.45
assert_query_succeedsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected