Skip to content

Commit 3b015b2

Browse files
Luke OsborneLuke Osborne
authored andcommitted
readyset-mysql: Extend 'show readyset status' test
This extends the test that asserts on the output format of 'show readyset status' to fully capture the current format, and to make it so that any update to the format (including additional lines), will cause a test failure. We do this so that we can be sure an upcoming refactor of this logic doesn't change the output format, nor will any future changes without notifying us. Change-Id: If91b84b6fdc8c8dcf9d820eb6826db43b1b7e287 Reviewed-on: https://gerrit.readyset.name/c/readyset/+/6397 Tested-by: Buildkite CI Reviewed-by: Jason Brown <[email protected]>
1 parent b4b7bc3 commit 3b015b2

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

readyset-mysql/tests/integration.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,17 +1823,33 @@ async fn show_readyset_status() {
18231823
let (opts, _handle, shutdown_tx) = setup().await;
18241824
let mut conn = mysql_async::Conn::new(opts).await.unwrap();
18251825
let mut ret: Vec<mysql::Row> = conn.query("SHOW READYSET STATUS;").await.unwrap();
1826+
1827+
let valid_timestamp = |s: String| {
1828+
if s == "NULL" {
1829+
true
1830+
} else {
1831+
NaiveDateTime::parse_from_str(&s, "%Y-%m-%d %H:%M:%S").is_ok()
1832+
}
1833+
};
1834+
1835+
// NOTE: If this readyset extension has changed, verify the new behavior is correct then update
1836+
// the expected values below
1837+
assert_eq!(ret.len(), 5);
18261838
let row = ret.remove(0);
18271839
assert_eq!(row.get::<String, _>(0).unwrap(), "Connection Count");
18281840
assert_eq!(row.get::<String, _>(1).unwrap(), "0");
1829-
assert_eq!(
1830-
ret.first().unwrap().get::<String, _>(0).unwrap(),
1831-
"Snapshot Status"
1832-
);
1833-
assert_eq!(
1834-
ret.first().unwrap().get::<String, _>(1).unwrap(),
1835-
"Completed"
1836-
);
1841+
let row = ret.remove(0);
1842+
assert_eq!(row.get::<String, _>(0).unwrap(), "Snapshot Status");
1843+
assert_eq!(row.get::<String, _>(1).unwrap(), "Completed");
1844+
let row = ret.remove(0);
1845+
assert_eq!(row.get::<String, _>(0).unwrap(), "Last started Controller");
1846+
assert!(valid_timestamp(row.get::<String, _>(1).unwrap()));
1847+
let row = ret.remove(0);
1848+
assert_eq!(row.get::<String, _>(0).unwrap(), "Last completed snapshot");
1849+
assert!(valid_timestamp(row.get::<String, _>(1).unwrap()));
1850+
let row = ret.remove(0);
1851+
assert_eq!(row.get::<String, _>(0).unwrap(), "Last started replication");
1852+
assert!(valid_timestamp(row.get::<String, _>(1).unwrap()));
18371853

18381854
shutdown_tx.shutdown().await;
18391855
}

0 commit comments

Comments
 (0)