mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix: the API verifies a backup and shows what was found; Docker's health check reads /healthz
The backups API had every backup action but Verify, and did not show a backup's verified_at and damage: a script restoring through it got no sign of a damaged chain. Docker's health check asked for the login page, so a hung job worker left the container healthy; it now reads /healthz.
This commit is contained in:
parent
fc6ad4e8ca
commit
7b23c75bf5
5 changed files with 42 additions and 6 deletions
|
|
@ -13,6 +13,7 @@ from django.contrib.auth import get_user_model
|
|||
from django.core.exceptions import PermissionDenied
|
||||
from django.test import TransactionTestCase
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
|
||||
from appsettings.settings import get_settings
|
||||
from computes.models import Compute
|
||||
|
|
@ -328,6 +329,23 @@ class VerifyBackupTests(TransactionTestCase):
|
|||
self.assertContains(page, "Damaged")
|
||||
self.assertContains(page, "The backup's file f is missing from the target")
|
||||
|
||||
def test_the_api_verifies_and_tells_what_was_found(self):
|
||||
self.client.force_login(self.admin)
|
||||
response = self.client.post(f"/api/v1/backups/{self.full.uuid}/verify/", {"submission_key": "key-api-ver1"},
|
||||
content_type="application/json")
|
||||
self.assertEqual(response.status_code, 202, response.content)
|
||||
self.assertEqual(response.json()["kind"], "backup.verify")
|
||||
Backup.objects.filter(pk=self.full.pk).update(verified_at=timezone.now(), damage=[
|
||||
{"text": "The backup's file %(name)s is missing from the target", "values": {"name": "f"}}])
|
||||
backup = self.client.get(f"/api/v1/backups/{self.full.uuid}/").json()
|
||||
self.assertTrue(backup["verified_at"])
|
||||
self.assertEqual(backup["damage"], "The backup's file f is missing from the target")
|
||||
# an incremental restores its base's files too
|
||||
self.assertEqual(self.client.get(f"/api/v1/backups/{self.incremental.uuid}/").json()["damage"],
|
||||
"The backup's file f is missing from the target")
|
||||
Backup.objects.filter(pk=self.full.pk).update(damage=[])
|
||||
self.assertEqual(self.client.get(f"/api/v1/backups/{self.incremental.uuid}/").json()["damage"], "")
|
||||
|
||||
def test_a_restore_page_tells_of_damage_in_the_chain(self):
|
||||
self.client.force_login(self.admin)
|
||||
damage = [{"text": "The backup's file %(name)s is missing from the target", "values": {"name": "base-vda.qcow2"}}]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue