Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion database/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl Pool {
mod tests {
use super::*;
use crate::metric::Metric;
use crate::tests::builder::{job, RequestBuilder};
use crate::tests::builder::{job, CollectorBuilder, RequestBuilder};
use crate::tests::run_postgres_test;
use crate::{tests::run_db_test, BenchmarkRequestType, Commit, CommitType, Date};
use chrono::Utc;
Expand Down Expand Up @@ -1222,4 +1222,45 @@ mod tests {
})
.await;
}

#[tokio::test]
async fn purge_artifact() {
run_postgres_test(|ctx| async {
let db = ctx.db();

ctx.upsert_master_artifact("foo").await;
ctx.insert_master_request("foo", "bar", 1).await;
db.enqueue_benchmark_job(
"foo",
Target::X86_64UnknownLinuxGnu,
CodegenBackend::Llvm,
Profile::Check,
0,
)
.await
.unwrap()
.unwrap();
db.purge_artifact(&ArtifactId::Tag("foo".to_string())).await;

assert!(!db
.load_benchmark_request_index()
.await
.unwrap()
.contains_tag("foo"));

let collector = ctx.add_collector(CollectorBuilder::default()).await;
assert!(db
.dequeue_benchmark_job(
collector.name(),
collector.target(),
collector.benchmark_set(),
)
.await
.unwrap()
.is_none());

Ok(ctx)
})
.await;
}
}
11 changes: 9 additions & 2 deletions database/src/pool/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,12 +1582,19 @@ where
// thanks to ON DELETE CASCADE.
let info = aid.info();
self.conn()
.execute("delete from artifact where name = $1", &[&info.name])
.execute("DELETE FROM artifact WHERE name = $1", &[&info.name])
.await
.unwrap();
self.conn()
.execute(
"delete from pull_request_build where bors_sha = $1",
"DELETE FROM pull_request_build WHERE bors_sha = $1",
&[&info.name],
)
.await
.unwrap();
self.conn()
.execute(
"DELETE FROM benchmark_request WHERE tag = $1",
&[&info.name],
)
.await
Expand Down
Loading