Skip to content

Commit

Permalink
Parameterize actions sleep interval for faster test execution.
Browse files Browse the repository at this point in the history
  • Loading branch information
bittrance committed Oct 2, 2023
1 parent 93a1533 commit b8348b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
process::{Command, Stdio},
sync::{Arc, Mutex},
thread::{sleep, spawn, JoinHandle},
time::{Duration, Instant},
time::Instant,
};

use serde::Deserialize;
Expand All @@ -14,6 +14,7 @@ use crate::{
errors::GitOpsError,
opts::CliOptions,
receiver::{SourceType, WorkloadEvent},
utils::POLL_INTERVAL,
};

#[derive(Debug, PartialEq)]
Expand Down Expand Up @@ -140,7 +141,7 @@ where
sink.lock().unwrap()(WorkloadEvent::Timeout(name.to_string()))?;
break Ok(ActionResult::Failure);
}
sleep(Duration::from_secs(1));
sleep(POLL_INTERVAL);
}
}

Expand All @@ -149,6 +150,7 @@ mod tests {
use std::{
process::ExitStatus,
sync::{Arc, Mutex},
time::Duration,
};

use super::*;
Expand Down
4 changes: 2 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::thread::sleep;
use std::time::{Duration, Instant};

#[cfg(test)]
const POLL_INTERVAL: Duration = Duration::from_millis(10);
pub const POLL_INTERVAL: Duration = Duration::from_millis(10);
#[cfg(not(test))]
const POLL_INTERVAL: Duration = Duration::from_millis(500);
pub const POLL_INTERVAL: Duration = Duration::from_millis(500);

pub struct Watchdog {
deadline: Instant,
Expand Down

0 comments on commit b8348b5

Please sign in to comment.