Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting a nonexistent producer should succeed #5366

Merged
merged 3 commits into from
Apr 1, 2024
Merged
Changes from 1 commit
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
28 changes: 26 additions & 2 deletions oximeter/collector/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,10 @@ impl OximeterAgent {
>,
id: Uuid,
) -> Result<(), Error> {
let (_info, task) =
tasks.remove(&id).ok_or_else(|| Error::NoSuchProducer(id))?;
bnaecker marked this conversation as resolved.
Show resolved Hide resolved
let Some((_info, task)) = tasks.remove(&id) else {
// We have no such producer, so good news, we've removed it!
return Ok(());
};
debug!(
self.log,
"removed collection task from set";
Expand Down Expand Up @@ -1121,4 +1123,26 @@ mod tests {
assert_eq!(stats.failed_collections.len(), 1);
logctx.cleanup_successful();
}

#[tokio::test]
async fn test_delete_nonexistent_producer_succeeds() {
let logctx =
test_setup_log("test_delete_nonexistent_producer_succeeds");
let log = &logctx.log;

// Spawn an oximeter collector ...
let collector = OximeterAgent::new_standalone(
Uuid::new_v4(),
SocketAddrV6::new(Ipv6Addr::LOCALHOST, 0, 0, 0),
crate::default_refresh_interval(),
None,
log,
)
.await
.unwrap();
assert!(
collector.delete_producer(Uuid::new_v4()).await.is_ok(),
"Deleting a non-existent producer should be OK"
);
}
}
Loading