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

[cluster-test] Log rotate libra.log #1585

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions testsuite/cluster-test/Cargo.toml
Expand Up @@ -27,6 +27,7 @@ serde_json = "1.0"
termion = "1.5.3"
serde = { version = "1.0.89", features = ["derive"] }
structopt = "0.3.2"
chrono = { version = "0.4.7" }

slog = { version = "2.5.0", features = ["max_level_debug", "release_max_level_debug"] }
slog-term = "2.4.1"
Expand Down
32 changes: 27 additions & 5 deletions testsuite/cluster-test/src/main.rs
@@ -1,3 +1,4 @@
use chrono::{Datelike, Timelike, Utc};
use cluster_test::effects::RemoveNetworkEffects;
use cluster_test::experiments::{MultiRegionSimulation, PacketLossRandomValidators};
use cluster_test::github::GitHub;
Expand Down Expand Up @@ -853,18 +854,39 @@ impl ClusterTestRunner {
thread::sleep(Duration::from_secs(10));
info!("Starting...");
}
let now = Utc::now();
let suffix = format!(
".{:04}{:02}{:02}-{:02}{:02}{:02}.gz",
now.year(),
now.month(),
now.day(),
now.hour(),
now.minute(),
now.second()
);
let suffix = &suffix;
info!("Will use suffix {} for log rotation", suffix);
let jobs = self
.cluster
.instances()
.iter()
.map(|instance| {
let instance = instance.clone();
move || {
if let Err(e) =
instance.run_cmd_tee_err(vec!["sudo", "rm", "-rf", "/data/libra/"])
{
info!("Failed to wipe {}: {:?}", instance, e);
}
instance
.run_cmd_tee_err(vec!["sudo", "rm", "-rf", "/data/libra/*db"])
.map_err(|e| info!("Failed to wipe {}: {:?}", instance, e))
.ok();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Correct me if I'm wrong, .ok() here and below is a no-op right? If so, can we remove it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok() here is to suppress linter warning - otherwise it complains about unused Result

instance
.run_cmd_tee_err(vec![
"sudo",
"gzip",
"-S",
suffix,
"/data/libra/libra.log",
])
.map_err(|e| info!("Failed to gzip log file {}: {:?}", instance, e))
.ok();
}
})
.collect();
Expand Down