From 136d799b8e2c8fdbbd3d3611774e3deab6838eed Mon Sep 17 00:00:00 2001 From: Python Maint Date: Tue, 3 Jun 2025 15:34:01 +0200 Subject: [PATCH 01/13] Rebuilt for Python 3.14 From c1e58d4cd0c350a1aa76482736d744ac75e8a940 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 25 Jul 2025 18:28:30 +0000 Subject: [PATCH 02/13] Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild From 8f6446b329a1d4a124c77808f73fa2b87021aaae Mon Sep 17 00:00:00 2001 From: Python Maint Date: Fri, 15 Aug 2025 15:18:14 +0200 Subject: [PATCH 03/13] Rebuilt for Python 3.14.0rc2 bytecode From db32e4519c12d1b95ca651ffc56919fdb39de71d Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Mon, 18 Aug 2025 14:49:49 +0100 Subject: [PATCH 04/13] Increase tests/upstream/main.fmf duration to 30m --- tests/upstream/main.fmf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/upstream/main.fmf b/tests/upstream/main.fmf index 8aeea9d..3c8aa15 100644 --- a/tests/upstream/main.fmf +++ b/tests/upstream/main.fmf @@ -5,4 +5,4 @@ path: snapm-0.4.3/ require: - python3-pytest - python3-devel -duration: 25m +duration: 30m From c3955d9ce62e4ac69355b5b11add00b4002a5141 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Mon, 18 Aug 2025 14:52:27 +0100 Subject: [PATCH 05/13] Fix tmt lints and path setting Add a pair of wrapper scripts to set up the environment and run the tests and drop incorrect usage of the path attribute in tests/upstream/main.fmf. --- plans/main.fmf | 1 + tests/upstream/main.fmf | 4 +--- tests/upstream/prepare-host-environment.sh | 11 +++++++++++ tests/upstream/run-unit-tests.sh | 11 +++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100755 tests/upstream/prepare-host-environment.sh create mode 100755 tests/upstream/run-unit-tests.sh diff --git a/plans/main.fmf b/plans/main.fmf index 4e23ba7..34e8a1e 100644 --- a/plans/main.fmf +++ b/plans/main.fmf @@ -1,3 +1,4 @@ +summary: Run snapm unit tests from dist-git sources discover: how: fmf dist-git-source: true diff --git a/tests/upstream/main.fmf b/tests/upstream/main.fmf index 3c8aa15..1bd59ec 100644 --- a/tests/upstream/main.fmf +++ b/tests/upstream/main.fmf @@ -1,7 +1,5 @@ summary: Run snapm upstream test suite -test: | - pytest -v --log-level=debug -path: snapm-0.4.3/ +test: ./prepare-host-environment.sh; ./run-unit-tests.sh require: - python3-pytest - python3-devel diff --git a/tests/upstream/prepare-host-environment.sh b/tests/upstream/prepare-host-environment.sh new file mode 100755 index 0000000..ff0c6cd --- /dev/null +++ b/tests/upstream/prepare-host-environment.sh @@ -0,0 +1,11 @@ +#!/usr/bin/bash +# Prepare the host environment for running the snapm tests. +# This includes installing missing dependencies and tools. + +set -euxo pipefail + +# Move to the checked out git repo with the test plans +# this should be the root of the dist-git repo +cd "${TMT_TREE}" + +sudo dnf builddep -y snapm.spec diff --git a/tests/upstream/run-unit-tests.sh b/tests/upstream/run-unit-tests.sh new file mode 100755 index 0000000..2c2e4c6 --- /dev/null +++ b/tests/upstream/run-unit-tests.sh @@ -0,0 +1,11 @@ +#!/usr/bin/bash +# Execute snapm unit tests from a checked out dist-git repo + +set -euxo pipefail + +source /etc/os-release + +# Move to the extracted sources directory (patches are applied by default) +cd "${SRC_DIR}" + +sudo pytest -v --log-level=debug tests/ From e95d1a15b78b872fbedeffb5256309e8d9ce4c96 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Mon, 18 Aug 2025 16:47:23 +0100 Subject: [PATCH 06/13] Ensure SRC_DIR is defined in run-unit-tests.sh Signed-off-by: Bryn M. Reeves --- plans/main.fmf | 1 + tests/upstream/run-unit-tests.sh | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/plans/main.fmf b/plans/main.fmf index 34e8a1e..125c446 100644 --- a/plans/main.fmf +++ b/plans/main.fmf @@ -16,6 +16,7 @@ prepare: - python3-boom - python3-pytest - boom-boot + - rpmdevtools - name: Enable Stratisd how: shell script: | diff --git a/tests/upstream/run-unit-tests.sh b/tests/upstream/run-unit-tests.sh index 2c2e4c6..e559999 100755 --- a/tests/upstream/run-unit-tests.sh +++ b/tests/upstream/run-unit-tests.sh @@ -5,6 +5,12 @@ set -euxo pipefail source /etc/os-release +# Move to the directory with sources +cd ${TMT_SOURCE_DIR} + +# Extract the Source0 basename without extension +SRC_DIR=$(spectool --source 0 snapm.spec | sed 's/.\+\(snapm-[0-9.]\+\)\.tar\.gz/\1/') + # Move to the extracted sources directory (patches are applied by default) cd "${SRC_DIR}" From 1ec30aecb752fdd9bc1f6810c733f9a0064882d6 Mon Sep 17 00:00:00 2001 From: Python Maint Date: Fri, 19 Sep 2025 14:57:05 +0200 Subject: [PATCH 07/13] Rebuilt for Python 3.14.0rc3 bytecode From 1dede47ea64d56ab8a10332e62f9e355baabde0f Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Sun, 2 Nov 2025 17:51:14 +0000 Subject: [PATCH 08/13] Update snapm to upstream version 0.5.0. Signed-off-by: Bryn M. Reeves --- .gitignore | 1 + snapm.spec | 35 +++++++++++++++++++++++++++++++---- sources | 2 +- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f051b1b..2f6afc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /snapm-0.4.3.tar.gz +/snapm-0.5.0.tar.gz diff --git a/snapm.spec b/snapm.spec index bd8f3c7..960f73e 100644 --- a/snapm.spec +++ b/snapm.spec @@ -1,7 +1,7 @@ %global summary A set of tools for managing snapshots Name: snapm -Version: 0.4.3 +Version: 0.5.0 Release: %autorelease Summary: %{summary} @@ -18,6 +18,9 @@ BuildRequires: stratis-cli BuildRequires: stratisd BuildRequires: python3-devel BuildRequires: python3-sphinx +%if 0%{?fedora} +BuildRequires: libfaketime +%endif Requires: python3-snapm = %{version}-%{release} Recommends: boom-boot @@ -65,8 +68,25 @@ rm -f doc/*.rst doc/Makefile doc/conf.py %install %pyproject_install -mkdir -p %{buildroot}/%{_mandir}/man8 -%{__install} -p -m 644 man/man8/snapm.8 %{buildroot}/%{_mandir}/man8 +mkdir -p ${RPM_BUILD_ROOT}/%{_sysconfdir}/%{name}/plugins.d +mkdir -p ${RPM_BUILD_ROOT}/%{_sysconfdir}/%{name}/schedule.d +%{__install} -p -m 644 etc/%{name}/snapm.conf ${RPM_BUILD_ROOT}/%{_sysconfdir}/%{name} +%{__install} -p -m 644 etc/%{name}/plugins.d/lvm2-cow.conf ${RPM_BUILD_ROOT}/%{_sysconfdir}/%{name}/plugins.d +%{__install} -p -m 644 etc/%{name}/plugins.d/lvm2-thin.conf ${RPM_BUILD_ROOT}/%{_sysconfdir}/%{name}/plugins.d +%{__install} -p -m 644 etc/%{name}/plugins.d/stratis.conf ${RPM_BUILD_ROOT}/%{_sysconfdir}/%{name}/plugins.d + +mkdir -p ${RPM_BUILD_ROOT}/%{_mandir}/man8 +mkdir -p ${RPM_BUILD_ROOT}/%{_mandir}/man5 +%{__install} -p -m 644 man/man8/snapm.8 ${RPM_BUILD_ROOT}/%{_mandir}/man8 +%{__install} -p -m 644 man/man5/snapm.conf.5 ${RPM_BUILD_ROOT}/%{_mandir}/man5 +%{__install} -p -m 644 man/man5/snapm-plugins.d.5 ${RPM_BUILD_ROOT}/%{_mandir}/man5 +%{__install} -p -m 644 man/man5/snapm-schedule.d.5 ${RPM_BUILD_ROOT}/%{_mandir}/man5 + +mkdir -p ${RPM_BUILD_ROOT}/%{_unitdir} +%{__install} -p -m 644 systemd/snapm-create@.service ${RPM_BUILD_ROOT}/%{_unitdir} +%{__install} -p -m 644 systemd/snapm-create@.timer ${RPM_BUILD_ROOT}/%{_unitdir} +%{__install} -p -m 644 systemd/snapm-gc@.service ${RPM_BUILD_ROOT}/%{_unitdir} +%{__install} -p -m 644 systemd/snapm-gc@.timer ${RPM_BUILD_ROOT}/%{_unitdir} %check %pytest --log-level=debug -v tests/ @@ -76,7 +96,14 @@ mkdir -p %{buildroot}/%{_mandir}/man8 %license LICENSE %doc README.md %{_bindir}/snapm -%doc %{_mandir}/man*/snapm.* +%doc %{_mandir}/man*/snapm* +%attr(644, -, -) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/snapm.conf +%attr(644, -, -) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/plugins.d/* +%dir %attr(755, -, -) %{_sysconfdir}/%{name}/schedule.d +%attr(644, -, -) %{_unitdir}/snapm-create@.service +%attr(644, -, -) %{_unitdir}/snapm-create@.timer +%attr(644, -, -) %{_unitdir}/snapm-gc@.service +%attr(644, -, -) %{_unitdir}/snapm-gc@.timer %files -n python3-snapm # license for snapm (Apache-2.0) diff --git a/sources b/sources index eebae8a..b85f24e 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (snapm-0.4.3.tar.gz) = 2a481781f1275fbbb6a5052fbc69379aa85b79f05b860e15aef7826ce75627cbfa6717a93c5a9b538f30ba01900fd70e856b8d5d7a417f010af6b4ec58fb377c +SHA512 (snapm-0.5.0.tar.gz) = d9d745b5770637565f3f4bb669a6441b97b203a364e2974236fc2c4055cbf67afa69758124df3a427d761387c448ce7b4a58e986e9597ea53cc0c532ddca0ba7 From 6a958a4a0214211bde4eee90c552e626c6201f32 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Sun, 2 Nov 2025 19:50:08 +0000 Subject: [PATCH 09/13] Increase duration of tests/upstream/main to 90m The test suite takes longer now that scheduling tests are included. Signed-off-by: Bryn M. Reeves --- tests/upstream/main.fmf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/upstream/main.fmf b/tests/upstream/main.fmf index 1bd59ec..e1c137e 100644 --- a/tests/upstream/main.fmf +++ b/tests/upstream/main.fmf @@ -3,4 +3,4 @@ test: ./prepare-host-environment.sh; ./run-unit-tests.sh require: - python3-pytest - python3-devel -duration: 30m +duration: 90m From 1681e35f9ef4d0142bda1390b09e5d46af34a3b3 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Tue, 4 Nov 2025 13:42:31 +0000 Subject: [PATCH 10/13] Update snapm to upstream version 0.5.1. Signed-off-by: Bryn M. Reeves --- .gitignore | 1 + snapm.spec | 14 +++++++++++++- sources | 2 +- tests/upstream/run-unit-tests.sh | 8 ++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2f6afc4..7a3853f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /snapm-0.4.3.tar.gz /snapm-0.5.0.tar.gz +/snapm-0.5.1.tar.gz diff --git a/snapm.spec b/snapm.spec index 960f73e..335baea 100644 --- a/snapm.spec +++ b/snapm.spec @@ -1,7 +1,7 @@ %global summary A set of tools for managing snapshots Name: snapm -Version: 0.5.0 +Version: 0.5.1 Release: %autorelease Summary: %{summary} @@ -16,6 +16,7 @@ BuildRequires: lvm2 BuildRequires: make BuildRequires: stratis-cli BuildRequires: stratisd +BuildRequires: systemd-rpm-macros BuildRequires: python3-devel BuildRequires: python3-sphinx %if 0%{?fedora} @@ -88,6 +89,13 @@ mkdir -p ${RPM_BUILD_ROOT}/%{_unitdir} %{__install} -p -m 644 systemd/snapm-gc@.service ${RPM_BUILD_ROOT}/%{_unitdir} %{__install} -p -m 644 systemd/snapm-gc@.timer ${RPM_BUILD_ROOT}/%{_unitdir} +mkdir -p ${RPM_BUILD_ROOT}/%{_tmpfilesdir} +%{__install} -p -m 644 systemd/tmpfiles.d/%{name}.conf ${RPM_BUILD_ROOT}/%{_tmpfilesdir}/ + +%{__install} -d -m 0700 ${RPM_BUILD_ROOT}/%{_rundir}/%{name} +%{__install} -d -m 0700 ${RPM_BUILD_ROOT}/%{_rundir}/%{name}/mounts +%{__install} -d -m 0700 ${RPM_BUILD_ROOT}/%{_rundir}/%{name}/lock + %check %pytest --log-level=debug -v tests/ @@ -104,6 +112,10 @@ mkdir -p ${RPM_BUILD_ROOT}/%{_unitdir} %attr(644, -, -) %{_unitdir}/snapm-create@.timer %attr(644, -, -) %{_unitdir}/snapm-gc@.service %attr(644, -, -) %{_unitdir}/snapm-gc@.timer +%attr(644, -, -) %{_tmpfilesdir}/%{name}.conf +%dir %{_rundir}/%{name}/ +%dir %{_rundir}/%{name}/mounts +%dir %{_rundir}/%{name}/lock %files -n python3-snapm # license for snapm (Apache-2.0) diff --git a/sources b/sources index b85f24e..960fde9 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (snapm-0.5.0.tar.gz) = d9d745b5770637565f3f4bb669a6441b97b203a364e2974236fc2c4055cbf67afa69758124df3a427d761387c448ce7b4a58e986e9597ea53cc0c532ddca0ba7 +SHA512 (snapm-0.5.1.tar.gz) = 30bec3d65c24732ad88ddc04ead12b2fafc96ca2e740283bae02b1214bd77f4d108cf1c597aaf27a487eec334243afac83b6ff8202adfe5224694302f40d7a99 diff --git a/tests/upstream/run-unit-tests.sh b/tests/upstream/run-unit-tests.sh index e559999..7b3e7c0 100755 --- a/tests/upstream/run-unit-tests.sh +++ b/tests/upstream/run-unit-tests.sh @@ -14,4 +14,12 @@ SRC_DIR=$(spectool --source 0 snapm.spec | sed 's/.\+\(snapm-[0-9.]\+\)\.tar\.gz # Move to the extracted sources directory (patches are applied by default) cd "${SRC_DIR}" +# Configure snapm +cp -r etc/snapm/ /etc +cp systemd/*.service systemd/*.timer /usr/lib/systemd/system +cp systemd/tmpfiles.d/snapm.conf /usr/lib/tmpfiles.d +systemctl daemon-reload +systemd-tmpfiles --create /usr/lib/tmpfiles.d/snapm.conf + +# Run tests sudo pytest -v --log-level=debug tests/ From 23d55ffb328cd77b57bce2acd3890b0210673fde Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Sun, 16 Nov 2025 20:47:28 +0000 Subject: [PATCH 11/13] Update snapm to upstream version 0.5.2. Signed-off-by: Bryn M. Reeves --- .gitignore | 1 + snapm.spec | 2 +- sources | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 7a3853f..b67ad75 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /snapm-0.4.3.tar.gz /snapm-0.5.0.tar.gz /snapm-0.5.1.tar.gz +/snapm-0.5.2.tar.gz diff --git a/snapm.spec b/snapm.spec index 335baea..f587cfb 100644 --- a/snapm.spec +++ b/snapm.spec @@ -1,7 +1,7 @@ %global summary A set of tools for managing snapshots Name: snapm -Version: 0.5.1 +Version: 0.5.2 Release: %autorelease Summary: %{summary} diff --git a/sources b/sources index 960fde9..a6f3877 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (snapm-0.5.1.tar.gz) = 30bec3d65c24732ad88ddc04ead12b2fafc96ca2e740283bae02b1214bd77f4d108cf1c597aaf27a487eec334243afac83b6ff8202adfe5224694302f40d7a99 +SHA512 (snapm-0.5.2.tar.gz) = 572b52d6d5e734df69b78e274c200456273fa1e6bb65dc28d55b99fe64a015f32c4811bcff8f682b7a3eea98e320bb63c08c10590c166d953eb343c93c842f3a From 96ee0afc9f64b17d9a6534bd17d2e669caae3bb8 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Wed, 19 Nov 2025 23:42:11 +0000 Subject: [PATCH 12/13] Add fix for snapm#606 (timeline index calculation bug) https://github.com/snapshotmanager/snapm/issues/606 Signed-off-by: Bryn M. Reeves --- ...ELINE-policy-retention-indexing-when.patch | 59 +++++ ...add-GcPolicyParamsTimeline-progressi.patch | 238 ++++++++++++++++++ snapm.spec | 2 + 3 files changed, 299 insertions(+) create mode 100644 0001-schedule-fix-TIMELINE-policy-retention-indexing-when.patch create mode 100644 0002-container_tests-add-GcPolicyParamsTimeline-progressi.patch diff --git a/0001-schedule-fix-TIMELINE-policy-retention-indexing-when.patch b/0001-schedule-fix-TIMELINE-policy-retention-indexing-when.patch new file mode 100644 index 0000000..d9b2079 --- /dev/null +++ b/0001-schedule-fix-TIMELINE-policy-retention-indexing-when.patch @@ -0,0 +1,59 @@ +From 4d0c9d55e1c53274527c2f449b83a858ae9bcddd Mon Sep 17 00:00:00 2001 +From: "Bryn M. Reeves" +Date: Tue, 18 Nov 2025 23:49:31 +0000 +Subject: [PATCH 1/2] schedule: fix TIMELINE policy retention indexing when + keep_x > len(x) + +Resolves: #606 + +Signed-off-by: Bryn M. Reeves +--- + snapm/manager/_schedule.py | 20 ++++++++++++++------ + 1 file changed, 14 insertions(+), 6 deletions(-) + +diff --git a/snapm/manager/_schedule.py b/snapm/manager/_schedule.py +index 2a65811..fd382a5 100644 +--- a/snapm/manager/_schedule.py ++++ b/snapm/manager/_schedule.py +@@ -431,24 +431,32 @@ class GcPolicyParamsTimeline(GcPolicyParams): + # Build a set of snapshots that should be KEPT by each category + kept_by_category = { + "yearly": set( +- yearly[len(yearly) - self.keep_yearly :] if self.keep_yearly else [] ++ yearly[max(len(yearly) - self.keep_yearly, 0) :] ++ if self.keep_yearly ++ else [] + ), + "quarterly": set( +- quarterly[len(quarterly) - self.keep_quarterly :] ++ quarterly[max(len(quarterly) - self.keep_quarterly, 0) :] + if self.keep_quarterly + else [] + ), + "monthly": set( +- monthly[len(monthly) - self.keep_monthly :] if self.keep_monthly else [] ++ monthly[max(len(monthly) - self.keep_monthly, 0) :] ++ if self.keep_monthly ++ else [] + ), + "weekly": set( +- weekly[len(weekly) - self.keep_weekly :] if self.keep_weekly else [] ++ weekly[max(len(weekly) - self.keep_weekly, 0) :] ++ if self.keep_weekly ++ else [] + ), + "daily": set( +- daily[len(daily) - self.keep_daily :] if self.keep_daily else [] ++ daily[max(len(daily) - self.keep_daily, 0) :] if self.keep_daily else [] + ), + "hourly": set( +- hourly[len(hourly) - self.keep_hourly :] if self.keep_hourly else [] ++ hourly[max(len(hourly) - self.keep_hourly, 0) :] ++ if self.keep_hourly ++ else [] + ), + } + +-- +2.51.0 + diff --git a/0002-container_tests-add-GcPolicyParamsTimeline-progressi.patch b/0002-container_tests-add-GcPolicyParamsTimeline-progressi.patch new file mode 100644 index 0000000..147a3b2 --- /dev/null +++ b/0002-container_tests-add-GcPolicyParamsTimeline-progressi.patch @@ -0,0 +1,238 @@ +From f9a0dec1289608347f17980e67245d639c7811c0 Mon Sep 17 00:00:00 2001 +From: "Bryn M. Reeves" +Date: Wed, 19 Nov 2025 20:47:34 +0000 +Subject: [PATCH 2/2] container_tests: add GcPolicyParamsTimeline progressive + test + +Resolves: #608 + +Signed-off-by: Bryn M. Reeves +--- + container_tests/tests/__init__.py | 11 ++ + container_tests/tests/test_schedule.py | 185 +++++++++++++++++++++++++ + 2 files changed, 196 insertions(+) + create mode 100644 container_tests/tests/__init__.py + +diff --git a/container_tests/tests/__init__.py b/container_tests/tests/__init__.py +new file mode 100644 +index 0000000..028e43c +--- /dev/null ++++ b/container_tests/tests/__init__.py +@@ -0,0 +1,11 @@ ++import logging ++ ++log = logging.getLogger() ++log.setLevel(logging.DEBUG) ++formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s %(message)s') ++file_handler = logging.FileHandler("test.log") ++file_handler.setFormatter(formatter) ++console_handler = logging.StreamHandler() ++console_handler.setFormatter(formatter) ++log.addHandler(file_handler) ++log.addHandler(console_handler) +diff --git a/container_tests/tests/test_schedule.py b/container_tests/tests/test_schedule.py +index 314518b..6d7522c 100644 +--- a/container_tests/tests/test_schedule.py ++++ b/container_tests/tests/test_schedule.py +@@ -100,6 +100,12 @@ def get_eighteen_months(): + + + class GcPolicyTests(unittest.TestCase): ++ def setUp(self): ++ log.debug("Preparing %s", self._testMethodName) ++ ++ def tearDown(self): ++ log.debug("Tearing down %s", self._testMethodName) ++ + def test_gcpolicy_bad_name(self): + with self.assertRaises(snapm.SnapmArgumentError) as cm: + gcp = GcPolicy("", GcPolicyType.ALL, {}) +@@ -490,6 +496,185 @@ class GcPolicyTests(unittest.TestCase): + self.assertEqual(to_delete[0], snapshot_sets[0], + "Should delete the oldest snapshot set") + ++ def test_GcPolicyParamsTimeline_progressive_hourly_3_months(self): ++ """ ++ Regression test for bug where snapshot sets are incorrectly garbage ++ collected due to a mis-calculation of the retention index when the ++ keep_x parameter for category x is greater than the number of snapshot ++ sets in that category. ++ ++ Generates a sequence of MockSnapshotSet objects at hourly intervals, ++ and applies garbage collection progressively at the end of each ++ interval. This accurately reflects how the GcPolicy applies in real ++ world use. ++ """ ++ params = { ++ "keep_yearly": 0, ++ "keep_quarterly": 1, ++ "keep_monthly": 3, ++ "keep_weekly": 4, ++ "keep_daily": 7, ++ "keep_hourly": 12 ++ } ++ ++ gcp = GcPolicy("test", GcPolicyType.TIMELINE, params) ++ ++ base = datetime(2024, 1, 1, 0, 0, 0) ++ ++ # first timestamp ++ start_ts = int(base.timestamp()) ++ ++ # seconds in three months ++ delta_ts = int(3 * 30.44 * 24 * 3600) ++ ++ snapshot_sets = [] ++ ++ for index, ts in enumerate(range(start_ts, start_ts + delta_ts, 3600)): ++ snapshot_sets.append(MockSnapshotSet(f"hourly.{index}", ts)) ++ to_delete = gcp.evaluate(snapshot_sets) ++ for td in to_delete: ++ snapshot_sets.remove(td) ++ log.debug("Nr snapshot sets (%d): %d", index, len(snapshot_sets)) ++ ++ # First 12 hours (12 hourly + 1 daily): 0-12 hours ++ if index <= 12: ++ self.assertEqual(len(snapshot_sets), index + 1) ++ ++ # First 1 day 11 hours (12 hourly + 1 daily): 14-35 hours ++ if index > 12 and index <= 35: ++ self.assertEqual(len(snapshot_sets), 13) ++ ++ # First 2 days 11 hours (12 hourly + 2 daily): 36-59 hours ++ if index > 35 and index <= 59: ++ self.assertEqual(len(snapshot_sets), 14) ++ ++ # First 3 days 11 hours (12 hourly + 3 daily): 60-83 hours ++ if index > 59 and index <= 83: ++ self.assertEqual(len(snapshot_sets), 15) ++ ++ # First 4 days 11 hours (12 hourly + 4 daily): 84-107 hours ++ if index > 83 and index <= 107: ++ self.assertEqual(len(snapshot_sets), 16) ++ ++ # First 5 days 11 hours (12 hourly + 5 daily): 108-131 hours ++ if index > 107 and index <= 131: ++ self.assertEqual(len(snapshot_sets), 17) ++ ++ # First 6 days 11 hours (12 hourly + 6 daily): 132-155 hours ++ if index > 131 and index <= 155: ++ self.assertEqual(len(snapshot_sets), 18) ++ ++ # First 7 days 11 hours (12 hourly + 7 daily + 1 weekly): 156-179 hours ++ if index > 155 and index <= 179: ++ self.assertEqual(len(snapshot_sets), 19) ++ ++ # First 7 days 23 hours (12 hourly + 7 daily + 1 weekly - dailies begin to expire): 180-191 hours ++ if index > 179 and index <= 191: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 8 days 11 hours (12 hourly + 7 daily) + 1 weekly: 192-203 hours ++ if index > 191 and index <= 203: ++ self.assertEqual(len(snapshot_sets), 19) ++ ++ # First 8 days 23 hours (12 hourly + 7 daily) + 1 weekly: 204-215 hours ++ if index > 203 and index <= 215: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 9 days 11 hours (12 hourly + 7 daily) + 1 weekly: 216-227 hours ++ if index > 215 and index <= 227: ++ self.assertEqual(len(snapshot_sets), 19) ++ ++ # First 9 days 23 hours (12 hourly + 7 daily) + 1 weekly: 228-239 hours ++ if index > 227 and index <= 239: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 10 days 11 hours (12 hourly + 7 daily) + 1 weekly: 240-251 hours ++ if index > 239 and index <= 251: ++ self.assertEqual(len(snapshot_sets), 19) ++ ++ # First 10 days 23 hours (12 hourly + 7 daily + 1 weekly): 252-263 hours ++ if index > 251 and index <= 263: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 11 days 11 hours (12 hourly + 7 daily + 1 weekly): 264-275 hours ++ if index > 263 and index <= 275: ++ self.assertEqual(len(snapshot_sets), 19) ++ ++ # First 11 days 23 hours (12 hourly + 7 daily + 1 weekly): 276-287 hours ++ if index > 275 and index <= 287: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 12 days 11 hours (12 hourly + 7 daily + 1 weekly): 288-299 hours ++ if index > 287 and index <= 299: ++ self.assertEqual(len(snapshot_sets), 19) ++ ++ # First 12 days 23 hours (12 hourly + 7 daily + 1 weekly): 300-311 hours ++ if index > 299 and index <= 311: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 13 days 11 hours (12 hourly + 7 daily + 1 weekly): 312-323 hours ++ if index > 311 and index <= 323: ++ self.assertEqual(len(snapshot_sets), 19) ++ ++ # First 14 days 11 hours (12 hourly + 7 daily + 2 weekly): 324-347 hours ++ if index > 323 and index <= 347: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 14 days 23 hours (12 hourly + 7 daily + 2 weekly): 348-359 hours ++ if index > 347 and index <= 359: ++ self.assertEqual(len(snapshot_sets), 21) ++ ++ # First 15 days 11 hours (12 hourly + 7 daily + 2 weekly): 360-371 hours ++ if index > 359 and index <= 371: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 15 days 23 hours (12 hourly + 7 daily + 2 weekly): 372-383 hours ++ if index > 371 and index <= 383: ++ self.assertEqual(len(snapshot_sets), 21) ++ ++ # First 16 days 11 hours (12 hourly + 7 daily + 2 weekly): 384-395 hours ++ if index > 383 and index <= 395: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 16 days 23 hours (12 hourly + 7 daily + 2 weekly): 396-407 hours ++ if index > 395 and index <= 407: ++ self.assertEqual(len(snapshot_sets), 21) ++ ++ # First 17 days 11 hours (12 hourly + 7 daily + 2 weekly): 408-419 hours ++ if index > 407 and index <= 419: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 17 days 23 hours (12 hourly + 7 daily + 2 weekly): 420-431 hours ++ if index > 419 and index <= 431: ++ self.assertEqual(len(snapshot_sets), 21) ++ ++ # First 18 days 11 hours (12 hourly + 7 daily + 2 weekly): 432-443 hours ++ if index > 431 and index <= 443: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 18 days 23 hours (12 hourly + 7 daily + 2 weekly): 444-455 hours ++ if index > 443 and index <= 455: ++ self.assertEqual(len(snapshot_sets), 21) ++ ++ # First 19 days 11 hours (12 hourly + 7 daily + 2 weekly): 456-467 hours ++ if index > 455 and index <= 467: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 19 days 23 hours (12 hourly + 7 daily + 2 weekly): 468-479 hours ++ if index > 467 and index <= 479: ++ self.assertEqual(len(snapshot_sets), 21) ++ ++ # First 20 days 11 hours (12 hourly + 7 daily + 2 weekly): 480-491 hours ++ if index > 479 and index <= 491: ++ self.assertEqual(len(snapshot_sets), 20) ++ ++ # First 21 days 11 hours (12 hourly + 7 daily + 3 weekly): 492-515 hours ++ if index > 491 and index <= 515: ++ self.assertEqual(len(snapshot_sets), 21) ++ ++ if index > 515: ++ self.assertIn(len(snapshot_sets), (21, 22, 23, 24, 25)) ++ + def test_GcPolicy__str__(self): + gcp = GcPolicy("test", GcPolicyType.ALL, {}) + xstr = "Name: test\nType: All\nParams: " +-- +2.51.0 + diff --git a/snapm.spec b/snapm.spec index f587cfb..19e518e 100644 --- a/snapm.spec +++ b/snapm.spec @@ -8,6 +8,8 @@ Summary: %{summary} License: Apache-2.0 URL: https://github.com/snapshotmanager/%{name} Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz +Patch1: 0001-schedule-fix-TIMELINE-policy-retention-indexing-when.patch +Patch2: 0002-container_tests-add-GcPolicyParamsTimeline-progressi.patch BuildArch: noarch From bf15eb632cd964f0ad256a73d125a6b63e5fad7e Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Thu, 8 Jan 2026 12:47:49 +0000 Subject: [PATCH 13/13] Update snapm to upstream version 0.7.0. Signed-off-by: Bryn M. Reeves --- .gitignore | 1 + snapm.spec | 5 ++--- sources | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index b67ad75..dce77ae 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /snapm-0.5.0.tar.gz /snapm-0.5.1.tar.gz /snapm-0.5.2.tar.gz +/snapm-0.7.0.tar.gz diff --git a/snapm.spec b/snapm.spec index 19e518e..d388071 100644 --- a/snapm.spec +++ b/snapm.spec @@ -1,15 +1,13 @@ %global summary A set of tools for managing snapshots Name: snapm -Version: 0.5.2 +Version: 0.7.0 Release: %autorelease Summary: %{summary} License: Apache-2.0 URL: https://github.com/snapshotmanager/%{name} Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz -Patch1: 0001-schedule-fix-TIMELINE-policy-retention-indexing-when.patch -Patch2: 0002-container_tests-add-GcPolicyParamsTimeline-progressi.patch BuildArch: noarch @@ -27,6 +25,7 @@ BuildRequires: libfaketime Requires: python3-snapm = %{version}-%{release} Recommends: boom-boot +Recommends: python3-file-magic %package -n python3-snapm Summary: %{summary} diff --git a/sources b/sources index a6f3877..06f9b84 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (snapm-0.5.2.tar.gz) = 572b52d6d5e734df69b78e274c200456273fa1e6bb65dc28d55b99fe64a015f32c4811bcff8f682b7a3eea98e320bb63c08c10590c166d953eb343c93c842f3a +SHA512 (snapm-0.7.0.tar.gz) = 13f88538070690bd4a051968f6a23abfc65c5bc5e30ed9fc75dd9cf0518c295099e237b66d704a560df5e9fb8ef5fd544ab72bd302f296be7d077feb78480368