Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
fix(stress test): fix log to file and probe message destination
Browse files Browse the repository at this point in the history
  • Loading branch information
madadam committed Jan 11, 2021
1 parent cf25c48 commit c933605
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions examples/stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,23 @@ async fn main() -> Result<()> {
}

// Init logging.
if let Some(path) = opts.log {
let _log_guard = if let Some(path) = opts.log {
let builder = tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env());

if path == "-" {
builder.init()
builder.init();
None
} else {
let file = File::open(path)?;
let file = File::create(path)?;
let file = BufWriter::new(file);
let (writer, _) = tracing_appender::non_blocking(file);
let (writer, guard) = tracing_appender::non_blocking(file);

builder.with_writer(writer).init()
builder.with_writer(writer).init();
Some(guard)
}
}
} else {
None
};

let schedule = ChurnSchedule::parse(&opts.schedule)?;

Expand Down Expand Up @@ -404,7 +408,9 @@ impl Network {
});

for (node, name, prefix) in nodes {
let dst = *cache.entry(prefix).or_insert_with(rand::random);
let dst = *cache
.entry(prefix)
.or_insert_with(|| prefix.substituted_in(rand::random()));
self.try_send_probe(node, *name, dst).await?;
self.probe_tracker.send(*prefix, dst);
}
Expand Down

0 comments on commit c933605

Please sign in to comment.