Fix test email generator to use correct Veeam format and consistent job name

Changed test emails to use proper Veeam Backup Job format that matches parser
expectations. All test emails now use the same job name "Test-Backup-Job" so
they appear as different runs of the same job, enabling proper status testing.

Changes:
- Switched from multiple backup software to Veeam only for simplicity
- Fixed subject format to: Veeam Backup Job "Test-Backup-Job" finished with Success/WARNING/Failed
- Fixed body format to include: Backup job: Test-Backup-Job
- All 3 emails per set use same job name but different dates
- Added realistic VM objects (VM-APP01, VM-DB01, VM-WEB01) with status details
- Each set shows different failure scenarios for testing
- Updated changelog description

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Ivo Oskamp 2026-02-09 14:54:42 +01:00
parent 19ef9dc32a
commit 26848998e1
2 changed files with 156 additions and 70 deletions

View File

@ -309,46 +309,74 @@ def settings_generate_test_emails(status_type):
try:
from datetime import datetime, timedelta
# Fixed test email sets per status type
# Fixed test email sets per status type (Veeam only for consistent testing)
# All emails use the same job name "Test-Backup-Job" so they appear as different
# runs of the same job for proper status testing
email_sets = {
"success": [
{
"from_address": "veeam@test.local",
"subject": "Backup job 'Daily VM Backup' completed successfully",
"body": """Job name: Daily VM Backup
Status: Success
"subject": 'Veeam Backup Job "Test-Backup-Job" finished with Success',
"body": """Backup job: Test-Backup-Job
Session details:
Start time: 2026-02-09 01:00:00
End time: 2026-02-09 02:15:00
Total size: 150 GB
Objects processed: 25
Duration: 01:15:00
Processing VM-APP01
Success
Processing VM-DB01
Success
Processing VM-WEB01
Success
All backup operations completed without issues.""",
},
{
"from_address": "synology@test.local",
"subject": "[Synology] Backup Task SQL Database Backup completed successfully",
"body": """Dear Administrator,
"from_address": "veeam@test.local",
"subject": 'Veeam Backup Job "Test-Backup-Job" finished with Success',
"body": """Backup job: Test-Backup-Job
Backup task 'SQL Database Backup' has completed successfully.
Session details:
Start time: 2026-02-08 01:00:00
End time: 2026-02-08 02:10:00
Total size: 145 GB
Duration: 01:10:00
Task: SQL Database Backup
Status: Success
Start: 2026-02-09 02:00:00
Finish: 2026-02-09 02:45:00
Data transferred: 75 GB
Processing VM-APP01
Success
Processing VM-DB01
Success
Processing VM-WEB01
Success
All backup operations completed without issues.""",
},
{
"from_address": "nakivo@test.local",
"subject": "Job 'Exchange Mailbox' finished successfully",
"body": """NAKIVO Backup & Replication
"from_address": "veeam@test.local",
"subject": 'Veeam Backup Job "Test-Backup-Job" finished with Success',
"body": """Backup job: Test-Backup-Job
Job: Exchange Mailbox
Status: Success
Started: 2026-02-09 03:00:00
Completed: 2026-02-09 03:30:00
Size: 50 GB
Session details:
Start time: 2026-02-07 01:00:00
End time: 2026-02-07 02:20:00
Total size: 152 GB
Duration: 01:20:00
Processing VM-APP01
Success
Processing VM-DB01
Success
Processing VM-WEB01
Success
All backup operations completed without issues.""",
},
@ -356,85 +384,143 @@ All backup operations completed without issues.""",
"warning": [
{
"from_address": "veeam@test.local",
"subject": "Backup job 'Weekly File Server' completed with warnings",
"body": """Job name: Weekly File Server
Status: Warning
"subject": 'Veeam Backup Job "Test-Backup-Job" finished with WARNING',
"body": """Backup job: Test-Backup-Job
Session details:
Start time: 2026-02-09 01:00:00
End time: 2026-02-09 02:30:00
Total size: 200 GB
Objects processed: 35
Total size: 148 GB
Duration: 01:30:00
Processing VM-APP01
Success
Processing VM-DB01
Warning
Warning: Low free space on target datastore
Processing VM-WEB01
Success
Backup completed but some files were skipped.""",
},
{
"from_address": "synology@test.local",
"subject": "[Synology] Backup Task Critical Servers completed with warnings",
"body": """Dear Administrator,
"from_address": "veeam@test.local",
"subject": 'Veeam Backup Job "Test-Backup-Job" finished with WARNING',
"body": """Backup job: Test-Backup-Job
Backup task 'Critical Servers' has completed with warnings.
Session details:
Start time: 2026-02-08 01:00:00
End time: 2026-02-08 02:25:00
Total size: 142 GB
Duration: 01:25:00
Task: Critical Servers
Status: Warning
Start: 2026-02-09 02:00:00
Finish: 2026-02-09 03:00:00
Data transferred: 300 GB
Processing VM-APP01
Warning
Warning: Retry was successful after initial failure
Backup completed but some files were skipped.""",
Processing VM-DB01
Success
Processing VM-WEB01
Success
Backup completed with warnings.""",
},
{
"from_address": "nakivo@test.local",
"subject": "Job 'Production Backup' finished with warnings",
"body": """NAKIVO Backup & Replication
"from_address": "veeam@test.local",
"subject": 'Veeam Backup Job "Test-Backup-Job" finished with WARNING',
"body": """Backup job: Test-Backup-Job
Job: Production Backup
Status: Warning
Started: 2026-02-09 03:00:00
Completed: 2026-02-09 04:00:00
Size: 250 GB
Session details:
Start time: 2026-02-07 01:00:00
End time: 2026-02-07 02:35:00
Total size: 140 GB
Duration: 01:35:00
Some backup objects were skipped.""",
Processing VM-APP01
Success
Processing VM-DB01
Success
Processing VM-WEB01
Warning
Warning: Some files were locked and skipped
Backup completed with warnings.""",
},
],
"error": [
{
"from_address": "veeam@test.local",
"subject": "Backup job 'Development Environment' failed",
"body": """Job name: Development Environment
Status: Failed
"subject": 'Veeam Backup Job "Test-Backup-Job" finished with Failed',
"body": """Backup job: Test-Backup-Job
Session details:
Start time: 2026-02-09 01:00:00
End time: 2026-02-09 01:15:00
Total size: 0 GB
Objects processed: 0
Duration: 00:15:00
Processing VM-APP01
Failed
Error: Cannot create snapshot: VSS error 0x800423f4
Processing VM-DB01
Success
Processing VM-WEB01
Success
Backup failed. Please check the logs for details.""",
},
{
"from_address": "synology@test.local",
"subject": "[Synology] Backup Task Archive Job failed",
"body": """Dear Administrator,
"from_address": "veeam@test.local",
"subject": 'Veeam Backup Job "Test-Backup-Job" finished with Failed',
"body": """Backup job: Test-Backup-Job
Backup task 'Archive Job' has failed.
Session details:
Start time: 2026-02-08 01:00:00
End time: 2026-02-08 01:10:00
Total size: 0 GB
Duration: 00:10:00
Task: Archive Job
Status: Failed
Start: 2026-02-09 02:00:00
Finish: 2026-02-09 02:05:00
Data transferred: 0 GB
Processing VM-APP01
Success
Backup failed. Please check the logs for details.""",
Processing VM-DB01
Failed
Error: Disk space exhausted on backup repository
Processing VM-WEB01
Success
Backup failed due to storage issue.""",
},
{
"from_address": "nakivo@test.local",
"subject": "Job 'Critical Servers' finished with errors",
"body": """NAKIVO Backup & Replication
"from_address": "veeam@test.local",
"subject": 'Veeam Backup Job "Test-Backup-Job" finished with Failed',
"body": """Backup job: Test-Backup-Job
Job: Critical Servers
Status: Failed
Started: 2026-02-09 03:00:00
Completed: 2026-02-09 03:10:00
Size: 0 GB
Session details:
Start time: 2026-02-07 01:00:00
End time: 2026-02-07 01:05:00
Total size: 0 GB
Duration: 00:05:00
Some backup objects failed to process.""",
Processing VM-APP01
Success
Processing VM-DB01
Success
Processing VM-WEB01
Failed
Error: Network connection lost to ESXi host
Backup failed. Network issue detected.""",
},
],
}

View File

@ -7,7 +7,7 @@ This file documents all changes made to this project via Claude Code.
### Added
- Added "Cleanup orphaned jobs" maintenance option in Settings → Maintenance to delete jobs without valid customer links and their associated emails/runs permanently from database (useful when customers are removed)
- Added "Preview orphaned jobs" button to show detailed list of jobs to be deleted with run/email counts before confirming deletion (verification step for safety)
- Added "Generate test emails" feature in Settings → Maintenance with three separate buttons to create fixed test email sets (success/warning/error) in inbox for testing parsers and maintenance operations (each set contains exactly 3 emails simulating Veeam, Synology, and NAKIVO backup notifications with consistent data for reproducible testing)
- Added "Generate test emails" feature in Settings → Maintenance with three separate buttons to create fixed test email sets (success/warning/error) in inbox for testing parsers and maintenance operations (each set contains exactly 3 Veeam Backup Job emails with the same job name "Test-Backup-Job" and different dates/objects/statuses for reproducible testing and proper status flow testing)
### Changed
- Removed customer name from Autotask ticket title to keep titles concise (format changed from "[Backupchecks] Customer - Job Name - Status" to "[Backupchecks] Job Name - Status")