diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 00000000..a389f755 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,22 @@ +exclude_paths: + - src/modules + - src/module_utils + - .github + +skip_list: + - no-handler + - key-order[task] + - key-order[play] + - name[casing] + - no-changed-when + - role-name + - var-naming + - yaml[braces] + - yaml[colons] + - yaml[commas] + - yaml[indentation] + - yaml[line-length] + - yaml[octal-values] + - name[template] + - command-instead-of-shell + - jinja[spacing] diff --git a/.github/ISSUE_TEMPLATE/backlog.md b/.github/ISSUE_TEMPLATE/backlog.md new file mode 100644 index 00000000..072398f8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/backlog.md @@ -0,0 +1,52 @@ +--- +name: Backlog Item +about: Log and track pending tasks, improvements, and enhancements +title: '' +labels: backlog, enhancement, bug, feature +assignees: '' + +--- + +## Overview + +Provide a concise summary of the issue or enhancement. + +--- + +## Problem Statement + +A clear, detailed description of the problem. Include: + +- What is happening? +- What is the expected behavior? +- Any error messages or traces. + +--- + +## Proposed Enhancement + +Detail the required changes or improvements to resolve the problem. Include: + +- Steps to implement the enhancement. +- Any references or research documents. +- Impact analysis if applicable. + +--- + +## Item Type + +Please select the type of item by marking the appropriate checkbox: + +- [ ] Backlog +- [ ] Enhancement +- [ ] Bug +- [ ] Feature + +--- + +## Acceptance Criteria + +Define the conditions that must be met for this item to be considered complete: + +- Criteria 1 +- Criteria 2 diff --git a/.github/ISSUE_TEMPLATE/issue.md b/.github/ISSUE_TEMPLATE/issue.md new file mode 100644 index 00000000..ec72f6ee --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue.md @@ -0,0 +1,45 @@ +--- +name: Issue +about: Create a report or discussion item for any issue or thought related to the project. Consider using the Backlog Item template for tracking bugs, tasks, improvements, and enhancements. +title: '' +labels: '' +assignees: '' + +--- + +## Overview + +Provide a brief summary of the issue or discussion point. + +--- + +## Description + +Explain the issue or subject in detail. Include relevant background information and context. + +--- + +## Steps to Reproduce (if applicable) + +Provide a clear, step-by-step list of instructions to reproduce the issue: + +1. Step one +2. Step two +3. Step three + +--- + +## Environment + +List details about your setup (e.g., operating system, version, browser, etc.): + +- OS: +- Version: +- Additional details: +- Test Type + +--- + +## Additional Context + +Include any extra information, such as logs, screenshots, or links that might help in understanding or resolving the issue. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..61b2e47d --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,42 @@ +# Description + + +## Problem Statement + + +## Solution Details + +- [ ] Implementation changes +- [ ] Configuration updates +- [ ] Documentation updates + +## Testing + +### Test Environment + +- OS: +- SAP Version: +- Database Type: + +### Test Cases + +- [ ] Unit tests added/updated +- [ ] Manual Testing done + +## Checklist + +- [ ] Code follows project style guidelines +- [ ] Documentation has been updated +- [ ] Tests are passing +- [ ] PR title follows conventional commit format +- [ ] Breaking changes are clearly marked + +## Dependencies + +- Depends on: #issue_number + +## Screenshots/Logs + + +## Additional Notes + \ No newline at end of file diff --git a/.github/workflows/github-actions-ansible-lint.yml b/.github/workflows/github-actions-ansible-lint.yml new file mode 100644 index 00000000..e522d2ea --- /dev/null +++ b/.github/workflows/github-actions-ansible-lint.yml @@ -0,0 +1,49 @@ + +name: Pull Request - Ansible Lint and Code Coverage +on: [push, pull_request] +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 + with: + egress-policy: audit + + - name: Checkout the code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 + + - name: Setup Python + uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 #v5.4.0 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Install Ansible Collections + run: | + ansible-galaxy collection install ansible.windows --force + ansible-galaxy collection install ansible.posix --force + ansible-galaxy collection install ansible.utils --force + ansible-galaxy collection install ansible.netcommon:5.1.2 --force + ansible-galaxy collection install community.windows --force + ansible-galaxy collection install community.general --force + ansible-galaxy collection install microsoft.ad --force + + - name: Run ansible-lint + run: | + ansible-lint src/ -c .ansible-lint + + # - name: Run pytest with coverage + # run: | + # pytest --cov=src/ --cov-report=xml tests/ + + - name: Check code formatting with black + run: | + black --check src/ --config pyproject.toml diff --git a/.gitignore b/.gitignore index 8a30d258..cf4800cd 100644 --- a/.gitignore +++ b/.gitignore @@ -396,3 +396,13 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml + + +# Python virtual environment +.venv +.vscode + +# System configuration files +WORKSPACES/* +.ppk +VMWPASSWORD diff --git a/README.md b/README.md index 5cd7cecf..70626124 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,62 @@ -# Project +# SAP Testing Automation Framework -> This repo has been populated by an initial template to help get you started. Please -> make sure to update the content to build a great experience for community-building. +## Overview -As the maintainer of this project, please make a few updates: +The SAP Testing Automation Framework is a automation solution designed to validate the configuration and performance of SAP systems on Azure under a wide array of scenarios. This framework not only streamlines the testing of SAP environments but also brings confidence and assurance by simulating real-world conditions. -- Improving this README.MD file to provide a great experience -- Updating SUPPORT.MD with content about this project's support experience -- Understanding the security reporting process in SECURITY.MD -- Remove this section from the README +Currently, the framework offers test scenarios focusing on high availability functional testing and configuration checks. Under the high availability category, we address critical components including: + +- **SAP HANA Database HA Configurations:** Validate SAP HANA database configurations, ensuring resilience, rapid failover, and optimal performance even in adverse conditions. +- **SAP Central Services (SCS/ERS) HA Setups:** Test and verify the configuration integrity and robustness of SAP Central Services, including load balancing, failover mechanisms, and component interoperability. + +By integrating comprehensive monitoring, detailed logging, and automated evaluation, our framework transforms how organizations maintain and enhance the reliability of their SAP landscapes on Azure. + +### Purpose + +Testing is crucial for maintaining business continuity in SAP environments. This framework addresses several critical needs: + +**Risk Mitigation**: +The framework provides systematic testing of failure scenarios, helping organizations identify and address potential issues before they impact production systems. It simulates various failure modes, including node failures, network interruptions, and storage issues, ensuring that recovery mechanisms function as designed. + +**Compliance**: +Organizations must often demonstrate that their SAP systems meet specific availability requirements. This framework provides documented evidence of HA testing, including detailed logs and reports that can be used for audit purposes. It helps ensure that HA implementations align with organizational standards and regulatory requirements. + +**Quality Assurance**: +Through automated and consistent testing procedures, the framework helps maintain high quality standards across SAP infrastructure components. It validates that all HA mechanisms, including clustering software, storage replication, and application-level failover, work together seamlessly. + +**Automation**: +Manual testing of HA configurations is time-consuming and prone to human error. This framework automates the entire testing process, from setup to execution and reporting, significantly reducing the operational overhead of HA testing while improving accuracy and consistency. + +## Get Started + +There are two primary ways to get started with the SAP Testing Automated Framework. Choose the path that best fits your current environment and objectives: + +### [Integration with SAP Deployment Automation Framework (SDAF)](./docs/SDAF_INTEGRATION.md) + +If you already have [SDAF](https://github.com/Azure/sap-automation) environment set up, integrating the SAP Testing Automation Framework is a natural extension that allows you to leverage existing deployment pipelines and configurations. + +### [Getting Started with High Availability Testing (Standalone)](./docs/GETTING_STARTED.md) + +For users focused solely on validating SAP functionality and configurations, the standalone approach offers a streamlined process to test critical SAP components without the complexity of full deployment integration. + + +### [Architecture and Components](./docs/ARCHITECTURE.md) + +## License + +Copyright (c) Microsoft Corporation. +Licensed under the MIT License. + +## Support + +For support and questions, please: +1. Check existing issues +2. Create new issue if needed +3. Provide detailed information about the problem + +## Additional Resources +- [Azure SAP Documentation](https://docs.microsoft.com/azure/sap) +- [SAP on Azure: High Availability Guide](https://docs.microsoft.com/azure/sap/workloads/sap-high-availability-guide-start) ## Contributing diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..5c40f1e3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,58 @@ +[tool.black] +line_length = 100 + +[tool.pylint.main] +load-plugins = ["pylint.extensions.docparams"] + +[tool.pylint.basic] +argument-naming-style = "snake_case" +attr-naming-style = "snake_case" +bad-names = ["foo", "bar", "baz", "toto", "tutu", "tata"] +class-naming-style = "PascalCase" +docstring-min-length = 10 +function-naming-style = "snake_case" +variable-naming-style = "snake_case" + + +[tool.pylint.format] +max-line-length = 100 +max-module-lines = 1000 + +[tool.pylint."messages control"] +enable = [ + "C0116", + "C0115", + "C0114", + "C0301", + "E1101", + "W0611", +] +disable = [ + "W0702", # bare-except + "W0703", # broad-except + "W4901", # global-statement + "R0902", # too-many-instance-attributes + "R0903", # too-few-public-methods + "R1702", + "R0801", + "W0108" +] + +[tool.pylint.design] +max-args = 5 + +[tool.pylint.docs] +docstring-min-length = 10 + +[tool.pylint.variables] +init-import = false +dummy-variables-rgx = "_.*|dummy" + +[tool.pylint.refactoring] +max-nested-blocks = 3 + +[tool.pylint.errors] +enable = [ + "E1101", + "W0611", +] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..c6c7c651 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,75 @@ +ansible-compat==24.6.1 +ansible-core==2.17.1 +ansible-lint==24.6.1 +ansible-runner==2.4.0 +attrs==25.1.0 +azure-common==1.1.28 +azure-core==1.32.0 +azure-identity==1.17.1 +azure-kusto-data==4.5.1 +azure-kusto-ingest==4.5.1 +azure-mgmt-core==1.5.0 +azure-mgmt-network==28.1.0 +azure-storage-blob==12.24.1 +azure-storage-queue==12.12.0 +black==25.1.0 +bracex==2.5.post1 +certifi==2025.1.31 +cffi==1.17.1 +charset-normalizer==3.4.1 +click==8.1.8 +coverage==7.6.12 +cryptography==44.0.1 +exceptiongroup==1.2.2 +filelock==3.17.0 +idna==3.10 +ijson==3.3.0 +importlib_metadata==8.6.1 +iniconfig==2.0.0 +isodate==0.7.2 +Jinja2==3.1.5 +jsonschema==4.23.0 +jsonschema-specifications==2024.10.1 +lockfile==0.12.2 +markdown-it-py==3.0.0 +MarkupSafe==3.0.2 +mdurl==0.1.2 +msal==1.31.1 +msal-extensions==1.2.0 +mypy-extensions==1.0.0 +numpy==2.2.2 +packaging==24.2 +pandas==2.2.3 +pathspec==0.12.1 +pexpect==4.9.0 +platformdirs==4.3.6 +pluggy==1.5.0 +portalocker==2.10.1 +ptyprocess==0.7.0 +pycparser==2.22 +Pygments==2.19.1 +PyJWT==2.10.1 +pytest==8.3.4 +pytest-cov==6.0.0 +pytest-mock==3.14.0 +python-daemon==3.1.2 +python-dateutil==2.9.0.post0 +pytz==2025.1 +PyYAML==6.0.2 +referencing==0.36.2 +requests==2.32.3 +resolvelib==1.0.1 +rich==13.9.4 +rpds-py==0.22.3 +ruamel.yaml==0.18.10 +ruamel.yaml.clib==0.2.12 +six==1.17.0 +subprocess-tee==0.4.2 +tenacity==9.0.0 +tomli==2.2.1 +typing_extensions==4.12.2 +tzdata==2025.1 +urllib3==2.2.2 +wcmatch==10.0 +yamllint==1.35.1 +zipp==3.21.0 \ No newline at end of file diff --git a/src/ansible.cfg b/src/ansible.cfg new file mode 100644 index 00000000..28b92a00 --- /dev/null +++ b/src/ansible.cfg @@ -0,0 +1,25 @@ +# Ansible Configuration Files: +# http://docs.ansible.com/ansible/latest/reference_appendices/config.html +# https://github.com/ansible/ansible/blob/stable-2.9/examples/ansible.cfg +# https://github.com/fdavis/ansible-best-practices/blob/master/ansible.cfg + +[defaults] + +display_skipped_hosts = False +conditional_bare_variables = False +interpreter_python = auto_silent +callbacks_enabled = profile_tasks +stdout_callback = yaml +bin_ansible_callbacks = True +host_key_checking = False +error_on_undefined_vars = True +library=modules +module_utils=module_utils +allow_world_readable_tmpfiles = True + +[callback_log_plays] +log_folder = /var/tmp/ansible/hosts +log_path = /var/tmp/ansible/hosts + +[connection] +ssh_args=-C -o ControlMaster=auto -o ControlPersist=60s -o ServerAliveInterval=300 -o ControlPath=/tmp/ansible-ssh-%h-%p-%r diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b