Module: check_mk
Branch: master
Commit: d86a1be083c6aa996973d7f2761018b78d7ea7c6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d86a1be083c6aa…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jan 14 07:40:14 2019 +0100
Add test for the new no-history option
Change-Id: I0cbfa440630fb68f0aeed3cf6d8f6be124564e72
---
tests/integration/bin/test_mkbackup.py | 36 ++++++++++++++++++++++++++++++++--
1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/tests/integration/bin/test_mkbackup.py
b/tests/integration/bin/test_mkbackup.py
index 17bc584..0ebacb8 100644
--- a/tests/integration/bin/test_mkbackup.py
+++ b/tests/integration/bin/test_mkbackup.py
@@ -3,19 +3,26 @@
import subprocess
import re
import os
+import tarfile
+import fnmatch
import lockfile # type: ignore
import pytest # type: ignore
from testlib import web # pylint: disable=unused-import
-(a)pytest.fixture(scope="function")
-def test_cfg(web, site, tmpdir):
+(a)pytest.fixture()
+def backup_path(tmpdir):
backup_path = '%s/backup' % tmpdir
if not os.path.exists(backup_path):
os.makedirs(backup_path)
+ return backup_path
+
+
+(a)pytest.fixture(scope="function")
+def test_cfg(web, site, backup_path):
cfg = {
'jobs': {
'testjob': {
@@ -25,6 +32,14 @@ def test_cfg(web, site, tmpdir):
'target': 'test-target',
'title': u'T\xe4stjob',
},
+ 'testjob-no-history': {
+ 'no_history': True,
+ 'compress': False,
+ 'encrypt': None,
+ 'schedule': None,
+ 'target': 'test-target',
+ 'title': u'T\xe4stjob no history',
+ },
'testjob-compressed': {
'compress': True,
'encrypt': None,
@@ -215,3 +230,20 @@ def test_mkbackup_encrypted_backup_and_restore(site, test_cfg):
def test_mkbackup_compressed_backup_and_restore(site, test_cfg):
backup_id = _execute_backup(site, job_id="testjob-compressed")
_execute_restore(site, backup_id)
+
+
+def test_mkbackup_no_history_backup_and_restore(site, test_cfg, backup_path):
+ backup_id = _execute_backup(site, job_id="testjob-no-history")
+
+ tar_path = os.path.join(backup_path, backup_id, "site-%s.tar" % site.id)
+
+ member_names = [m.name for m in tarfile.open(tar_path).getmembers()]
+ history = [n for n in member_names if fnmatch.fnmatch(n,
"*/var/check_mk/core/archive/*")]
+ logs = [n for n in member_names if fnmatch.fnmatch(n, "*/var/log/*.log")]
+ rrds = [n for n in member_names if n.endswith(".rrd")]
+
+ assert not history, history
+ assert not rrds, rrds
+ assert not logs, logs
+
+ _execute_restore(site, backup_id)