(ui) Add readable dry-run summaries
Surface dry-run status, transfer estimates, file counts, warnings, and the full rsync log link directly on the run detail page. Keep raw rsync output and JSON available, but make the common review path easier to scan before starting a real backup.
This commit is contained in:
@@ -1066,12 +1066,69 @@ class ViewTests(TestCase):
|
||||
self.assertContains(response, "--archive")
|
||||
self.assertContains(response, "Rsync Log")
|
||||
self.assertContains(response, "sending incremental file list")
|
||||
self.assertContains(response, "Dry Run Summary")
|
||||
self.assertContains(response, "Files Seen")
|
||||
self.assertContains(response, "Would Transfer")
|
||||
self.assertContains(response, "Transfer Estimate")
|
||||
self.assertContains(response, "Warnings:</strong> none recorded")
|
||||
self.assertContains(response, "Stats")
|
||||
self.assertContains(response, "Files seen:</strong> 10")
|
||||
self.assertContains(response, "Estimated link-dest saving")
|
||||
self.assertContains(response, ""ok": true")
|
||||
self.assertContains(response, reverse("snapshot_detail", args=[snapshot.id]))
|
||||
|
||||
def test_run_detail_surfaces_dry_run_warnings_and_log_link(self) -> None:
|
||||
self.client.force_login(self.staff_user)
|
||||
host = HostConfig.objects.create(host="web-01", address="web-01.example.test")
|
||||
with TemporaryDirectory() as tmp:
|
||||
log_path = Path(tmp) / "dry-run" / "rsync.log"
|
||||
log_path.parent.mkdir(parents=True)
|
||||
log_path.write_text("WARNING: noisy shell output\npermission denied\n", encoding="utf-8")
|
||||
run = BackupRun.objects.create(
|
||||
host=host,
|
||||
status=BackupRun.Status.FAILED,
|
||||
rsync_exit_code=255,
|
||||
result={
|
||||
"ok": False,
|
||||
"dry_run": True,
|
||||
"log": str(log_path),
|
||||
"failure": {
|
||||
"category": "transport",
|
||||
"message": "Rsync transport failed.",
|
||||
"hint": "Check SSH access.",
|
||||
},
|
||||
"stats": {
|
||||
"duration_seconds": 4,
|
||||
"rsync": {
|
||||
"files_total": 25,
|
||||
"files_transferred": 3,
|
||||
"total_file_size_bytes": 10_000,
|
||||
"total_transferred_file_size_bytes": 1_500,
|
||||
},
|
||||
},
|
||||
"rsync": {
|
||||
"exit_code": 255,
|
||||
"log_tail": ["WARNING: noisy shell output", "permission denied"],
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
response = self.client.get(reverse("run_detail", args=[run.id]))
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "Dry Run Summary")
|
||||
self.assertContains(response, "failed")
|
||||
self.assertContains(response, "Files Seen")
|
||||
self.assertContains(response, "25")
|
||||
self.assertContains(response, "Would Transfer")
|
||||
self.assertContains(response, "3")
|
||||
self.assertContains(response, "1.5")
|
||||
self.assertContains(response, "Open full rsync log")
|
||||
self.assertContains(response, reverse("run_rsync_log", args=[run.id]))
|
||||
self.assertContains(response, "Rsync transport failed.")
|
||||
self.assertContains(response, "Check SSH access.")
|
||||
self.assertContains(response, "WARNING: noisy shell output")
|
||||
|
||||
def test_run_detail_links_existing_rsync_log(self) -> None:
|
||||
self.client.force_login(self.staff_user)
|
||||
host = HostConfig.objects.create(host="web-01", address="web-01.example.test")
|
||||
|
||||
Reference in New Issue
Block a user