|
1 | 1 | use crate::{ |
2 | | - ArtifactCollection, ArtifactId, ArtifactIdNumber, BenchmarkRequest, BenchmarkRequestIndex, |
3 | | - BenchmarkRequestStatus, CodegenBackend, CompileBenchmark, Target, |
| 2 | + ArtifactCollection, ArtifactId, ArtifactIdNumber, BenchmarkJob, BenchmarkRequest, |
| 3 | + BenchmarkRequestIndex, BenchmarkRequestStatus, BenchmarkSet, CodegenBackend, CollectorConfig, |
| 4 | + CompileBenchmark, Target, |
4 | 5 | }; |
5 | 6 | use crate::{CollectionId, Index, Profile, QueuedCommit, Scenario, Step}; |
6 | 7 | use chrono::{DateTime, Utc}; |
@@ -220,6 +221,17 @@ pub trait Connection: Send + Sync { |
220 | 221 | profile: &Profile, |
221 | 222 | benchmark_set: u32, |
222 | 223 | ) -> anyhow::Result<()>; |
| 224 | + |
| 225 | + /// Get the confiuguration for a collector by the name of the collector |
| 226 | + async fn get_collector_config(&self, collector_name: &str) -> anyhow::Result<CollectorConfig>; |
| 227 | + |
| 228 | + /// Get the confiuguration for a collector by the name of the collector |
| 229 | + async fn dequeue_benchmark_job( |
| 230 | + &self, |
| 231 | + collector_name: &str, |
| 232 | + target: &Target, |
| 233 | + benchmark_set: &BenchmarkSet, |
| 234 | + ) -> anyhow::Result<Option<BenchmarkJob>>; |
223 | 235 | } |
224 | 236 |
|
225 | 237 | #[async_trait::async_trait] |
@@ -625,4 +637,39 @@ mod tests { |
625 | 637 | }) |
626 | 638 | .await; |
627 | 639 | } |
| 640 | + |
| 641 | + #[tokio::test] |
| 642 | + async fn get_collector_config_error_if_not_exist() { |
| 643 | + run_postgres_test(|ctx| async { |
| 644 | + let db = ctx.db_client().connection().await; |
| 645 | + |
| 646 | + let collector_config_result = db.get_collector_config("collector-1").await; |
| 647 | + |
| 648 | + assert!(collector_config_result.is_err()); |
| 649 | + |
| 650 | + Ok(ctx) |
| 651 | + }) |
| 652 | + .await; |
| 653 | + } |
| 654 | + |
| 655 | + #[tokio::test] |
| 656 | + async fn dequeue_benchmark_job_empty_queue() { |
| 657 | + run_postgres_test(|ctx| async { |
| 658 | + let db = ctx.db_client().connection().await; |
| 659 | + |
| 660 | + let benchmark_job_result = db |
| 661 | + .dequeue_benchmark_job( |
| 662 | + "collector-1", |
| 663 | + &Target::X86_64UnknownLinuxGnu, |
| 664 | + &BenchmarkSet(420), |
| 665 | + ) |
| 666 | + .await; |
| 667 | + |
| 668 | + assert!(benchmark_job_result.is_ok()); |
| 669 | + assert!(benchmark_job_result.unwrap().is_none()); |
| 670 | + |
| 671 | + Ok(ctx) |
| 672 | + }) |
| 673 | + .await; |
| 674 | + } |
628 | 675 | } |
0 commit comments