|
1 | 1 | use crate::selector::CompileTestCase; |
2 | 2 | use crate::{ |
3 | | - ArtifactCollection, ArtifactId, ArtifactIdNumber, BenchmarkRequest, BenchmarkRequestIndex, |
4 | | - BenchmarkRequestStatus, CodegenBackend, CompileBenchmark, Target, |
| 3 | + ArtifactCollection, ArtifactId, ArtifactIdNumber, BenchmarkJob, BenchmarkRequest, |
| 4 | + BenchmarkRequestIndex, BenchmarkRequestStatus, BenchmarkSet, CodegenBackend, CollectorConfig, |
| 5 | + CompileBenchmark, Target, |
5 | 6 | }; |
6 | 7 | use crate::{CollectionId, Index, Profile, QueuedCommit, Scenario, Step}; |
7 | 8 | use chrono::{DateTime, Utc}; |
@@ -232,6 +233,17 @@ pub trait Connection: Send + Sync { |
232 | 233 | &self, |
233 | 234 | artifact_row_id: &ArtifactIdNumber, |
234 | 235 | ) -> anyhow::Result<HashSet<CompileTestCase>>; |
| 236 | + |
| 237 | + /// Get the confiuguration for a collector by the name of the collector |
| 238 | + async fn get_collector_config(&self, collector_name: &str) -> anyhow::Result<CollectorConfig>; |
| 239 | + |
| 240 | + /// Get the confiuguration for a collector by the name of the collector |
| 241 | + async fn dequeue_benchmark_job( |
| 242 | + &self, |
| 243 | + collector_name: &str, |
| 244 | + target: &Target, |
| 245 | + benchmark_set: &BenchmarkSet, |
| 246 | + ) -> anyhow::Result<Option<BenchmarkJob>>; |
235 | 247 | } |
236 | 248 |
|
237 | 249 | #[async_trait::async_trait] |
@@ -690,6 +702,39 @@ mod tests { |
690 | 702 | .await |
691 | 703 | .unwrap() |
692 | 704 | .is_empty()); |
| 705 | + Ok(ctx) |
| 706 | + }) |
| 707 | + .await; |
| 708 | + } |
| 709 | + |
| 710 | + async fn get_collector_config_error_if_not_exist() { |
| 711 | + run_postgres_test(|ctx| async { |
| 712 | + let db = ctx.db_client().connection().await; |
| 713 | + |
| 714 | + let collector_config_result = db.get_collector_config("collector-1").await; |
| 715 | + |
| 716 | + assert!(collector_config_result.is_err()); |
| 717 | + |
| 718 | + Ok(ctx) |
| 719 | + }) |
| 720 | + .await; |
| 721 | + } |
| 722 | + |
| 723 | + #[tokio::test] |
| 724 | + async fn dequeue_benchmark_job_empty_queue() { |
| 725 | + run_postgres_test(|ctx| async { |
| 726 | + let db = ctx.db_client().connection().await; |
| 727 | + |
| 728 | + let benchmark_job_result = db |
| 729 | + .dequeue_benchmark_job( |
| 730 | + "collector-1", |
| 731 | + &Target::X86_64UnknownLinuxGnu, |
| 732 | + &BenchmarkSet(420), |
| 733 | + ) |
| 734 | + .await; |
| 735 | + |
| 736 | + assert!(benchmark_job_result.is_ok()); |
| 737 | + assert!(benchmark_job_result.unwrap().is_none()); |
693 | 738 |
|
694 | 739 | Ok(ctx) |
695 | 740 | }) |
|
0 commit comments