Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

The SAP Testing Automation Framework is an open-source orchestration tool designed to validate SAP deployments on Microsoft Azure. It enables you to assess system configurations against SAP on Azure best practices and guidelines. Additionally, the framework facilitates automation for various testing scenarios, including High Availability (HA) functional testing.

> **NOTE**: This repository is currently in private preview and is intended for testing and feedback purposes. As this is an early release, it is not yet production-ready, and breaking changes can be introduced at any time.
## Supported Configuration Matrix

The following SAP components are supported in a two-node Pacemaker cluster running on SUSE Linux Enterprise Server (SLES) or Red Hat Enterprise Linux (RHEL):
Expand Down
4 changes: 2 additions & 2 deletions src/roles/ha_db_hana/tasks/fs-freeze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
changed_when: cleanup_failed_resource_post.rc == 0
ignore_errors: true

- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 1"
when: cluster_status_pre.AUTOMATED_REGISTER | lower == "true"
get_cluster_status_db:
operation_step: "test_execution"
Expand All @@ -67,7 +67,7 @@
- name: "Test Execution: Freeze File System on Primary Node init"
when: ansible_hostname == cluster_status_pre.primary_node
block:
- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 2"
get_cluster_status_db:
operation_step: "post_failover"
database_sid: "{{ db_sid | lower }}"
Expand Down
4 changes: 2 additions & 2 deletions src/roles/ha_db_hana/tasks/primary-crash-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
- name: "Test Execution: Validate HANA DB cluster status"
when: ansible_hostname == cluster_status_pre.secondary_node
block:
- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 1"
when: cluster_status_pre.AUTOMATED_REGISTER == "true"
get_cluster_status_db:
operation_step: "test_execution"
Expand Down Expand Up @@ -113,7 +113,7 @@
changed_when: cleanup_failed_resource_post.rc == 0
ignore_errors: true

- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 2"
get_cluster_status_db:
operation_step: "post_failover"
database_sid: "{{ db_sid | lower }}"
Expand Down
4 changes: 2 additions & 2 deletions src/roles/ha_db_hana/tasks/primary-echo-b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
- name: "Test Execution: Switch to secondary node"
when: ansible_hostname == cluster_status_pre.secondary_node
block:
- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 1"
when: cluster_status_pre.AUTOMATED_REGISTER == "true"
get_cluster_status_db:
operation_step: "test_execution"
Expand Down Expand Up @@ -100,7 +100,7 @@
changed_when: cleanup_failed_resource_post.rc == 0
ignore_errors: true

- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 2"
get_cluster_status_db:
operation_step: "post_failover"
database_sid: "{{ db_sid | lower }}"
Expand Down
4 changes: 2 additions & 2 deletions src/roles/ha_db_hana/tasks/primary-node-crash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
changed_when: hana_db_stop_results == 0
failed_when: hana_db_stop_results.rc != 0

- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 1"
get_cluster_status_db:
operation_step: "test_execution"
database_sid: "{{ db_sid | lower }}"
Expand Down Expand Up @@ -81,7 +81,7 @@
changed_when: cleanup_failed_resource_post.rc == 0
ignore_errors: true

- name: "Test execution: Validate HANA DB cluster status"
- name: "Test execution: Validate HANA DB cluster status 2"
get_cluster_status_db:
operation_step: "post_failover"
database_sid: "{{ db_sid | lower }}"
Expand Down
4 changes: 2 additions & 2 deletions src/roles/ha_db_hana/tasks/primary-node-kill.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
changed_when: hana_db_kill_results == 0
failed_when: hana_db_kill_results.rc != 0

- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 1"
when: cluster_status_pre.AUTOMATED_REGISTER == "true"
get_cluster_status_db:
operation_step: "test_execution"
Expand Down Expand Up @@ -98,7 +98,7 @@
changed_when: cleanup_failed_resource_post.rc == 0
ignore_errors: true

- name: "Test execution: Validate HANA DB cluster status"
- name: "Test execution: Validate HANA DB cluster status 2"
get_cluster_status_db:
operation_step: "post_failover"
database_sid: "{{ db_sid | lower }}"
Expand Down
4 changes: 2 additions & 2 deletions src/roles/ha_db_hana/tasks/resource-migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
failed_when: hana_db_resource_migration.rc != 0
changed_when: hana_db_resource_migration.rc == 0

- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 1"
get_cluster_status_db:
operation_step: "test_execution"
database_sid: "{{ db_sid | lower }}"
Expand Down Expand Up @@ -94,7 +94,7 @@
ansible.builtin.wait_for:
timeout: 100

- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 2"
get_cluster_status_db:
operation_step: "test_execution"
database_sid: "{{ db_sid | lower }}"
Expand Down
2 changes: 1 addition & 1 deletion src/roles/ha_db_hana/tasks/sbd-fencing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
- name: "Test Execution: SBD Inquisitor kill manual fail over"
when: ansible_hostname == cluster_status_pre.primary_node
block:
- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 2"
get_cluster_status_db:
operation_step: "test_execution"
database_sid: "{{ db_sid | lower }}"
Expand Down
2 changes: 1 addition & 1 deletion src/roles/ha_db_hana/tasks/secondary-crash-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
cluster_status_test_execution.primary_node == cluster_status_pre.primary_node and
cluster_status_test_execution.secondary_node == ""

- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 2"
get_cluster_status_db:
operation_step: "post_failover"
database_sid: "{{ db_sid | lower }}"
Expand Down
2 changes: 1 addition & 1 deletion src/roles/ha_db_hana/tasks/secondary-echo-b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
cluster_status_test_execution.primary_node == cluster_status_pre.primary_node and
cluster_status_test_execution.secondary_node == ""

- name: "Test Execution: Validate HANA DB cluster status"
- name: "Test Execution: Validate HANA DB cluster status 2"
get_cluster_status_db:
operation_step: "post_failover"
database_sid: "{{ db_sid | lower }}"
Expand Down
4 changes: 2 additions & 2 deletions src/roles/ha_db_hana/tasks/secondary-node-kill.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
- node_tier == "hana"
- pre_validations_status == "PASSED"
block:
- name: "Test Execution: Kill the secondary node."
- name: "Test Execution: Kill the secondary node"
when: ansible_hostname == cluster_status_pre.primary_node
block:
- name: "Test Execution: Start timer"
Expand Down Expand Up @@ -57,7 +57,7 @@
cluster_status_test_execution.primary_node == cluster_status_pre.primary_node and
cluster_status_test_execution.secondary_node == ""

- name: "Test execution: Validate HANA DB cluster status"
- name: "Test execution: Validate HANA DB cluster status 2"
get_cluster_status_db:
operation_step: "post_failover"
ansible_os_family: "{{ ansible_os_family | upper }}"
Expand Down
4 changes: 2 additions & 2 deletions src/roles/misc/tasks/post-validations-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
{{
(
hostvars[cluster_status_pre.primary_node]['var_log_messages_output'].filtered_logs
| default("")
| default([])
)
+
(
hostvars[cluster_status_pre.secondary_node]['var_log_messages_output'].filtered_logs
| default("")
| default([])
)
}}

Expand Down
4 changes: 2 additions & 2 deletions src/roles/misc/tasks/post-validations-scs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
{{
(
hostvars[cluster_status_pre.ascs_node]['var_log_messages_output'].filtered_logs
| default("")
| default([])
)
+
(
hostvars[cluster_status_pre.ers_node]['var_log_messages_output'].filtered_logs
| default("")
| default([])
)
}}

Expand Down
4 changes: 2 additions & 2 deletions src/roles/misc/tasks/rescue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
{{
(
hostvars[first_node]['var_log_messages_output'].filtered_logs
| default("")
| default([])
)
+
(
hostvars[second_node]['var_log_messages_output'].filtered_logs
| default("")
| default([])
)
}}

Expand Down
112 changes: 112 additions & 0 deletions tests/roles/ha_db_hana/az_lb_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

"""
Test class for Azure LB configuration validation tasks.

This test class uses pytest to run functional tests on the Azure LB configuration validation tasks
defined in roles/ha_db_hana/tasks/azure-lb.yml. It sets up a temporary test environment,
mocks necessary Python modules and commands, and verifies the execution of the tasks.
"""

import os
import shutil
from pathlib import Path
import pytest
from tests.roles.ha_db_hana.roles_testing_base_db import RolesTestingBaseDB


class TestAzLBConfigValidation(RolesTestingBaseDB):
"""
Test class for Azure LB configuration validation tasks.
"""

@pytest.fixture
def test_environment(self, ansible_inventory):
"""
Set up a temporary test environment for the Azure LB configuration validation tasks.

:param ansible_inventory: Path to the Ansible inventory file.
:type ansible_inventory: str
:yield temp_dir: Path to the temporary test environment.
:ytype: str
"""

temp_dir = self.setup_test_environment(
role_type="ha_db_hana",
ansible_inventory=ansible_inventory,
task_name="azure-lb",
task_description="The test validates the Azure load balancer configuration.",
module_names=[
"project/library/get_azure_lb",
"project/library/log_parser",
"project/library/send_telemetry_data",
"project/library/get_package_list",
"bin/crm_resource",
],
extra_vars_override={"node_tier": "hana"},
)

os.makedirs(f"{temp_dir}/project/roles/ha_db_hana/tasks/files", exist_ok=True)
self.file_operations(
operation="write",
file_path=f"{temp_dir}/project/roles/ha_db_hana/tasks/files/constants.yaml",
content=self.file_operations(
operation="read",
file_path=Path(__file__).parent.parent / "mock_data/mock_azure_lb.txt",
),
)

os.makedirs(f"{temp_dir}/project/library", exist_ok=True)
self.file_operations(
operation="write",
file_path=f"{temp_dir}/project/library/uri",
content=self.file_operations(
operation="read",
file_path=Path(__file__).parent.parent / "mock_data/azure_metadata.txt",
),
)
os.chmod(f"{temp_dir}/project/library/uri", 0o755)

yield temp_dir
shutil.rmtree(temp_dir)

def test_ha_config_validation_success(self, test_environment, ansible_inventory):
"""
Test the Azure LB configuration validation tasks using Ansible Runner.

:param test_environment: Path to the temporary test environment.
:type test_environment: str
:param ansible_inventory: Path to the Ansible inventory file.
:type ansible_inventory: str
"""
result = self.run_ansible_playbook(
test_environment=test_environment, inventory_file_name="inventory_db.txt"
)

assert result.rc == 0, (
f"Playbook failed with status: {result.rc}\n"
f"STDOUT: {result.stdout.read() if result.stdout else 'No output'}\n"
f"STDERR: {result.stderr.read() if result.stderr else 'No errors'}\n"
f"Events: {[e.get('event') for e in result.events if 'event' in e]}"
)

ok_events, failed_events = [], []
for event in result.events:
if event.get("event") == "runner_on_ok":
ok_events.append(event)
elif event.get("event") == "runner_on_failed":
failed_events.append(event)

assert len(ok_events) > 0
assert len(failed_events) == 0

for event in ok_events:
task = event.get("event_data", {}).get("task")
task_result = event.get("event_data", {}).get("res")
if "Retrieve Subscription ID" in task:
assert task_result.get("changed") is False
if "Azure Load Balancer check" in task:
assert task_result.get("changed") is False
assert task_result["details"]["parameters"][1].get("name") == "probe_threshold"
assert task_result["details"]["parameters"][1].get("value") == "2"
Loading
Loading