summaryrefslogtreecommitdiffstats
path: root/tests/ops.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ops.rs')
-rw-r--r--tests/ops.rs50
1 files changed, 17 insertions, 33 deletions
diff --git a/tests/ops.rs b/tests/ops.rs
index 305976e..8fc6308 100644
--- a/tests/ops.rs
+++ b/tests/ops.rs
@@ -1,12 +1,3 @@
-//! Retention, metrics and backups (§15).
-//!
-//! These are the features that only get tested when something goes wrong, which
-//! is why they are specified here as behaviour rather than as functions that
-//! exist. The load-bearing claims: retention never evicts a byte the index is
-//! serving, it treats a package and its log and its sources as one unit, and it
-//! never deletes the history that explains the bytes. Metrics are computed from
-//! live state, so they cannot drift. Backups are `VACUUM INTO`, so they restore.
-
mod common;
use std::path::{Path, PathBuf};
@@ -85,9 +76,8 @@ fn retention_keeps_the_newest_n_versions_and_never_deletes_a_row() {
assert!(!p.exists(), "an evicted artifact should be gone: {}", p.display());
}
- // Nothing was forgotten: the rows are all still there, marked as purged
- // rather than removed, so "which bytes produced this" stays answerable as
- // history even once the bytes are gone.
+ // Nothing was forgotten: the rows are all still there, marked as purged rather
+ // than removed (§15).
assert_eq!(env.query_i64("SELECT count(*) FROM release", &[]), Some(5));
assert_eq!(env.query_i64("SELECT count(*) FROM artifact", &[]), Some(5));
assert_eq!(
@@ -118,10 +108,9 @@ fn retention_keeps_a_package_with_its_log_and_sources_as_one_unit() {
})
.unwrap();
let files = ops::release_files(&env.cfg, &env.db, oldest).unwrap();
- // Compare against what the database says the release holds, rather than
- // guessing from filename shapes: the store is content-addressed, so the
- // package file is a bare hex name and "does it look like a package" is not
- // a question the path can answer.
+ // Compare against what the database says the release holds: the store is
+ // content-addressed, so "does it look like a package" is not a question the
+ // path can answer.
let held: Vec<(Option<String>, Option<String>, Option<String>)> = env
.db
.read(|c| {
@@ -150,8 +139,8 @@ fn retention_keeps_a_package_with_its_log_and_sources_as_one_unit() {
assert!(Path::new(p).exists(), "the {what} should exist before eviction");
}
- // Eviction removes them together. A package whose log is gone but whose bytes
- // remain is the worst outcome: full price, no explanation.
+ // Eviction removes them together: a package whose log is gone but whose bytes
+ // remain is full price for no explanation.
ops::retention(&env.cfg, &env.db, Some(1)).unwrap();
let still_there: Vec<&PathBuf> = files.iter().filter(|f| f.exists()).collect();
assert!(
@@ -162,9 +151,8 @@ fn retention_keeps_a_package_with_its_log_and_sources_as_one_unit() {
#[test]
fn retention_never_evicts_the_version_the_index_is_serving() {
- // The interesting case: the accepted release is *not* the newest one, because
- // the newest build has not happened yet. A naive "keep the newest N" would
- // delete the bytes the index is pointing at.
+ // The accepted release is *not* the newest one here; a naive "keep the newest
+ // N" would delete the bytes the index points at.
let (env, fx) = env_with_fixture("plain-make");
publish_versions(&env, &fx, "plain-make", 2);
let served = env
@@ -248,8 +236,7 @@ fn metrics_reports_the_operating_numbers_in_prometheus_format() {
let m = ops::metrics(&env.cfg, &env.db).unwrap();
let text = m.to_prometheus();
- // Every family the contract names, and each one parseable as a Prometheus
- // sample: `name{labels} value`, preceded by its TYPE line.
+ // Every family the contract names, each parseable as a Prometheus sample.
for family in [
"aurbuild_queue_depth",
"aurbuild_pending_review_candidates",
@@ -294,8 +281,8 @@ fn metrics_reports_the_operating_numbers_in_prometheus_format() {
#[test]
fn a_fresh_install_reports_a_clean_sheet_not_a_division_by_zero() {
- // A brand-new install has no builds at all. Success rate has to be something
- // an alert rule can read, not NaN and not 0% (which would page).
+ // A brand-new install has no builds at all: success rate has to be something an
+ // alert rule can read, not NaN and not 0%.
let env = Env::new();
let m = ops::metrics(&env.cfg, &env.db).unwrap();
assert_eq!(m.succeeded + m.failed, 0);
@@ -329,8 +316,7 @@ fn backup_is_a_consistent_single_file_that_reopens_and_matches() {
let out = ops::backup(&env.db, &dest).unwrap();
assert_eq!(out, dest);
- // A single file: `VACUUM INTO` produces a compacted database with no WAL, so
- // the backup is one object that can be copied while the server keeps running.
+ // A single file: `VACUUM INTO` produces a compacted database with no WAL.
assert!(dest.exists());
assert!(!Path::new(&format!("{}-wal", dest.display())).exists(), "a backup must not need a sidecar");
assert!(!Path::new(&format!("{}-shm", dest.display())).exists());
@@ -346,8 +332,7 @@ fn backup_is_a_consistent_single_file_that_reopens_and_matches() {
assert_eq!(releases, 1);
drop(probe);
- // The live database is untouched and still in WAL mode — the backup did not
- // checkpoint it out from under the running server.
+ // The live database is untouched and still in WAL mode.
let mode: String = env
.db
.read(|c| Ok(c.query_row("PRAGMA journal_mode", [], |r| r.get::<_, String>(0))?))
@@ -358,8 +343,8 @@ fn backup_is_a_consistent_single_file_that_reopens_and_matches() {
#[test]
fn backup_refuses_to_overwrite_an_existing_snapshot() {
- // A backup that silently replaces last week's backup is not a backup; it is a
- // way of losing the only copy on the day you need it.
+ // A backup that silently replaces last week's backup is a way of losing the
+ // only copy on the day you need it.
let (env, _fx) = env_with_fixture("plain-make");
approve_and_build(&env, "plain-make");
let dest = env.root().join("snap.db");
@@ -370,8 +355,7 @@ fn backup_refuses_to_overwrite_an_existing_snapshot() {
assert!(std::fs::metadata(&dest).unwrap().len() > 0);
}
-/// Set a directory's mtime into the past, so the grace period can be exercised
-/// without sleeping for an hour.
+/// Set a directory's mtime into the past, so the grace period can be exercised.
fn backdate(path: &Path, secs: u64) {
let old = std::time::SystemTime::now() - std::time::Duration::from_secs(secs);
for f in std::fs::read_dir(path).into_iter().flatten().flatten() {