Skip to content

Commit

Permalink
tests: make clearer which tests are skipped [minor]
Browse files Browse the repository at this point in the history
  • Loading branch information
sloonz committed Dec 19, 2024
1 parent 38d0487 commit 1e1b406
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 29 deletions.
13 changes: 3 additions & 10 deletions tests/dest_btrfs_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ class DestBtrfsTests(unittest.TestCase, SrcBaseTests):
def setUp(self):
test_root = os.environ.get("UBACK_BTRFS_TEST_ROOT")
if test_root is None:
self.tmpdir = None
return
raise unittest.SkipTest("UBACK_BTRFS_TEST_ROOT not set")

ensure_dir(test_root)
self.tmpdir = f"{test_root}/dest-test"
basetmpdir = tempfile.mkdtemp(dir=test_root)
self.tmpdir = f"{basetmpdir}/dest-test"
if os.path.exists(self.tmpdir):
raise Exception("UBACK_BTRFS_TEST_ROOT already exists")

Expand All @@ -17,9 +16,6 @@ def setUp(self):
ensure_dir(f"{self.tmpdir}/snapshots")

def tearDown(self):
if self.tmpdir is None:
return

for s in os.listdir(f"{self.tmpdir}/backups"):
subprocess.check_call(["sudo", "btrfs", "subvolume", "delete", f"{self.tmpdir}/backups/{s}"])
for s in os.listdir(f"{self.tmpdir}/snapshots"):
Expand All @@ -38,9 +34,6 @@ def _cleanup_restore(self, d):
subprocess.check_call(["sudo", "btrfs", "subvolume", "delete", f"{d}/restore/{s}"])

def test_btrfs_dest(self):
if self.tmpdir is None:
return

source = f"type=btrfs,path={self.tmpdir}/source,no-encryption=1,state-file={self.tmpdir}/state.json,snapshots-path={self.tmpdir}/snapshots,full-interval=weekly," +\
"send-command=sudo btrfs send,delete-command=sudo btrfs subvolume delete"
dest = f"id=test,type=btrfs,path={self.tmpdir}/backups,no-encryption=1," +\
Expand Down
17 changes: 5 additions & 12 deletions tests/src_btrfs_tests.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
from .common import *

import json
import unittest
import tempfile

class SrcBtrfsTests(unittest.TestCase, SrcBaseTests):
def setUp(self):
test_root = os.environ.get("UBACK_BTRFS_TEST_ROOT")
if test_root is None:
self.tmpdir = None
return
raise unittest.SkipTest("UBACK_BTRFS_TEST_ROOT not set")

ensure_dir(test_root)
self.tmpdir = f"{test_root}/src-test"
if os.path.exists(self.tmpdir):
raise Exception("UBACK_BTRFS_TEST_ROOT already exists")
basetmpdir = tempfile.mkdtemp(dir=test_root)
self.tmpdir = f"{basetmpdir}/tests"

subprocess.check_call(["btrfs", "subvolume", "create", self.tmpdir])
subprocess.check_call(["btrfs", "subvolume", "create", f"{self.tmpdir}/source"])
Expand All @@ -38,18 +37,12 @@ def _cleanup_restore(self, d):
subprocess.check_call(["sudo", "btrfs", "subvolume", "delete", f"{d}/restore/{s}"])

def test_btrfs_source(self):
if self.tmpdir is None:
return

source = f"type=btrfs,path={self.tmpdir}/source,key-file={self.tmpdir}/backup.pub,state-file={self.tmpdir}/state.json,snapshots-path={self.tmpdir}/snapshots,full-interval=weekly," +\
"send-command=sudo btrfs send,delete-command=sudo btrfs subvolume delete"
dest = f"id=test,type=fs,path={self.tmpdir}/backups,@retention-policy=daily=3,key-file={self.tmpdir}/backup.key"
self._test_src(self.tmpdir, source, dest, "receive-command=sudo btrfs receive", test_ignore=False, test_delete=True)

def test_btrfs_reuse_snapshots(self):
if self.tmpdir is None:
return

source = f"type=btrfs,path={self.tmpdir}/source,key-file={self.tmpdir}/backup.pub,state-file={self.tmpdir}/state.json,snapshots-path={self.tmpdir}/snapshots,full-interval=weekly," +\
"send-command=sudo btrfs send,delete-command=sudo btrfs subvolume delete,reuse-snapshots=1d"
dest = f"type=fs,@retention-policy=daily=3,key-file={self.tmpdir}/backup.key"
Expand Down
8 changes: 1 addition & 7 deletions tests/src_mariabackup_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class SrcMariabackupTests(unittest.TestCase):
def setUp(self):
if os.getenv("SKIP_MARIADB_TESTS"):
return
raise unittest.SkipTest("UBACK_BTRFS_TEST_ROOT not set")

self.tmpdir = tempfile.mkdtemp()
os.mkdir(f"{self.tmpdir}/snapshots")
Expand Down Expand Up @@ -41,15 +41,9 @@ def _get_source(self, container):
f"command=docker exec -i {container} mariadb-backup -uroot -ptest,mariadb-command=docker exec -i {container} mariadb -uroot -ptest"

def tearDown(self):
if os.getenv("SKIP_MARIADB_TESTS"):
return

shutil.rmtree(self.tmpdir)

def test_mariabackup_source(self):
if os.getenv("SKIP_MARIADB_TESTS"):
return

container = None
try:
container = self._run_server("10.10")
Expand Down

0 comments on commit 1e1b406

Please sign in to comment.