manager: hidden command to move datastore prune opts into jobs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
@ -12,7 +12,7 @@ fn get_prune_list(
|
||||
return_kept: bool,
|
||||
options: &PruneJobOptions,
|
||||
) -> Vec<PathBuf> {
|
||||
let mut prune_info = compute_prune_info(list, options).unwrap();
|
||||
let mut prune_info = compute_prune_info(list, &options.keep).unwrap();
|
||||
|
||||
prune_info.reverse();
|
||||
|
||||
@ -68,13 +68,13 @@ fn test_prune_protected() -> Result<(), Error> {
|
||||
eprintln!("{:?}", orig_list);
|
||||
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_last = Some(1);
|
||||
options.keep.keep_last = Some(1);
|
||||
let remove_list = get_prune_list(orig_list.clone(), false, &options);
|
||||
let expect: Vec<PathBuf> = vec![PathBuf::from("host/elsa/2019-11-15T10:39:15Z")];
|
||||
assert_eq!(remove_list, expect);
|
||||
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_hourly = Some(1);
|
||||
options.keep.keep_hourly = Some(1);
|
||||
let remove_list = get_prune_list(orig_list.clone(), false, &options);
|
||||
let expect: Vec<PathBuf> = vec![PathBuf::from("host/elsa/2019-11-15T10:39:15Z")];
|
||||
assert_eq!(remove_list, expect);
|
||||
@ -94,7 +94,7 @@ fn test_prune_hourly() -> Result<(), Error> {
|
||||
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_hourly = Some(3);
|
||||
options.keep.keep_hourly = Some(3);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
PathBuf::from("host/elsa/2019-11-15T10:49:15Z"),
|
||||
@ -105,7 +105,7 @@ fn test_prune_hourly() -> Result<(), Error> {
|
||||
|
||||
let list = orig_list;
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_hourly = Some(2);
|
||||
options.keep.keep_hourly = Some(2);
|
||||
let remove_list = get_prune_list(list, true, &options);
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
PathBuf::from("host/elsa/2019-11-15T10:59:15Z"),
|
||||
@ -132,15 +132,15 @@ fn test_prune_simple2() -> Result<(), Error> {
|
||||
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_daily = Some(1);
|
||||
options.keep.keep_daily = Some(1);
|
||||
let remove_list = get_prune_list(list, true, &options);
|
||||
let expect: Vec<PathBuf> = vec![PathBuf::from("host/elsa/2019-12-04T11:59:15Z")];
|
||||
assert_eq!(remove_list, expect);
|
||||
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_last = Some(1);
|
||||
options.keep_daily = Some(1);
|
||||
options.keep.keep_last = Some(1);
|
||||
options.keep.keep_daily = Some(1);
|
||||
let remove_list = get_prune_list(list, true, &options);
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
PathBuf::from("host/elsa/2019-12-03T11:59:15Z"),
|
||||
@ -150,8 +150,8 @@ fn test_prune_simple2() -> Result<(), Error> {
|
||||
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_daily = Some(1);
|
||||
options.keep_weekly = Some(1);
|
||||
options.keep.keep_daily = Some(1);
|
||||
options.keep.keep_weekly = Some(1);
|
||||
let remove_list = get_prune_list(list, true, &options);
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
PathBuf::from("host/elsa/2019-12-01T11:59:15Z"),
|
||||
@ -161,9 +161,9 @@ fn test_prune_simple2() -> Result<(), Error> {
|
||||
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_daily = Some(1);
|
||||
options.keep_weekly = Some(1);
|
||||
options.keep_monthly = Some(1);
|
||||
options.keep.keep_daily = Some(1);
|
||||
options.keep.keep_weekly = Some(1);
|
||||
options.keep.keep_monthly = Some(1);
|
||||
let remove_list = get_prune_list(list, true, &options);
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
PathBuf::from("host/elsa/2019-11-22T11:59:15Z"),
|
||||
@ -174,8 +174,8 @@ fn test_prune_simple2() -> Result<(), Error> {
|
||||
|
||||
let list = orig_list;
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_monthly = Some(1);
|
||||
options.keep_yearly = Some(1);
|
||||
options.keep.keep_monthly = Some(1);
|
||||
options.keep.keep_yearly = Some(1);
|
||||
let remove_list = get_prune_list(list, true, &options);
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
PathBuf::from("host/elsa/2018-11-15T11:59:15Z"),
|
||||
@ -199,21 +199,21 @@ fn test_prune_simple() -> Result<(), Error> {
|
||||
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_last = Some(4);
|
||||
options.keep.keep_last = Some(4);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
let expect: Vec<PathBuf> = Vec::new();
|
||||
assert_eq!(remove_list, expect);
|
||||
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_last = Some(3);
|
||||
options.keep.keep_last = Some(3);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
let expect: Vec<PathBuf> = vec![PathBuf::from("host/elsa/2019-12-02T11:59:15Z")];
|
||||
assert_eq!(remove_list, expect);
|
||||
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_last = Some(2);
|
||||
options.keep.keep_last = Some(2);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
PathBuf::from("host/elsa/2019-12-02T11:59:15Z"),
|
||||
@ -223,7 +223,7 @@ fn test_prune_simple() -> Result<(), Error> {
|
||||
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_last = Some(1);
|
||||
options.keep.keep_last = Some(1);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
PathBuf::from("host/elsa/2019-12-02T11:59:15Z"),
|
||||
@ -234,7 +234,7 @@ fn test_prune_simple() -> Result<(), Error> {
|
||||
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_last = Some(0);
|
||||
options.keep.keep_last = Some(0);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
PathBuf::from("host/elsa/2019-12-02T11:59:15Z"),
|
||||
@ -247,8 +247,8 @@ fn test_prune_simple() -> Result<(), Error> {
|
||||
// keep-last, keep-daily mixed
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_last = Some(2);
|
||||
options.keep_daily = Some(2);
|
||||
options.keep.keep_last = Some(2);
|
||||
options.keep.keep_daily = Some(2);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
let expect: Vec<PathBuf> = vec![];
|
||||
assert_eq!(remove_list, expect);
|
||||
@ -256,7 +256,7 @@ fn test_prune_simple() -> Result<(), Error> {
|
||||
// keep-daily test
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_daily = Some(3);
|
||||
options.keep.keep_daily = Some(3);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
let expect: Vec<PathBuf> = vec![PathBuf::from("host/elsa/2019-12-04T11:59:15Z")];
|
||||
assert_eq!(remove_list, expect);
|
||||
@ -264,7 +264,7 @@ fn test_prune_simple() -> Result<(), Error> {
|
||||
// keep-daily test
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_daily = Some(2);
|
||||
options.keep.keep_daily = Some(2);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
PathBuf::from("host/elsa/2019-12-02T11:59:15Z"),
|
||||
@ -275,7 +275,7 @@ fn test_prune_simple() -> Result<(), Error> {
|
||||
// keep-weekly
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_weekly = Some(5);
|
||||
options.keep.keep_weekly = Some(5);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
// all backup are within the same week, so we only keep a single file
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
@ -288,8 +288,8 @@ fn test_prune_simple() -> Result<(), Error> {
|
||||
// keep-daily + keep-weekly
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_daily = Some(1);
|
||||
options.keep_weekly = Some(5);
|
||||
options.keep.keep_daily = Some(1);
|
||||
options.keep.keep_weekly = Some(5);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
PathBuf::from("host/elsa/2019-12-02T11:59:15Z"),
|
||||
@ -301,7 +301,7 @@ fn test_prune_simple() -> Result<(), Error> {
|
||||
// keep-monthly
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_monthly = Some(6);
|
||||
options.keep.keep_monthly = Some(6);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
// all backup are within the same month, so we only keep a single file
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
@ -314,7 +314,7 @@ fn test_prune_simple() -> Result<(), Error> {
|
||||
// keep-yearly
|
||||
let list = orig_list.clone();
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_yearly = Some(7);
|
||||
options.keep.keep_yearly = Some(7);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
// all backup are within the same year, so we only keep a single file
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
@ -327,9 +327,9 @@ fn test_prune_simple() -> Result<(), Error> {
|
||||
// keep-weekly + keep-monthly + keep-yearly
|
||||
let list = orig_list;
|
||||
let mut options = PruneJobOptions::default();
|
||||
options.keep_weekly = Some(5);
|
||||
options.keep_monthly = Some(6);
|
||||
options.keep_yearly = Some(7);
|
||||
options.keep.keep_weekly = Some(5);
|
||||
options.keep.keep_monthly = Some(6);
|
||||
options.keep.keep_yearly = Some(7);
|
||||
let remove_list = get_prune_list(list, false, &options);
|
||||
// all backup are within one week, so we only keep a single file
|
||||
let expect: Vec<PathBuf> = vec![
|
||||
|
Reference in New Issue
Block a user