diff options
Diffstat (limited to 'tests/ops.rs')
| -rw-r--r-- | tests/ops.rs | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/tests/ops.rs b/tests/ops.rs index 8fc6308..821b733 100644 --- a/tests/ops.rs +++ b/tests/ops.rs @@ -18,7 +18,6 @@ fn approve_and_build(env: &Env, name: &str) { pipeline::run(&env.cfg, &env.db, &id).unwrap(); } -/// Publish the same pkgbase N times, each at a higher version. fn publish_versions(env: &Env, fx: &Fixture, name: &str, n: usize) { approve_and_build(env, name); for i in 1..n { @@ -55,7 +54,6 @@ fn retention_keeps_the_newest_n_versions_and_never_deletes_a_row() { assert_eq!(report.releases_evicted, 3, "5 versions, keep 2: {report:?}"); assert!(report.files_removed >= 3, "each evicted release removes its package: {report:?}"); - // The newest two survive; the older three lose their bytes. let kept: Vec<PathBuf> = env .db .read(|c| { @@ -76,8 +74,6 @@ 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 (ยง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!( @@ -88,7 +84,6 @@ fn retention_keeps_the_newest_n_versions_and_never_deletes_a_row() { env.query_i64("SELECT count(*) FROM release WHERE purged_at IS NOT NULL", &[]), Some(3) ); - // And the run itself is on the record. assert_eq!(env.query_i64("SELECT count(*) FROM gc_run", &[]), Some(1)); assert!(env.query_i64("SELECT count(*) FROM audit WHERE action='retention'", &[]) == Some(1)); } @@ -108,9 +103,6 @@ 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: 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| { @@ -139,8 +131,6 @@ 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 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!( @@ -151,8 +141,6 @@ 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 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 @@ -176,8 +164,6 @@ fn retention_never_evicts_the_version_the_index_is_serving() { }) .unwrap(); - // Publish a third version, then pretend the index still serves the first by - // withdrawing the newer ones from the index. env.exec("UPDATE package SET state='removed' WHERE state='in_index'", &[]); env.exec( "UPDATE package SET state='in_index' WHERE release_id=?1", @@ -196,11 +182,8 @@ fn staging_dirs_are_swept_only_when_their_build_is_finished() { let (env, fx) = env_with_fixture("plain-make"); approve_and_build(&env, "plain-make"); - // An old dir belonging to a finished build: disposable. let done = env.cfg.staging_dir().join("finished-build"); - // An old dir with no build row at all: left over from a crash. let orphan = env.cfg.staging_dir().join("no-such-build"); - // An old dir whose build is still running: NOT disposable, however old it is. let live = env.cfg.staging_dir().join("live-build"); for d in [&done, &orphan, &live] { std::fs::create_dir_all(d).unwrap(); @@ -226,17 +209,14 @@ fn staging_dirs_are_swept_only_when_their_build_is_finished() { fn metrics_reports_the_operating_numbers_in_prometheus_format() { let (env, fx) = env_with_fixture("plain-make"); approve_and_build(&env, "plain-make"); - // Leave one review unapproved so there is review debt to measure. fx.bump(&[("pkgver", "9.9")]); aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap(); - // And a queued build that has never run, so queue depth is not vacuously zero. let c = candidates::pending_candidates(&env.db).unwrap().remove(0); let _ = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c); let m = ops::metrics(&env.cfg, &env.db).unwrap(); let text = m.to_prometheus(); - // Every family the contract names, each parseable as a Prometheus sample. for family in [ "aurbuild_queue_depth", "aurbuild_pending_review_candidates", @@ -281,8 +261,6 @@ 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%. let env = Env::new(); let m = ops::metrics(&env.cfg, &env.db).unwrap(); assert_eq!(m.succeeded + m.failed, 0); @@ -297,7 +275,6 @@ fn the_http_metrics_endpoint_serves_scrapeable_text() { assert_eq!(page.status, 200); assert!(page.body.contains("# TYPE aurbuild_queue_depth gauge")); assert!(page.body.contains("aurbuild_sqlite_wal_size_bytes")); - // No session needed: a scraper cannot log in. Check it with a bare socket. let (headers, body) = web.raw_get("/metrics"); assert!(body.contains("aurbuild_up 1"), "metrics should be reachable unauthenticated"); let ct = headers @@ -316,13 +293,10 @@ 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. 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()); - // It is a real database with the same schema and the same crown jewel: the - // approval trail. let probe = rusqlite::Connection::open(&dest).unwrap(); let version: i64 = probe.query_row("PRAGMA user_version", [], |r| r.get(0)).unwrap(); assert!(version >= 8, "the snapshot carries the migrated schema, got {version}"); @@ -332,7 +306,6 @@ 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. let mode: String = env .db .read(|c| Ok(c.query_row("PRAGMA journal_mode", [], |r| r.get::<_, String>(0))?)) @@ -343,8 +316,6 @@ 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 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"); @@ -355,7 +326,6 @@ 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. 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() { |
