diff options
author | David VaĊĦek <david.vasek@nic.cz> | 2024-05-24 19:35:15 +0200 |
---|---|---|
committer | Daniel Salzman <daniel.salzman@nic.cz> | 2024-06-14 17:18:30 +0200 |
commit | a675f90dff83aa54a06c5379e568daeb74911c70 (patch) | |
tree | f7e76f7f95e453930673461b7c7db6b5e4fe3ce4 /tests-extra/tests | |
parent | contrib/files: in remove_file(), remove all cases of directory as a directory (diff) | |
download | knot-a675f90dff83aa54a06c5379e568daeb74911c70.tar.xz knot-a675f90dff83aa54a06c5379e568daeb74911c70.zip |
backup: use the force option to overwrite an already existing backupdir
Diffstat (limited to '')
-rw-r--r-- | tests-extra/tests/zone/backup/test.py | 36 | ||||
-rw-r--r-- | tests-extra/tests/zone/backup_lock/test.py | 6 |
2 files changed, 41 insertions, 1 deletions
diff --git a/tests-extra/tests/zone/backup/test.py b/tests-extra/tests/zone/backup/test.py index 215b2dcdf..68fcd924e 100644 --- a/tests-extra/tests/zone/backup/test.py +++ b/tests-extra/tests/zone/backup/test.py @@ -37,6 +37,7 @@ for z in zones: slave.zonefile_load = "none" backup_dir = master.dir + "/backup" +backup_dir2 = master.dir + "/backup2" # Backup of a backup, for debugging. slave_bck_dir = slave.dir + "/backup" zone0_expire = 45 # zone zones[0] expiration time in its SOA @@ -57,7 +58,8 @@ for z in zones: master.ctl("zone-sign " + z.name) slave.zone_wait(z, serials_init[z.name]) -master.ctl("zone-backup +backupdir %s" % backup_dir) +master.ctl("zone-backup +backupdir %s" % backup_dir, wait=True) +master.ctl("zone-backup +backupdir %s" % backup_dir2) slave.ctl("zone-backup %s %s +journal +backupdir %s +nozonefile" % \ (zones[0].name, zones[1].name, slave_bck_dir)) @@ -132,4 +134,36 @@ for i in range(start_time + zone0_expire + valgrind_delay - int(t.uptime())): resp = slave.dig(zones[0].name, "SOA") resp.check(rcode="SERVFAIL") +# Test that the older backup is replaced by the newer one. +shutil.rmtree(keydir) +master.start() +master.zones_wait(zones) +(dnskey1_5, dnskey2_5) = get_dnskeys(master, zones) +if dnskey1_5 == dnskey1_4 or dnskey2_5 == dnskey2_4: + set_err("TEST ERROR 2") +master.ctl("-f zone-backup +backupdir %s" % backup_dir, wait=True) +master.stop() +shutil.rmtree(keydir) +master.start() +master.zones_wait(zones) +(dnskey1_6, dnskey2_6) = get_dnskeys(master, zones) +if dnskey1_6 == dnskey1_5 or dnskey2_6 == dnskey2_5: + set_err("TEST ERROR 3") +master.ctl("zone-restore +backupdir %s" % backup_dir, wait=True) +master.zones_wait(zones) +(dnskey1_7, dnskey2_7) = get_dnskeys(master, zones) +if dnskey1_7 != dnskey1_5 or dnskey2_7 != dnskey2_5: + set_err("KEYS FROM FORCED BACKUP NOT RESTORED") + +# Test that even a zonefile not existing in the newer backup gets overwritten. +master.ctl("-f zone-purge %s" % zones[1].name, wait=True) +master.ctl("-f zone-backup +backupdir %s" % backup_dir, wait=True) +master.ctl("-f zone-purge", wait=True) +master.ctl("zone-restore +backupdir %s" % backup_dir, wait=True) +t.sleep(3) +resp = master.dig(zones[0].name, "SOA") +resp.check(rcode="NOERROR") +resp = master.dig(zones[1].name, "SOA") +resp.check(rcode="SERVFAIL") + t.stop() diff --git a/tests-extra/tests/zone/backup_lock/test.py b/tests-extra/tests/zone/backup_lock/test.py index 1aab2b550..0d2ef8b48 100644 --- a/tests-extra/tests/zone/backup_lock/test.py +++ b/tests-extra/tests/zone/backup_lock/test.py @@ -98,6 +98,12 @@ except: pass check_log_err(master, "already exists") +# Attempt to start backup with the "-f" option into already existing backup, expected OK. +try: + master.ctl("-f zone-backup +backupdir %s" % backup_dir, wait=True) +except: + set_err("FORCED BACKUP NOT ALLOWED") + # Attempt to start restore from non-existing backup directory, expected (not exists). try: master.ctl("zone-restore +backupdir %s" % backup_dir_void, wait=True) |