|
| 1 | +# Azure Backup Functional Testing for SAP HANA |
| 2 | + |
| 3 | +The SAP Testing Automation Framework includes an Azure Backup testing component that validates backup and restore operations for SAP HANA databases deployed on Azure. It exercises the [Azure Backup for SAP HANA](https://learn.microsoft.com/azure/backup/sap-hana-database-about) service through the Python SDK (`azure-mgmt-recoveryservicesbackup`) and native HANA recovery commands. |
| 4 | + |
| 5 | +## Supported Scenarios |
| 6 | + |
| 7 | +The framework supports both **HA (two-node cluster)** and **Non-HA (single-node)** HANA deployments. Five test cases cover the end-to-end backup-restore lifecycle: |
| 8 | + |
| 9 | +| # | Test Case | Task Name | Description | |
| 10 | +|---|-----------|-----------|-------------| |
| 11 | +| 1 | Azure Backup Setup Verification | `backup-setup-verification` | Discovers all protected HANA databases in the Recovery Services vault, verifies backup configuration health, and checks that recent restore points exist. | |
| 12 | +| 2 | Restore Backup to HANA DB | `restore-to-db` | Triggers a full or point-in-time restore to the original HANA database via Azure Backup, monitors the restore job, then validates HANA is running. | |
| 13 | +| 3 | Restore Backup to FileSystem | `restore-to-filesystem` | Restores the HANA backup as files to a filesystem path, verifies the files are present, then recovers the HANA DB from those files and validates it is operational. | |
| 14 | +| 4 | Recover DB using Database Commands | `recover-db-commands` | Tests native HANA recovery using `recoverSys.py` / `RECOVER DATA`. Queries the backup catalog, stops HANA, performs recovery, restarts, and validates consistency. | |
| 15 | +| 5 | Cross-VM Restore | `restore-cross-vm` | Restores a HANA backup from VM-1 to VM-2 (AlternateWorkloadRestore). Validates the target HANA instance starts and the database is consistent. Requires ≥ 2 HANA nodes. | |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +### 1. Azure Backup Configuration |
| 20 | + |
| 21 | +- A **Recovery Services vault** must exist with SAP HANA backup configured. |
| 22 | +- At least one HANA database must be **registered and protected** with a backup policy. |
| 23 | +- A recent backup (full or incremental) must have completed successfully so restore points are available. |
| 24 | + |
| 25 | +For setup guidance, see [Back up SAP HANA databases in Azure VMs](https://learn.microsoft.com/azure/backup/sap-hana-database-instances-backup). |
| 26 | + |
| 27 | +### 2. Managed Identity Permissions |
| 28 | + |
| 29 | +The management server's managed identity (system- or user-assigned) requires: |
| 30 | + |
| 31 | +| Role | Scope | Purpose | |
| 32 | +|------|-------|---------| |
| 33 | +| **Backup Operator** | Recovery Services vault | Discover protected items, list restore points, trigger restore operations, monitor restore jobs | |
| 34 | +| **Reader** | HANA VM resource group | Resolve target VM ARM IDs for cross-VM and filesystem restores | |
| 35 | + |
| 36 | +For identity setup, see [Setup Guide — Identity and Authorization](./SETUP.MD#4-identity-and-authorization). |
| 37 | + |
| 38 | +### 3. HANA Node Access |
| 39 | + |
| 40 | +- The management server must have SSH connectivity to all HANA DB hosts. |
| 41 | +- The `<sid>adm` user must be able to run `HDB stop`, `HDB start`, `sapcontrol`, and `hdbsql` commands. |
| 42 | +- For test case 3 (restore-to-filesystem), the target filesystem path must be writable. |
| 43 | +- For test case 5 (cross-VM restore), at least 2 HANA nodes must be in the inventory. |
| 44 | + |
| 45 | +## Configuration |
| 46 | + |
| 47 | +### 1. Update `vars.yaml` |
| 48 | + |
| 49 | +Set the test type to `AzureBackupDatabase`: |
| 50 | + |
| 51 | +```yaml |
| 52 | +TEST_TYPE: SAPFunctionalTests |
| 53 | +SAP_FUNCTIONAL_TEST_TYPE: AzureBackupDatabase |
| 54 | +``` |
| 55 | +
|
| 56 | +### 2. Configure Backup Parameters |
| 57 | +
|
| 58 | +Add the following variables to your system's `sap-parameters.yaml` file (under `WORKSPACES/SYSTEM/<SYSTEM_CONFIG_NAME>/`): |
| 59 | + |
| 60 | +```yaml |
| 61 | +# Required: Recovery Services vault resource ID |
| 62 | +backup_vault_resource_id: "/subscriptions/xxxx/resourceGroups/my-backup-rg/providers/Microsoft.RecoveryServices/vaults/my-rsv-vault" |
| 63 | +
|
| 64 | +# Required for restore test cases (2-5) |
| 65 | +backup_container_name: "VMAppContainer;Compute;my-rg;hanavm01" |
| 66 | +backup_item_name: "saphanadatabase;h05;systemdb" |
| 67 | +
|
| 68 | +# Required for filesystem restore (test case 3) |
| 69 | +backup_target_filesystem_path: "/hana/backup/restore" |
| 70 | +
|
| 71 | +# Required for cross-VM restore (test case 5) |
| 72 | +backup_target_container_name: "VMAppContainer;Compute;my-rg;hanavm02" |
| 73 | +backup_target_database_name: "SYSTEMDB" |
| 74 | +
|
| 75 | +# Optional: point-in-time restore (ISO 8601 UTC timestamp) |
| 76 | +backup_restore_point_time: "" |
| 77 | +``` |
| 78 | + |
| 79 | +### 3. User-Assigned Managed Identity (Optional) |
| 80 | + |
| 81 | +If your management server uses a user-assigned managed identity, set the client ID in `vars.yaml`: |
| 82 | + |
| 83 | +```yaml |
| 84 | +user_assigned_identity_client_id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" |
| 85 | +``` |
| 86 | + |
| 87 | +If omitted or set to `null`, the framework uses system-assigned managed identity. |
| 88 | + |
| 89 | +## Test Execution |
| 90 | + |
| 91 | +Run the tests using the `sap_automation_qa.sh` script: |
| 92 | + |
| 93 | +```bash |
| 94 | +# Run all Azure Backup test cases |
| 95 | +./scripts/sap_automation_qa.sh --test_groups=BACKUP_DB_HANA |
| 96 | +
|
| 97 | +# Run specific test cases |
| 98 | +./scripts/sap_automation_qa.sh --test_groups=BACKUP_DB_HANA --test_cases=[backup-setup-verification] |
| 99 | +./scripts/sap_automation_qa.sh --test_groups=BACKUP_DB_HANA --test_cases=[restore-to-db,restore-to-filesystem] |
| 100 | +./scripts/sap_automation_qa.sh --test_groups=BACKUP_DB_HANA --test_cases=[restore-cross-vm] |
| 101 | +
|
| 102 | +# Run with verbose output |
| 103 | +./scripts/sap_automation_qa.sh --test_groups=BACKUP_DB_HANA -vv |
| 104 | +``` |
| 105 | + |
| 106 | +### Via SAP QA Service API |
| 107 | + |
| 108 | +```bash |
| 109 | +# Create a job through the API |
| 110 | +./scripts/sap_automation_qa.sh job create --workspace DEV-WEEU-SAP01-X00 --test-group AzureBackupDatabase |
| 111 | +``` |
| 112 | + |
| 113 | +## Viewing Test Results |
| 114 | + |
| 115 | +Test results are generated the same way as HA tests. Navigate to your workspace directory: |
| 116 | + |
| 117 | +```bash |
| 118 | +cd WORKSPACES/SYSTEM/<SYSTEM_CONFIG_NAME>/quality_assurance/ |
| 119 | +``` |
| 120 | + |
| 121 | +The HTML report summarises each test case with PASS/FAIL/SKIPPED status. For details on the report format, see [High Availability — Viewing Test Results](./HIGH_AVAILABILITY.md#viewing-test-results). |
0 commit comments