MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test_statement_logging_basic

Function test_statement_logging_basic

src/environmentd/tests/server.rs:477–673  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

475#[mz_ore::test]
476#[allow(clippy::disallowed_methods)]
477fn test_statement_logging_basic() {
478 let (server, mut client) = setup_statement_logging(1.0, 1.0, "");
479 client.execute("SELECT 1", &[]).unwrap();
480 // We test that queries of this view execute on a cluster.
481 // If we ever change the threshold for constant folding such that
482 // this gets to run on environmentd, change this query.
483 client
484 .execute(
485 "CREATE VIEW v AS SELECT * FROM generate_series(1, 10001)",
486 &[],
487 )
488 .unwrap();
489 client.execute("SELECT * FROM v", &[]).unwrap();
490 client.execute("CREATE DEFAULT INDEX i ON v", &[]).unwrap();
491 client.execute("SELECT * FROM v", &[]).unwrap();
492 let _ = client.execute("SELECT 1/0", &[]);
493 client.execute("CREATE TABLE t (x int)", &[]).unwrap();
494 client.execute("SELECT * FROM t", &[]).unwrap();
495
496 #[derive(Debug)]
497 struct Record {
498 sample_rate: f64,
499 began_at: DateTime<Utc>,
500 finished_at: DateTime<Utc>,
501 finished_status: String,
502 error_message: Option<String>,
503 prepared_at: DateTime<Utc>,
504 execution_strategy: Option<String>,
505 result_size: Option<i64>,
506 rows_returned: Option<i64>,
507 execution_timestamp: Option<u64>,
508 }
509
510 let mut client = server.connect_internal(postgres::NoTls).unwrap();
511
512 let result = Retry::default()
513 .max_duration(Duration::from_secs(30))
514 .retry(|_| {
515 let sl_results = client
516 .query(
517 "SELECT
518 mseh.sample_rate,
519 mseh.began_at,
520 mseh.finished_at,
521 mseh.finished_status,
522 mseh.error_message,
523 mpsh.prepared_at,
524 mseh.execution_strategy,
525 mseh.result_size,
526 mseh.rows_returned,
527 mseh.execution_timestamp
528FROM
529 mz_internal.mz_statement_execution_history AS mseh
530 LEFT JOIN
531 mz_internal.mz_prepared_statement_history AS mpsh
532 ON mseh.prepared_statement_id = mpsh.id
533 JOIN
534 (SELECT DISTINCT sql, sql_hash, redacted_sql FROM mz_internal.mz_sql_text) AS mst

Callers

nothing calls this directly

Calls 15

setup_statement_loggingFunction · 0.85
to_datetimeFunction · 0.85
unwrapMethod · 0.80
max_durationMethod · 0.80
gatherMethod · 0.80
expectMethod · 0.80
executeMethod · 0.45
connect_internalMethod · 0.45
retryMethod · 0.45
queryMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected