Compare commits

...

11 Commits

Author SHA1 Message Date
Bryn M. Reeves
1d1865620c Update the version test expectation.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
2026-01-08 20:11:17 +00:00
Bryn M. Reeves
1bf5ff4739 Update to upstream 0.7.0
Resolves: RHEL-137376

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
2026-01-08 18:34:25 +00:00
Bryn M. Reeves
fed5ae3ccd schedule: fix TIMELINE policy retention indexing when keep_x > len(x)
https://github.com/snapshotmanager/snapm/issues/606

Resolves: RHEL-129677

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
2025-11-19 23:57:30 +00:00
Bryn M. Reeves
138e85b1f5 Update expected string in TMT version test 2025-11-17 13:34:45 +00:00
Bryn M. Reeves
306b87c104 Update to upstream 0.5.2
Resolves: RHEL-127542
Resolves: RHEL-128932
2025-11-17 12:16:35 +00:00
Bryn M. Reeves
c732297187 Skip test_create_snapshot_set_no_provider in CI
https://github.com/snapshotmanager/snapm/issues/588

Resolves: RHEL-111712

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
2025-11-05 11:22:56 +00:00
Bryn M. Reeves
c7528ef1d5 Update TMT configuration
Resolves: RHEL-111712

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
2025-11-04 19:07:53 +00:00
Bryn M. Reeves
8a28ce10d9 Update to upstream 0.5.1
Resolves: RHEL-111712
2025-11-04 19:02:07 +00:00
Bryn M. Reeves
946f20b4bc Update test path in main.fmf
Resolves: RHEL-80365
Resolves: RHEL-76129
2025-05-12 20:44:12 +01:00
Bryn M. Reeves
504bb5eba1 Remove stray .patch file
Resolves: RHEL-80365
Resolves: RHEL-76129
2025-05-12 20:43:14 +01:00
Bryn M. Reeves
15e4599850 Update to upstream 0.4.3
Resolves: RHEL-80365
Resolves: RHEL-76129
2025-05-12 19:27:07 +01:00
13 changed files with 248 additions and 125 deletions

4
.gitignore vendored
View File

@ -1 +1,5 @@
/snapm-0.4.0.tar.gz
/snapm-0.4.3.tar.gz
/snapm-0.5.1.tar.gz
/snapm-0.5.2.tar.gz
/snapm-0.7.0.tar.gz

View File

@ -0,0 +1,112 @@
From 5d363f97d4ccea2a53c7da48ff9f18a3dd9da274 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Thu, 8 Jan 2026 18:24:16 +0000
Subject: [PATCH] tests: skip a handful of tests in RH CI environments #915
Resolves: #915
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
tests/__init__.py | 7 +++++++
tests/test_command.py | 4 +++-
tests/test_mounts.py | 4 +++-
tests/test_plugin.py | 3 ++-
4 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/tests/__init__.py b/tests/__init__.py
index fa39b9cb..989fc87f 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -101,3 +101,10 @@ def have_root():
and ``False`` otherwise.
"""
return os.geteuid() == 0 and os.getegid() == 0
+
+
+def in_rh_ci():
+ """Return ``True`` if we appear to be running in CentOS/RHEL CI,
+ and ``False`` otherwise.
+ """
+ return os.environ.get("IN_RH_CI", None) is not None
diff --git a/tests/test_command.py b/tests/test_command.py
index c1e547fb..4319ecd3 100644
--- a/tests/test_command.py
+++ b/tests/test_command.py
@@ -18,7 +18,7 @@ from snapm.report import ReportOpts
import snapm.manager
import boom
-from tests import MockArgs, have_root, BOOT_ROOT_TEST
+from tests import MockArgs, have_root, BOOT_ROOT_TEST, in_rh_ci
from ._util import LvmLoopBacked, StratisLoopBacked
@@ -1079,6 +1079,7 @@ class CommandTests(CommandTestsBase):
args += ["snapset", "delete", "hourly.0"]
self.assertEqual(command.main(args), 0)
+ @unittest.skipIf(in_rh_ci(), "Tests running in RH CI pipeline")
def test_main_snapset_diff(self):
"""Test 'snapm snapset diff' command."""
self.manager.create_snapshot_set("testset0", self.mount_points())
@@ -1110,6 +1111,7 @@ class CommandTests(CommandTestsBase):
self.manager.delete_snapshot_sets(snapm.Selection(name="testset0"))
self.manager.delete_snapshot_sets(snapm.Selection(name="testset1"))
+ @unittest.skipIf(in_rh_ci(), "Tests running in RH CI pipeline")
def test_main_snapset_diffreport(self):
"""Test 'snapm snapset diffreport' command."""
self.manager.create_snapshot_set("testset0", self.mount_points())
diff --git a/tests/test_mounts.py b/tests/test_mounts.py
index d6c7a5a3..db249341 100644
--- a/tests/test_mounts.py
+++ b/tests/test_mounts.py
@@ -24,7 +24,7 @@ import snapm.manager._mounts as mounts
import snapm.manager
from snapm.manager.plugins import format_snapshot_name, encode_mount_point
-from tests import have_root, is_redhat
+from tests import have_root, is_redhat, in_rh_ci
from ._util import LoopBackDevices, LvmLoopBacked
ETC_FSTAB = "/etc/fstab"
@@ -587,6 +587,7 @@ class MountsTests(MountsTestsBase):
# 4. Check that the mount was still discovered (it's just a warning)
self.assertEqual(len(new_mounts._mounts), 1)
+ @unittest.skipIf(in_rh_ci(), "Tests running in RH CI pipeline")
def test_discover_incomplete_api_mounts(self):
"""
Tests that discovery logs warnings for missing API mounts.
@@ -626,6 +627,7 @@ class MountsTestsExec(MountsTestsBase):
"""
need_exec = True
+ @unittest.skipIf(in_rh_ci(), "Tests running in RH CI pipeline")
def test_mount_exec(self):
"""
Tests running a command chrooted inside a mounted snapshot set.
diff --git a/tests/test_plugin.py b/tests/test_plugin.py
index bd4fec08..7532a2fb 100644
--- a/tests/test_plugin.py
+++ b/tests/test_plugin.py
@@ -14,7 +14,7 @@ log = logging.getLogger()
import snapm.manager.plugins as plugins
-from tests import MockPlugin
+from tests import MockPlugin, in_rh_ci
def _find_device_mounts():
@@ -85,6 +85,7 @@ class PluginTests(unittest.TestCase):
for name, origin in snapshot_names.items():
self.assertEqual(None, plugins.parse_snapshot_name(name, origin))
+ @unittest.skipIf(in_rh_ci(), "Tests running in RH CI pipeline")
def test_device_from_mount_point(self):
mounts = _find_device_mounts()
for mount in mounts:
--
2.52.0

View File

@ -1,38 +0,0 @@
From 5b96245740eb8ee94ff744edb9cacd1d161ddec0 Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Fri, 20 Dec 2024 20:32:14 +0000
Subject: [PATCH] tests: temporarily exclude CentOS from test_boot.is_redhat()
check
The current version of boom-boot in CentOS Stream does not support
automatic --uname-pattern for CentOS installations:
# boom profile create --from-host
Could not determine uname pattern for 'CentOS Stream'
Exclude CentOS temporarily from the profile auto-creation test until
https://github.com/snapshotmanager/boom-boot/issues/59 is fixed and
available in the CentOS repos.
---
tests/test_boot.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tests/test_boot.py b/tests/test_boot.py
index a15ce5f..e8d76ee 100644
--- a/tests/test_boot.py
+++ b/tests/test_boot.py
@@ -39,7 +39,10 @@ _VAR_TMP = "/var/tmp"
def is_redhat():
- return os.path.exists("/etc/redhat-release")
+ # Exclude CentOS for now until the fix for boom-boot #59 is available
+ # in the CentOS repositories.
+ return (os.path.exists("/etc/redhat-release")
+ and not os.path.exists("/etc/centos-release"))
class BootTestsSimple(unittest.TestCase):
--
2.47.1

View File

@ -1,3 +1,4 @@
summary: Run snapm unit tests from dist-git sources
discover:
how: fmf
dist-git-source: true
@ -14,16 +15,18 @@ prepare:
- lvm2
- python3-boom
- python3-pytest
- boom-boot
- rpmdevtools
- name: Enable Stratisd
how: shell
script: |
systemctl enable --now stratisd
- name: Create boom OsProfile
how: shell
script: |
boom profile create --from-host --uname-pattern el10
- name: Enable CRB
how: shell
script: |
dnf install -y "dnf-command(config-manager)" ;
dnf config-manager --set-enabled crb || true
- name: Create boom OsProfile
how: shell
script: |
boom profile create --from-host

View File

@ -1,53 +1,38 @@
%global summary A set of tools for managing snapshots
%global sphinx_docs 1
Name: snapm
Version: 0.4.0
Release: 2%{?dist}
Version: 0.7.0
Release: %autorelease
Summary: %{summary}
License: GPL-2.0-only AND Apache-2.0
URL: https://github.com/snapshotmanager/snapm
License: Apache-2.0
URL: https://github.com/snapshotmanager/%{name}
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
Patch1: 0001-tests-temporarily-exclude-CentOS-from-test_boot.is_r.patch
Patch1: 0001-tests-skip-a-handful-of-tests-in-RH-CI-environments-.patch
BuildArch: noarch
BuildRequires: make
BuildRequires: python3-setuptools
BuildRequires: python3-devel
BuildRequires: python3-pip
BuildRequires: python3-wheel
BuildRequires: python3-boom
BuildRequires: python3-dbus-client-gen
BuildRequires: python3-dbus-python-client-gen
BuildRequires: python3-justbytes
BuildRequires: python3-packaging
BuildRequires: python3-dateutil
BuildRequires: python3-wcwidth
BuildRequires: python3-psutil
BuildRequires: python3-pytest
BuildRequires: lvm2
BuildRequires: stratisd
BuildRequires: stratis-cli
%if 0%{?sphinx_docs}
BuildRequires: python3-sphinx
BuildRequires: boom-boot
BuildRequires: lvm2
BuildRequires: make
BuildRequires: stratis-cli
BuildRequires: stratisd
BuildRequires: systemd-rpm-macros
BuildRequires: python3-devel
BuildRequires: python3-sphinx
%if 0%{?fedora}
BuildRequires: libfaketime
%endif
Requires: python3-snapm = %{version}-%{release}
Recommends: boom-boot
Recommends: python3-file-magic
%package -n python3-snapm
Summary: %{summary}
%{?python_provide:%python_provide python3-snapm}
Requires: %{__python3}
Requires: python3-boom >= 1.6.4
%if 0%{?sphinx_docs}
%package -n python3-snapm-doc
Summary: %{summary}
%endif
%description
Snapshot manager (snapm) is a tool for managing sets of snapshots on Linux
@ -61,86 +46,91 @@ the same time, representing the system state at the time the set was created.
This package provides the python3 snapm module.
%if 0%{?sphinx_docs}
%description -n python3-snapm-doc
Snapshot manager (snapm) is a tool for managing sets of snapshots on Linux
systems. The snapm tool allows snapshots of multiple volumes to be captured at
the same time, representing the system state at the time the set was created.
This package provides the python3 snapm module documentation in HTML format.
%endif
%prep
%autosetup -p1 -n snapm-%{version}
%autosetup -p1 -n %{name}-%{version}
%generate_buildrequires
%pyproject_buildrequires
%build
%if 0%{?sphinx_docs}
make %{?_smp_mflags} -C doc html
%pyproject_wheel
%{make_build} -C doc html
rm doc/_build/html/.buildinfo
mv doc/_build/html doc/html
rm -rf doc/html/_sources
rm -rf doc/_build
rm -f doc/*.rst
%endif
%if 0%{?centos} || 0%{?rhel}
%py3_build
%else
%pyproject_wheel
%endif
rm -rf doc/html/_sources doc/_build
rm -f doc/*.rst doc/Makefile doc/conf.py
%install
%if 0%{?centos} || 0%{?rhel}
%py3_install
%else
%pyproject_install
%endif
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
install -m 644 man/man8/snapm.8 ${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
rm doc/Makefile
rm doc/conf.py
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}
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-3 --log-level=debug -v
%pytest --log-level=debug -v tests/
%files
# Main license for snapm (GPLv2)
%license COPYING
# License for snapm.manager.plugins.stratislib (Apache 2.0)
%license COPYING.stratislib
# Main license for snapm (Apache-2.0)
%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
%attr(644, -, -) %{_tmpfilesdir}/%{name}.conf
%dir %{_rundir}/%{name}/
%dir %{_rundir}/%{name}/mounts
%dir %{_rundir}/%{name}/lock
%files -n python3-snapm
# Main license for snapm (GPLv2)
%license COPYING
# License for snapm.manager.plugins.stratislib (Apache 2.0)
%license COPYING.stratislib
# license for snapm (Apache-2.0)
%license LICENSE
%doc README.md
%{python3_sitelib}/%{name}/
%if 0%{?centos} || 0%{?rhel}
%{python3_sitelib}/%{name}-*.egg-info/
%else
%{python3_sitelib}/%{name}*.dist-info/
%endif
%if 0%{?sphinx_docs}
%files -n python3-snapm-doc
# Main license for snapm (GPLv2)
%license COPYING
# License for snapm.manager.plugins.stratislib (Apache 2.0)
%license COPYING.stratislib
# license for snapm (Apache-2.0)
%license LICENSE
%doc README.md
%doc doc
%endif
%changelog
* Thu Jan 09 2025 Bryn M. Reeves <bmr@redhat.com> - 0.4.0-2
- Bump release and rebuild
Resolves: RHEL-59006
* Wed Dec 18 2024 Bryn M. Reeves <bmr@redhat.com> - 0.4.0-1
- Initial commit on c10s
Resolves: RHEL-59006
%autochangelog

View File

@ -1 +1 @@
SHA512 (snapm-0.4.0.tar.gz) = d4829bef312212e0b122c241235cce6520dc1c37e11dbe32d1882485a2d81e94aa396d0957c13fee848e472ab3efcad18b262c5bfbb9a7fd08f74497d34f97ba
SHA512 (snapm-0.7.0.tar.gz) = 13f88538070690bd4a051968f6a23abfc65c5bc5e30ed9fc75dd9cf0518c295099e237b66d704a560df5e9fb8ef5fd544ab72bd302f296be7d077feb78480368

2
tests/help/main.fmf Normal file
View File

@ -0,0 +1,2 @@
summary: Test snapm --help output
test: ./test.sh

8
tests/help/test.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh -eux
echo $TMT_SOURCE_DIR
ls $TMT_SOURCE_DIR
tmp=$(mktemp)
snapm --help > "$tmp"
grep 'Snapshot Manager' "$tmp"
rm "$tmp"

View File

@ -1,8 +1,6 @@
summary: Run snapm upstream test suite
test: |
pytest -v --log-level=debug
path: snapm-0.4.0/
test: ./prepare-host-environment.sh; ./run-unit-tests.sh
require:
- python3-pytest
- python3-devel
duration: 25m
duration: 90m

View File

@ -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

View File

@ -0,0 +1,25 @@
#!/usr/bin/bash
# Execute snapm unit tests from a checked out dist-git repo
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}"
# 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 IN_RH_CI=yes pytest -v --log-level=debug tests/

2
tests/version/main.fmf Normal file
View File

@ -0,0 +1,2 @@
summary: Test snapm --version output
test: ./test.sh

6
tests/version/test.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh -eux
tmp=$(mktemp)
snapm --version > "$tmp"
grep '0.7.0' "$tmp"
rm "$tmp"