Skip to content

Commit a966b27

Browse files
test(k8s): Add retry to fix flaky (#1069)
1 parent 69938df commit a966b27

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

agent-control/tests/k8s/garbage_collector.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use crate::common::runtime::{block_on, tokio_runtime};
1+
use crate::common::{
2+
retry::retry,
3+
runtime::{block_on, tokio_runtime},
4+
};
25

36
use super::tools::{
47
k8s_env::K8sEnv,
@@ -189,8 +192,15 @@ agents:
189192

190193
// Expect that the current_agent and secret to be removed on the second call.
191194
gc.collect().unwrap();
192-
block_on(api_foo.get(resource_name)).expect_err("CR should be removed");
193-
block_on(api_secret.get(secret_name)).expect_err("Secret should be removed");
195+
retry(60, Duration::from_secs(1), || {
196+
if block_on(api_foo.get(resource_name)).is_ok() {
197+
return Err("CR should be removed".into());
198+
};
199+
if block_on(api_secret.get(secret_name)).is_ok() {
200+
return Err("Secret should be removed".into());
201+
};
202+
Ok(())
203+
});
194204
assert_ne!(
195205
agent_instance_id,
196206
instance_id_getter.get(agent_id).unwrap(),

0 commit comments

Comments
 (0)