diff --git a/examples/lading-logrotatefs.yaml b/examples/lading-logrotatefs.yaml new file mode 100644 index 000000000..9a72144d6 --- /dev/null +++ b/examples/lading-logrotatefs.yaml @@ -0,0 +1,17 @@ +generator: + - file_gen: + logrotate_fs: + seed: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, + 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131] + concurrent_logs: 8 + maximum_bytes_per_log: 100MB + total_rotations: 4 + max_depth: 0 + variant: "ascii" + bytes_per_second: 10MB + maximum_prebuild_cache_size_bytes: 1GB + mount_point: /tmp/logrotate + +blackhole: + - tcp: + binding_addr: "0.0.0.0:8080" diff --git a/lading/src/generator/file_gen/logrotate_fs.rs b/lading/src/generator/file_gen/logrotate_fs.rs index be3aef9a9..75fb5d203 100644 --- a/lading/src/generator/file_gen/logrotate_fs.rs +++ b/lading/src/generator/file_gen/logrotate_fs.rs @@ -22,7 +22,7 @@ use std::{ time::Duration, }; use tokio::task::{self, JoinError}; -use tracing::{error, info}; +use tracing::{debug, error, info}; mod model; @@ -123,6 +123,10 @@ impl Server { config.concurrent_logs, ); + info!( + "Creating logrotate filesystem with mount point {mount}", + mount = config.mount_point.display(), + ); // Initialize the FUSE filesystem let fs = LogrotateFS { state: Arc::new(Mutex::new(state)), @@ -243,7 +247,7 @@ impl Filesystem for LogrotateFS { let name_str = name.to_str().unwrap_or(""); if let Some(ino) = state.lookup(tick, parent as usize, name_str) { if let Some(attr) = getattr_helper(&mut state, self.start_time_system, tick, ino) { - info!("lookup: returning attr for inode {}: {:?}", ino, attr); + debug!("lookup: returning attr for inode {}: {:?}", ino, attr); reply.entry(&TTL, &attr, 0); return; } diff --git a/lading/src/generator/file_gen/logrotate_fs/model.rs b/lading/src/generator/file_gen/logrotate_fs/model.rs index 672124c31..3b03ddcef 100644 --- a/lading/src/generator/file_gen/logrotate_fs/model.rs +++ b/lading/src/generator/file_gen/logrotate_fs/model.rs @@ -379,9 +379,14 @@ impl State { return state; } - // Generate random group names - let num_groups = rng.gen_range(1..=concurrent_logs); - for group_id in 0..num_groups { + // Strategy: + // + // For 0 to `concurrent_logs` generate a directory path up to + // `max_depth` from the root node and place a file in that + // directory. Node that we must keep track of the group we're in, so we + // loop over `concurrent_logs`. + for group_id in 0..concurrent_logs { + // First, generate the group name. let base: String = (0..8) .map(|_| rng.sample(rand::distributions::Alphanumeric) as char) .collect(); @@ -392,17 +397,14 @@ impl State { names.push(format!("{base_name}.{i}")); // Ordinal i } state.group_names.push(names); - } - // Strategy: - // - // For 0 to num_groups generate a directory path up to `max_depth` from - // the root node and place a file in that directory. Node that we must - // keep track of the group we're in, so we loop over num_groups. - - for group_id in 0..num_groups { + // Now, build up the directory tree and put the file in it. let mut current_inode = state.root_inode; - let depth = rng.gen_range(1..=max_depth as usize); + let depth = if max_depth == 0 { + 0 + } else { + rng.gen_range(1..=max_depth as usize) + }; // Build the directory path for _ in 0..depth {