Skip to content

Commit 6867c87

Browse files
authored
test(bigquery): handle 404 err when cleaning stale datasets (#3594)
When multiple CI steps run in parallel, there is a change of then trying to delete the same dataset (BigQuery metadata service has an eventual consistency model). This PR checks if the error when trying to fetch a Dataset is a 404 and skip it. Fixes #3572
1 parent 302dba5 commit 6867c87

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/integration-tests/src/bigquery.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use crate::Result;
1616
use futures::stream::StreamExt;
17-
use gax::paginator::ItemPaginator;
17+
use gax::{error::rpc::Code, paginator::ItemPaginator};
1818
use rand::{Rng, distr::Alphanumeric};
1919

2020
const INSTANCE_LABEL: &str = "rust-sdk-integration-test";
@@ -113,8 +113,12 @@ async fn cleanup_stale_datasets(
113113
let stale_datasets = futures::future::join_all(pending_all_datasets)
114114
.await
115115
.into_iter()
116-
.filter_map(|r| {
117-
let dataset = r.unwrap();
116+
.filter_map(|r| match r {
117+
Ok(dataset) => Some(dataset),
118+
Err(e) if e.status().is_some_and(|s| s.code == Code::NotFound) => None,
119+
Err(_) => panic!("expected a successful get_dataset()"),
120+
})
121+
.filter_map(|dataset| {
118122
if dataset
119123
.labels
120124
.get(INSTANCE_LABEL)

0 commit comments

Comments
 (0)