* [pbs-devel] [PATCH proxmox-backup v3 2/2] pbs2to3: add test cases for kernel version compatibility
2024-08-29 14:41 [pbs-devel] [PATCH proxmox-backup v3 1/2] pbs2to3: fix #5600: expect any kernel 6.x version above 6.2.16 Daniel Kral
@ 2024-08-29 14:41 ` Daniel Kral
2024-09-10 14:16 ` [pbs-devel] [PATCH proxmox-backup v3 1/2] pbs2to3: fix #5600: expect any kernel 6.x version above 6.2.16 Fiona Ebner
1 sibling, 0 replies; 4+ messages in thread
From: Daniel Kral @ 2024-08-29 14:41 UTC (permalink / raw)
To: pbs-devel
Implements test cases for the kernel version compatibility check in
`pbs2to3` for a set of expected and unexpected kernel versions.
Suggested-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
The kernel versions in the test cases were mostly hand-picked from the
current Proxmox Backup Server repositories, excluding the kernel
versions 5.19.* and 6.1.* because they were both not expected before
this patch. Also, they are tested for both cases, when PBS was already
upgraded to v3.x and when PBS is still on v2.x.
differences to v2:
- removed unnecessary .iter() call in test loop
- retyped kernel versions from Vec<_> to &[&str]
src/bin/pbs2to3.rs | 61 ++++++++++++++++++++++++++++++++++++++++------
1 file changed, 54 insertions(+), 7 deletions(-)
diff --git a/src/bin/pbs2to3.rs b/src/bin/pbs2to3.rs
index 194a077e..325dca7d 100644
--- a/src/bin/pbs2to3.rs
+++ b/src/bin/pbs2to3.rs
@@ -123,18 +123,26 @@ impl Checker {
Ok(())
}
+ fn is_kernel_version_compatible(&self, running_version: &str) -> bool {
+ let re = if self.upgraded {
+ r"^6\.(?:2\.(?:[2-9]\d+|1[6-8]|1\d\d+)|([5-9]|\d{2,}))[^~]*$"
+ } else {
+ r"^(?:5\.(?:13|15)|6\.2)"
+ };
+ let re = Regex::new(re).expect("failed to compile kernel compat regex");
+
+ re.is_match(running_version)
+ }
+
fn check_kernel_compat(
&mut self,
pkg_versions: &[pbs_api_types::APTUpdateInfo],
) -> Result<(), Error> {
self.output.log_info("Check running kernel version..")?;
- let (krunning, kinstalled) = if self.upgraded {
- (
- Regex::new(r"^6\.(?:2\.(?:[2-9]\d+|1[6-8]|1\d\d+)|([5-9]|\d{2,}))[^~]*$")?,
- "proxmox-kernel-6.2",
- )
+ let kinstalled = if self.upgraded {
+ "proxmox-kernel-6.2"
} else {
- (Regex::new(r"^(?:5\.(?:13|15)|6\.2)")?, "pve-kernel-5.15")
+ "pve-kernel-5.15"
};
let output = std::process::Command::new("uname").arg("-r").output();
@@ -144,7 +152,7 @@ impl Checker {
.log_fail("unable to determine running kernel version.")?,
Ok(ret) => {
let running_version = std::str::from_utf8(&ret.stdout[..ret.stdout.len() - 1])?;
- if krunning.is_match(running_version) {
+ if self.is_kernel_version_compatible(running_version) {
if self.upgraded {
self.output.log_pass(format!(
"running new kernel '{running_version}' after upgrade."
@@ -620,3 +628,42 @@ impl ConsoleOutput {
Ok(())
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn test_is_kernel_version_compatible(
+ expected_versions: &[&str],
+ unexpected_versions: &[&str],
+ upgraded: bool,
+ ) {
+ let checker = Checker {
+ output: ConsoleOutput::new(),
+ upgraded,
+ };
+
+ for version in expected_versions {
+ assert!(checker.is_kernel_version_compatible(version));
+ }
+ for version in unexpected_versions {
+ assert!(!checker.is_kernel_version_compatible(version));
+ }
+ }
+
+ #[test]
+ fn test_is_pve_kernel_version_compatible() {
+ let expected_versions = &["5.13.19-6-pve", "5.15.158-2-pve", "6.2.16-5-pve"];
+ let unexpected_versions = &["6.1.10-1-pve", "5.19.17-2-pve"];
+
+ test_is_kernel_version_compatible(expected_versions, unexpected_versions, false);
+ }
+
+ #[test]
+ fn test_is_proxmox_kernel_version_compatible() {
+ let expected_versions = &["6.2.16-20-pve", "6.5.13-6-pve", "6.8.12-1-pve"];
+ let unexpected_versions = &["5.13.19-6-pve", "6.1.15-1-pve"];
+
+ test_is_kernel_version_compatible(expected_versions, unexpected_versions, true);
+ }
+}
--
2.39.2
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pbs-devel] [PATCH proxmox-backup v3 1/2] pbs2to3: fix #5600: expect any kernel 6.x version above 6.2.16
2024-08-29 14:41 [pbs-devel] [PATCH proxmox-backup v3 1/2] pbs2to3: fix #5600: expect any kernel 6.x version above 6.2.16 Daniel Kral
2024-08-29 14:41 ` [pbs-devel] [PATCH proxmox-backup v3 2/2] pbs2to3: add test cases for kernel version compatibility Daniel Kral
@ 2024-09-10 14:16 ` Fiona Ebner
2024-09-18 13:08 ` Daniel Kral
1 sibling, 1 reply; 4+ messages in thread
From: Fiona Ebner @ 2024-09-10 14:16 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Daniel Kral
Am 29.08.24 um 16:41 schrieb Daniel Kral:
> Fixes a minor bug where `pbs2to3` shows an incorrect warning about an
> incompatible kernel version, where newer kernel versions than 6.5.* were
> marked as unexpected.
>
> Signed-off-by: Daniel Kral <d.kral@proxmox.com>
> ---
> no diff to v1/v2.
>
> src/bin/pbs2to3.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/bin/pbs2to3.rs b/src/bin/pbs2to3.rs
> index 1f895abd..194a077e 100644
> --- a/src/bin/pbs2to3.rs
> +++ b/src/bin/pbs2to3.rs
> @@ -130,7 +130,7 @@ impl Checker {
> self.output.log_info("Check running kernel version..")?;
> let (krunning, kinstalled) = if self.upgraded {
> (
> - Regex::new(r"^6\.(?:2\.(?:[2-9]\d+|1[6-8]|1\d\d+)|5)[^~]*$")?,
> + Regex::new(r"^6\.(?:2\.(?:[2-9]\d+|1[6-8]|1\d\d+)|([5-9]|\d{2,}))[^~]*$")?,
> "proxmox-kernel-6.2",
> )
> } else {
Sorry, forgot to check for newer versions of the patch series, so
answering again as it's still relevant:
In PVE and PMG we allow arbitrary newer -pve kernels for
future-proofing, it would be nice to do the same here too:
https://git.proxmox.com/?p=pve-manager.git;a=commit;h=fb59038a8b110b0b0b438ec035fd41dd9d591232
https://git.proxmox.com/?p=pmg-api.git;a=commit;h=9d67a9af218b73027822c9c4665b88e6662e7ef7
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread