From: Philipp Hufnagl <p.hufnagl@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v5 4/4] tests: check if include/exclude behavior works correctly
Date: Mon, 18 Dec 2023 16:36:38 +0100 [thread overview]
Message-ID: <20231218153638.609440-5-p.hufnagl@proxmox.com> (raw)
In-Reply-To: <20231218153638.609440-1-p.hufnagl@proxmox.com>
This checks if including and excluding works as expected. That the
filter are added out of order is on purpose since it sould make no
difference.
Signed-off-by: Philipp Hufnagl <p.hufnagl@proxmox.com>
---
tests/sync_jobs.rs | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 tests/sync_jobs.rs
diff --git a/tests/sync_jobs.rs b/tests/sync_jobs.rs
new file mode 100644
index 00000000..83877160
--- /dev/null
+++ b/tests/sync_jobs.rs
@@ -0,0 +1,34 @@
+use pbs_api_types::{
+ apply_filters, split_by_include_exclude, BackupGroup, BackupType, GroupFilter,
+};
+use std::str::FromStr;
+
+#[test]
+fn test_group_filters() {
+ let group_filters = vec![
+ GroupFilter::from_str("exclude:regex:.*10[1-3]").unwrap(),
+ GroupFilter::from_str("regex:.*10[2-8]").unwrap(),
+ GroupFilter::from_str("exclude:regex:.*10[5-7]").unwrap(),
+ ];
+ let (include_filters, exclude_filters) = split_by_include_exclude(Some(group_filters));
+
+ let dont_backup = vec![
+ "vm/101", "vm/102", "vm/103", "vm/105", "vm/106", "vm/107", "vm/109",
+ ];
+ for id in dont_backup {
+ assert!(!apply_filters(
+ &BackupGroup::new(BackupType::Vm, id),
+ &include_filters,
+ &exclude_filters
+ ));
+ }
+
+ let do_backup = vec!["vm/104", "vm/108"];
+ for id in do_backup {
+ assert!(apply_filters(
+ &BackupGroup::new(BackupType::Vm, id),
+ &include_filters,
+ &exclude_filters
+ ));
+ }
+}
--
2.39.2
next prev parent reply other threads:[~2023-12-18 15:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-18 15:36 [pbs-devel] [PATCH proxmox-backup v5 0/4] fix #4315: datastore: Exclude entries from sync Philipp Hufnagl
2023-12-18 15:36 ` [pbs-devel] [PATCH proxmox-backup v5 1/4] fix #4315: jobs: modify GroupFilter so include/exclude is tracked Philipp Hufnagl
2023-12-19 13:22 ` Lukas Wagner
2023-12-22 9:42 ` Philipp Hufnagl
2023-12-22 9:53 ` Lukas Wagner
2023-12-18 15:36 ` [pbs-devel] [PATCH proxmox-backup v5 2/4] ui: Show if Filter includes or excludes Philipp Hufnagl
2023-12-18 15:36 ` [pbs-devel] [PATCH proxmox-backup v5 3/4] docs: document new include/exclude paramenter Philipp Hufnagl
2023-12-18 15:36 ` Philipp Hufnagl [this message]
2023-12-19 13:23 ` [pbs-devel] [PATCH proxmox-backup v5 4/4] tests: check if include/exclude behavior works correctly Lukas Wagner
2023-12-22 9:45 ` Philipp Hufnagl
2023-12-19 13:25 ` [pbs-devel] [PATCH proxmox-backup v5 0/4] fix #4315: datastore: Exclude entries from sync Lukas Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231218153638.609440-5-p.hufnagl@proxmox.com \
--to=p.hufnagl@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox