Skip to content

Commit

Permalink
[TST] Scheduler test fix (#1851)
Browse files Browse the repository at this point in the history
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
- Fixes an issue with the scheduler test where tiebreaks on 0 last
compaction time are random. This uses contains instead of order. When
@Ishiihara adds a the api for last compaction time to the sysdb this
will be fixed and reverted!
 - New functionality
	 - None

## Test plan
*How are these changes tested?*

- [x] Tests pass locally with `pytest` for python, `yarn test` for js,
`cargo test` for rust

## Documentation Changes
None
  • Loading branch information
HammadB authored Mar 9, 2024
1 parent cf46f77 commit 186165d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions rust/worker/src/compactor/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ mod tests {
use crate::types::SegmentScope;
use num_bigint::BigInt;
use std::collections::HashMap;
use std::str::FromStr;
use std::time::Duration;
use uuid::Uuid;

Expand Down Expand Up @@ -271,7 +272,7 @@ mod tests {
async fn test_scheduler() {
let mut log = Box::new(InMemoryLog::new());

let collection_uuid_1 = Uuid::new_v4();
let collection_uuid_1 = Uuid::from_str("00000000-0000-0000-0000-000000000001").unwrap();
let collection_id_1 = collection_uuid_1.to_string();
log.add_log(
collection_id_1.clone(),
Expand All @@ -291,7 +292,7 @@ mod tests {
}),
);

let collection_uuid_2 = Uuid::new_v4();
let collection_uuid_2 = Uuid::from_str("00000000-0000-0000-0000-000000000002").unwrap();
let collection_id_2 = collection_uuid_2.to_string();
log.add_log(
collection_id_2.clone(),
Expand Down Expand Up @@ -341,7 +342,12 @@ mod tests {
scheduler.schedule().await;
let tasks = scheduler.get_tasks();
assert_eq!(tasks.len(), 2);
assert_eq!(tasks[0].collection_id, collection_id_1);
assert_eq!(tasks[1].collection_id, collection_id_2);
// TODO: 3/9 Tasks may be out of order since we have not yet implemented SysDB Get last compaction time. Use contains instead of equal.
let task_ids = tasks
.iter()
.map(|t| t.collection_id.clone())
.collect::<Vec<String>>();
assert!(task_ids.contains(&collection_id_1));
assert!(task_ids.contains(&collection_id_2));
}
}
2 changes: 1 addition & 1 deletion rust/worker/src/log/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) struct CollectionInfo {
pub(crate) first_log_id_ts: i64,
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub(crate) struct CollectionRecord {
pub(crate) id: String,
pub(crate) tenant_id: String,
Expand Down

0 comments on commit 186165d

Please sign in to comment.