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

Make sure state starts at close to now tick #1078

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions lading/src/generator/file_gen/logrotate_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ impl Server {
&config.variant,
)?;

let start_time = std::time::Instant::now();
let start_time_system = std::time::SystemTime::now();
let state = model::State::new(
&mut rng,
start_time.elapsed().as_secs(),
config.bytes_per_second.get_bytes() as u64,
config.total_rotations,
config.maximum_bytes_per_log.get_bytes() as u64,
Expand All @@ -131,8 +134,8 @@ impl Server {
let fs = LogrotateFS {
state: Arc::new(Mutex::new(state)),
open_files: Arc::new(Mutex::new(HashMap::new())),
start_time: std::time::Instant::now(),
start_time_system: std::time::SystemTime::now(),
start_time,
start_time_system,
};

let options = vec![
Expand Down
7 changes: 6 additions & 1 deletion lading/src/generator/file_gen/logrotate_fs/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,10 @@ pub(crate) enum NodeType {
impl State {
/// Create a new instance of `State`.
#[tracing::instrument(skip(rng, block_cache))]
#[allow(clippy::too_many_arguments)]
pub(crate) fn new<R>(
rng: &mut R,
initial_tick: Tick,
bytes_per_tick: u64,
max_rotations: u8,
max_bytes_per_file: u64,
Expand All @@ -374,7 +376,7 @@ impl State {
let mut state = State {
nodes,
root_inode,
now: 0,
now: initial_tick,
block_cache,
max_bytes_per_file,
max_rotations,
Expand Down Expand Up @@ -955,6 +957,7 @@ mod test {
1024u64..=500_000u64, // max_bytes_per_file
1u8..=4u8, // max_depth
1u16..=16u16, // concurrent_logs
1u64..=1000u64, // initial_tick
)
.prop_map(
|(
Expand All @@ -964,6 +967,7 @@ mod test {
max_bytes_per_file,
max_depth,
concurrent_logs,
initial_tick,
)| {
let mut rng = StdRng::seed_from_u64(seed);
let block_cache = block::Cache::fixed(
Expand All @@ -976,6 +980,7 @@ mod test {

State::new(
&mut rng,
initial_tick,
bytes_per_tick,
max_rotations,
max_bytes_per_file,
Expand Down
Loading