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

Function test_cache_stats_procedure

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

Source from the content-addressed store, hash-verified

368
369#[test]
370fn test_cache_stats_procedure() {
371 log::debug!("📊 Testing cache stats procedure");
372
373 // Use isolated fixture to avoid interference from cache clearing in parallel tests
374 let fixture = TestFixture::new().expect("Failed to create test fixture");
375
376 // Create test graph - use separate schema to avoid conflicts
377 let unique_id = std::time::SystemTime::now()
378 .duration_since(std::time::UNIX_EPOCH)
379 .unwrap()
380 .as_nanos();
381 let test_schema = format!("cache_stats_schema_{}", unique_id);
382 let test_graph = format!("{}/cache_stats_test", test_schema);
383
384 fixture
385 .query(&format!("CREATE SCHEMA IF NOT EXISTS {}", test_schema))
386 .unwrap();
387 fixture
388 .query(&format!("SESSION SET SCHEMA {}", test_schema))
389 .unwrap();
390 fixture
391 .query(&format!("CREATE GRAPH {}", test_graph))
392 .unwrap();
393 fixture
394 .query(&format!("SESSION SET GRAPH {}", test_graph))
395 .unwrap();
396
397 // Insert some data
398 fixture.assert_query_succeeds("INSERT (:StatsTestNode {id: 1, data: 'test1'})");
399 fixture.assert_query_succeeds("INSERT (:StatsTestNode {id: 2, data: 'test2'})");
400
401 // Query to populate cache
402 fixture.assert_query_succeeds("MATCH (n:StatsTestNode) RETURN n.id, n.data");
403
404 // Test cache stats procedure
405 let stats_result = fixture.query("CALL gql.cache_stats()").unwrap();
406
407 log::debug!(" 📈 Cache stats returned {} rows", stats_result.rows.len());
408 assert!(
409 !stats_result.rows.is_empty(),
410 "Cache stats should return at least one row"
411 );
412
413 // Verify expected columns are present
414 assert!(
415 stats_result.variables.contains(&"cache_type".to_string()),
416 "Should have cache_type column"
417 );
418 assert!(
419 stats_result.variables.contains(&"entries".to_string()),
420 "Should have entries column"
421 );
422
423 // Look for storage cache row
424 let mut found_storage_cache = false;
425 for row in &stats_result.rows {
426 if let Some(Value::String(cache_type)) = row.values.get("cache_type") {
427 log::debug!(" Found cache type: {}", cache_type);

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