Skip to content

Commit

Permalink
fix: wait_for_condition returning incorrect value
Browse files Browse the repository at this point in the history
  • Loading branch information
kamiyaa committed Jan 28, 2025
1 parent a6159ea commit 99fd6f7
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions rust/main/utils/run-locally/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,15 @@ fn main() -> ExitCode {

if !post_startup_invariants(&checkpoints_dirs) {
log!("Failure: Post startup invariants are not met");
return report_test_result(true);
return report_test_result(false);
} else {
log!("Success: Post startup invariants are met");
}

let starting_relayer_balance: f64 = agent_balance_sum(9092).unwrap();

// wait for CI invariants to pass
let mut failure_occurred = wait_for_condition(&config, loop_start, || {
let mut test_passed = wait_for_condition(&config, loop_start, || {
termination_invariants_met(
&config,
starting_relayer_balance,
Expand All @@ -449,8 +449,9 @@ fn main() -> ExitCode {
)
});

if failure_occurred {
return report_test_result(failure_occurred);
if !test_passed {
log!("Failure occurred during E2E");
return report_test_result(test_passed);
}

// Here we want to restart the relayer and validate
Expand All @@ -462,7 +463,7 @@ fn main() -> ExitCode {

let loop_start = Instant::now();
// wait for Relayer restart invariants to pass
failure_occurred = wait_for_condition(&config, loop_start, relayer_restart_invariants_met);
test_passed = wait_for_condition(&config, loop_start, relayer_restart_invariants_met);

// verify long-running tasks are still running
for (name, (child, _)) in state.agents.iter_mut() {
Expand All @@ -473,7 +474,7 @@ fn main() -> ExitCode {
name,
status.code().unwrap()
);
failure_occurred = true;
test_passed = false;
break;
}
}
Expand All @@ -482,7 +483,7 @@ fn main() -> ExitCode {
let resp = server::run_retry_request().expect("Failed to process retry request");
assert!(resp.matched > 0);

report_test_result(failure_occurred)
report_test_result(test_passed)
}

fn create_common_agent() -> Program {
Expand Down Expand Up @@ -636,12 +637,12 @@ fn check_ci_timed_out(config: &Config, start_time: Instant) -> bool {
(Instant::now() - start_time).as_secs() > config.ci_mode_timeout
}

fn report_test_result(failure_occurred: bool) -> ExitCode {
if failure_occurred {
log!("E2E tests failed");
ExitCode::FAILURE
} else {
fn report_test_result(passed: bool) -> ExitCode {
if passed {
log!("E2E tests passed");
ExitCode::SUCCESS
} else {
log!("E2E tests failed");
ExitCode::FAILURE
}
}

0 comments on commit 99fd6f7

Please sign in to comment.