From 45c56584836aa4e3d05968e131c7d19f26c8e6eb Mon Sep 17 00:00:00 2001 From: Than Ngo Date: Thu, 25 Jan 2024 18:20:37 +0100 Subject: [PATCH] - add tests and tools - fix bash and python shebangs Related: RHEL-16895 --- redhat.sap_install-1.3.4-add_tests.patch | 1690 ++++++++++++++++++++++ redhat.sap_install-1.3.4-add_tools.patch | 128 ++ rhel-system-roles-sap.spec | 19 +- 3 files changed, 1836 insertions(+), 1 deletion(-) create mode 100644 redhat.sap_install-1.3.4-add_tests.patch create mode 100644 redhat.sap_install-1.3.4-add_tools.patch diff --git a/redhat.sap_install-1.3.4-add_tests.patch b/redhat.sap_install-1.3.4-add_tests.patch new file mode 100644 index 0000000..68d021b --- /dev/null +++ b/redhat.sap_install-1.3.4-add_tests.patch @@ -0,0 +1,1690 @@ +commit a7cb39c723ddcce5e45b7e8f370137e4ae42b629 +Author: Than Ngo +Date: Wed Jan 24 20:41:25 2024 +0100 + + Add missing tests folders + + Signed-off-by: Than Ngo + +diff --git a/roles/sap_general_preconfigure/tests/.pylintrc b/roles/sap_general_preconfigure/tests/.pylintrc +new file mode 120000 +index 0000000..0d402e7 +--- /dev/null ++++ b/roles/sap_general_preconfigure/tests/.pylintrc +@@ -0,0 +1 @@ ++../../../.pylintrc +\ No newline at end of file +diff --git a/roles/sap_general_preconfigure/tests/beautify-assert-output.sh b/roles/sap_general_preconfigure/tests/beautify-assert-output.sh +new file mode 120000 +index 0000000..9a2e976 +--- /dev/null ++++ b/roles/sap_general_preconfigure/tests/beautify-assert-output.sh +@@ -0,0 +1 @@ ++../tools/beautify-assert-output.sh +\ No newline at end of file +diff --git a/roles/sap_general_preconfigure/tests/run-sap_general_preconfigure-tests.py b/roles/sap_general_preconfigure/tests/run-sap_general_preconfigure-tests.py +new file mode 100755 +index 0000000..b09ea85 +--- /dev/null ++++ b/roles/sap_general_preconfigure/tests/run-sap_general_preconfigure-tests.py +@@ -0,0 +1,199 @@ ++#!/usr/bin/env python ++ ++""" ++Tests for role sap_general_preconfigure ++""" ++ ++import os ++import sys ++import subprocess ++ ++# output field delimiter for displaying the results: ++# FIELD_DELIMITER = ';' ++FIELD_DELIMITER = '\t' ++ ++if len(sys.argv) == 1: ++ _managed_node = input("Provide name of managed node: ") ++else: ++ _managed_node = sys.argv[1] ++ ++print('Running tests for role sap_general_preconfigure...\n') ++print('Managed node: ' + _managed_node) ++ ++_mn_rhel_release = subprocess.getoutput( ++ "ssh root@" ++ + _managed_node ++ + " cat /etc/redhat-release | \ ++ awk 'BEGIN{FS=\"release \"}{split($2, a, \" \"); print a[1]}'") ++print('Managed node Red Hat release: ' + _mn_rhel_release) ++_mn_hw_arch = subprocess.getoutput("ssh root@" + _managed_node + " uname -m") ++print('Managed node HW architecture: ' + _mn_hw_arch) ++ ++__tests = [ ++ { ++ 'number': '1', ++ 'name': 'Run in check mode on new system.', ++ 'command_line_parameter': '--check ', ++ 'ignore_error_final': True, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_general_preconfigure_fail_if_reboot_required': False, ++ } ++ ] ++ }, ++ { ++ 'number': '2', ++ 'name': 'Run in assert mode on new system, \ ++ check for enabled repos and for minor release lock, \ ++ check for possible RHEL update, \ ++ ignore assert errors.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': False, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_general_preconfigure_assert': True, ++ 'sap_general_preconfigure_assert_ignore_errors': True, ++ 'sap_general_preconfigure_update': True, ++ 'sap_general_preconfigure_enable_repos': True, ++ 'sap_general_preconfigure_set_minor_release': True, ++ } ++ ] ++ }, ++ { ++ 'number': '3', ++ 'name': 'Run in normal mode on new system, \ ++ enable repos and set minor release lock, \ ++ check for possible RHEL update, \ ++ set SELinux to permisive, \ ++ allow a reboot.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': False, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_general_preconfigure_update': True, ++ 'sap_general_preconfigure_enable_repos': True, ++ 'sap_general_preconfigure_set_minor_release': True, ++ 'sap_general_preconfigure_selinux_state': 'permissive', ++ 'sap_general_preconfigure_reboot_ok': True, ++ } ++ ] ++ }, ++ { ++ 'number': '4', ++ 'name': 'Idempotency check: Run in normal mode on modified system, \ ++ enable repos and set minor release lock, \ ++ check for possible RHEL update, \ ++ set SELinux to permisive, \ ++ allow a reboot.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': False, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_general_preconfigure_update': True, ++ 'sap_general_preconfigure_enable_repos': True, ++ 'sap_general_preconfigure_set_minor_release': True, ++ 'sap_general_preconfigure_selinux_state': 'permissive', ++ 'sap_general_preconfigure_reboot_ok': True, ++ } ++ ] ++ }, ++ { ++ 'number': '5', ++ 'name': 'Run in assert mode on modified system, \ ++ check for repos and for the RHEL minor release lock, \ ++ check for possible RHEL update, \ ++ check if SELinux is permisive, \ ++ ignore any assert error.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': False, ++ 'compact_assert_output': True, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_general_preconfigure_assert': True, ++ 'sap_general_preconfigure_assert_ignore_errors': True, ++ 'sap_general_preconfigure_update': True, ++ 'sap_general_preconfigure_enable_repos': True, ++ 'sap_general_preconfigure_set_minor_release': True, ++ 'sap_general_preconfigure_selinux_state': 'permissive', ++ } ++ ] ++ }, ++ { ++ 'number': '6', ++ 'name': 'Run in check mode on modified system.', ++ 'command_line_parameter': '--check ', ++ 'ignore_error_final': True, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [] ++ }, ++] ++ ++for par1 in __tests: ++ print('\n' + 'Test ' + par1['number'] + ': ' + par1['name']) ++ command = ( ++ 'ansible-playbook sap_general_preconfigure-default-settings.yml ' ++ + par1['command_line_parameter'] ++ + '-l ' ++ + _managed_node ++ + ' ' ++ + '-e "' ++ ) ++ for par2 in par1['role_vars']: ++ command += str(par2) ++ command += '"' ++ if par1['compact_assert_output']: ++ command += ' | ./beautify-assert-output.sh' ++ print("command: " + command) ++ _py_rc = os.system(command) ++ par1['rc'] = str(int(_py_rc / 256)) ++ if _py_rc != 0: ++ if par1['ignore_error_final']: ++ print('Test ' ++ + par1['number'] ++ + ' finished with return code ' ++ + par1['rc'] + '. Continuing with the next test') ++ else: ++ print('Test ' ++ + par1['number'] ++ + ' finished with return code ' ++ + par1['rc'] + '.') ++ sys.exit(_py_rc) ++ else: ++ print('Test ' + par1['number'] + ' finished with return code ' + par1['rc'] + '.') ++ ++print('\nResults for role sap_general_preconfigure: ' ++ + _managed_node ++ + ' - RHEL ' ++ + _mn_rhel_release ++ + ' - ' ++ + _mn_hw_arch + ':') ++ ++print('\n#' ++ + FIELD_DELIMITER ++ + 'RC' + FIELD_DELIMITER ++ + 'name' + FIELD_DELIMITER ++ + 'argument' + FIELD_DELIMITER ++ + 'compact' + FIELD_DELIMITER ++ + 'role_vars') ++ ++for par1 in __tests: ++ print(par1['number'] + FIELD_DELIMITER ++ + par1['rc'] + FIELD_DELIMITER ++ + par1['name'] + FIELD_DELIMITER ++ + par1['command_line_parameter'] + FIELD_DELIMITER ++ + str(par1['compact_assert_output']) + FIELD_DELIMITER, end='') ++ if len(par1['role_vars']) == 0: ++ print("") ++ else: ++ for par2 in par1['role_vars']: ++ print(str(par2)) +diff --git a/roles/sap_general_preconfigure/tests/sap_general_preconfigure-default-settings.yml b/roles/sap_general_preconfigure/tests/sap_general_preconfigure-default-settings.yml +new file mode 100644 +index 0000000..a3c320b +--- /dev/null ++++ b/roles/sap_general_preconfigure/tests/sap_general_preconfigure-default-settings.yml +@@ -0,0 +1,6 @@ ++--- ++- hosts: all ++ collections: ++ - community.sap_install ++ roles: ++ - sap_general_preconfigure +diff --git a/roles/sap_hana_install/tests/README.md b/roles/sap_hana_install/tests/README.md +new file mode 100644 +index 0000000..ef2af5b +--- /dev/null ++++ b/roles/sap_hana_install/tests/README.md +@@ -0,0 +1,4 @@ ++# sap_hana_install testing ++ ++The tests in the subdirectories are designed for quality assurance processes. These files might be used for demonstration ++purposes as well, however it is recommended to use the sample files in directory `playbooks` in the root of the Ansible Collection. +diff --git a/roles/sap_hana_install/tests/install/README.md b/roles/sap_hana_install/tests/install/README.md +new file mode 100644 +index 0000000..7a344c4 +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/README.md +@@ -0,0 +1,55 @@ ++# sap_hana_install Installation testing ++ ++Installation testing is done by running: ++`# run-sap_hana_install-install-tests.py ` ++where `managed_node` is the hostname of the host on which SAP HANA installation testing will take place, ++and `username` is the name of a user for accessing the managed node. Some basic information is retrieved ++from the managed node via `ssh`, for which we need a user name. ++ ++The following steps have to be performed to prepare the tests: ++- The files mentioned in the tasks `Copy ... to software directory` (e.g. `SAPCAR_1115-70006178.EXE`), ++ as well as their sha256 checksum files (e.g. `SAPCAR_1115-70006178.EXE.sha256`), need to be available ++ in the directory specified by variable `sap_hana_install_software_directory` in file ++ `install-vars.yml`, e.g. `/software/sap_hana_install_test`. ++- You can either download or copy these files manually or via Ansible with yml file ++ `prepare-install-tests-x86_64.yml` or `prepare-install-tests-ppc64le.yml`. ++ In that case, the required files need to be in a directory specified by variable `software_host_directory`, ++ followed by the output of `uname -m` (e.g. `/software/hana_store/x86_64`), on a server ++ specified by variable `software_host`. ++ ++For a SAP HANA scale-out test, the server(s) specified by variable `sap_hana_install_addhosts` in file ++`run-install-test-03.yml` (e.g. `node02`) need(s) to have the following file systems mounted from the node on ++which the test is run: ++- `/hana/data` ++- `/hana/log` ++- `/hana/shared` ++ ++Note: There should be no group named `sapsys` in file `/etc/group` on any of the test system(s), or if ++there is one, its group id should match the value of `sap_hana_install_groupid` (default `79`) in file ++install-vars.yml. ++ ++Each test cycle is running the following steps: ++- `ansible-playbook prepare-install-test-NN.yml -l managed_node` ++- `ansible-playbook run-install-test-NN.yml [...] -l managed_node -e [...]` ++- `ansible-playbook hana-uninstall.yml -l managed_node` ++ ++All screen outputs are saved in a newly created directory with the following name pattern: ++`hana-install-test-logs-` + rhel_release + `_` + hardware_architecture + `_` + date_time_string ++ ++Example: ++`hana-install-test-logs-8.4_x86_64_2022-03-06_23:29:34` ++ ++For each of the tests, there will be three output files in the log directory (shown with ++example file names for the directory mentioned above): ++- `hana-install-test-2022-03-06_23:29:34-prepare-01.log` ++- `hana-install-test-2022-03-06_23:29:34-run-01.log` ++- `hana-install-test-2022-03-06_23:29:34-uninstall-01.log` ++ ++and an additional file name at the end of all tests, named ++- `hana-install-test-2022-03-06_23:29:34-result.log` ++ ++If the return code of a test is `0`, the test has succeeded. If it is not `0` (default is `99`), ++the test has failed. ++ ++A test succeeds if the string specified in variable `expected_output_string` for each test is found ++in the output of the test run. +diff --git a/roles/sap_hana_install/tests/install/hana-uninstall.yml b/roles/sap_hana_install/tests/install/hana-uninstall.yml +new file mode 100644 +index 0000000..d5b0bbb +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/hana-uninstall.yml +@@ -0,0 +1,19 @@ ++--- ++ ++- hosts: all ++ become: true ++ vars_files: ++ - install-vars.yml ++ ++ tasks: ++ - name: "Uninstalling SAP HANA installation '{{ sap_hana_install_sid }}' after 5 seconds" ++ pause: ++ seconds: 5 ++ ++ - name: "Force uninstall SAP HANA '{{ sap_hana_install_sid }}' on '{{ ansible_hostname }}'" ++ shell: "{{ sap_hana_install_install_path }}/{{ sap_hana_install_sid }}/hdblcm/hdblcm --uninstall --components=all -b" ++ register: shell_output ++ ++ - name: Display the hdbuninst output ++ debug: ++ var: shell_output +diff --git a/roles/sap_hana_install/tests/install/install-vars.yml b/roles/sap_hana_install/tests/install/install-vars.yml +new file mode 100644 +index 0000000..080c174 +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/install-vars.yml +@@ -0,0 +1,14 @@ ++--- ++ ++sap_hana_install_new_system: true ++sap_hana_install_software_directory: '/software/sap_hana_install_test' ++sap_hana_install_software_extract_directory: '/software/sap_hana_install_test/extracted' ++sap_hana_install_install_path: '/hana/shared' ++sap_hana_install_sid: 'T01' ++sap_hana_install_number: '01' ++sap_hana_install_master_password: 'NewPass$321' ++sap_hana_install_userid: 950 ++sap_hana_install_groupid: 79 ++sap_hana_install_env_type: 'production' ++sap_hana_install_mem_restrict: 'y' ++sap_hana_install_max_mem: 36000 +diff --git a/roles/sap_hana_install/tests/install/prepare-install-test-01.yml b/roles/sap_hana_install/tests/install/prepare-install-test-01.yml +new file mode 100644 +index 0000000..fd92728 +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/prepare-install-test-01.yml +@@ -0,0 +1,14 @@ ++--- ++ ++- name: ++ hosts: all ++ become: true ++ vars_files: ++ - install-vars.yml ++ gather_facts: false ++ ++ tasks: ++ - name: Prepare test 01 - Remove Software extraction directory ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_extract_directory }}" ++ state: absent +diff --git a/roles/sap_hana_install/tests/install/prepare-install-test-02.yml b/roles/sap_hana_install/tests/install/prepare-install-test-02.yml +new file mode 100644 +index 0000000..eaf463d +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/prepare-install-test-02.yml +@@ -0,0 +1,14 @@ ++--- ++ ++- name: ++ hosts: all ++ become: true ++ vars_files: ++ - install-vars.yml ++ gather_facts: false ++ ++ tasks: ++ - name: Prepare test 02 - Remove Software extraction directory ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_extract_directory }}" ++ state: absent +diff --git a/roles/sap_hana_install/tests/install/prepare-install-test-03.yml b/roles/sap_hana_install/tests/install/prepare-install-test-03.yml +new file mode 100644 +index 0000000..eaf463d +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/prepare-install-test-03.yml +@@ -0,0 +1,14 @@ ++--- ++ ++- name: ++ hosts: all ++ become: true ++ vars_files: ++ - install-vars.yml ++ gather_facts: false ++ ++ tasks: ++ - name: Prepare test 02 - Remove Software extraction directory ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_extract_directory }}" ++ state: absent +diff --git a/roles/sap_hana_install/tests/install/prepare-install-tests-ppc64le.yml b/roles/sap_hana_install/tests/install/prepare-install-tests-ppc64le.yml +new file mode 100644 +index 0000000..4204079 +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/prepare-install-tests-ppc64le.yml +@@ -0,0 +1,35 @@ ++--- ++ ++- name: ++ hosts: all ++ become: true ++ vars_files: ++ - install-vars.yml ++ vars: ++ software_host: hostname ++ software_host_user: username ++ software_host_directory: /software/hana_store ++ gather_facts: false ++ ++ tasks: ++ - name: Remove '{{ sap_hana_install_software_directory }}' ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_directory }}/" ++ state: absent ++ ++ - name: Create '{{ sap_hana_install_software_directory }}' ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_directory }}" ++ state: directory ++ owner: root ++ group: root ++ mode: '0755' ++ ++ - name: Copy SAPCAR to software directory ++ ansible.builtin.shell: "scp {{ software_host_user }}@{{ software_host }}:{{ software_host_directory }}/ppc64le/SAPCAR_1115-70006238.EXE* {{ sap_hana_install_software_directory }}/" ++ ++ - name: Copy HANA rev 59.01 to software directory ++ ansible.builtin.shell: "scp {{ software_host_user }}@{{ software_host }}:{{ software_host_directory }}/ppc64le/IMDB_SERVER20_059_1-80002046.SAR* {{ sap_hana_install_software_directory }}/" ++ ++ - name: Copy SAP Hostagent to software directory ++ ansible.builtin.shell: "scp {{ software_host_user }}@{{ software_host }}:{{ software_host_directory }}/ppc64le/SAPHOSTAGENT55_55-80004831.SAR* {{ sap_hana_install_software_directory }}/" +diff --git a/roles/sap_hana_install/tests/install/prepare-install-tests-x86_64.yml b/roles/sap_hana_install/tests/install/prepare-install-tests-x86_64.yml +new file mode 100644 +index 0000000..0e5c111 +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/prepare-install-tests-x86_64.yml +@@ -0,0 +1,35 @@ ++--- ++ ++- name: ++ hosts: all ++ become: true ++ vars_files: ++ - install-vars.yml ++ vars: ++ software_host: hostname ++ software_host_user: username ++ software_host_directory: /software/hana_store ++ gather_facts: false ++ ++ tasks: ++ - name: Remove '{{ sap_hana_install_software_directory }}' ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_directory }}/" ++ state: absent ++ ++ - name: Create '{{ sap_hana_install_software_directory }}' ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_directory }}" ++ state: directory ++ owner: root ++ group: root ++ mode: '0755' ++ ++ - name: Copy SAPCAR to software directory ++ ansible.builtin.shell: "scp {{ software_host_user }}@{{ software_host }}:{{ software_host_directory }}/x86_64/SAPCAR_1115-70006178.EXE* {{ sap_hana_install_software_directory }}/" ++ ++ - name: Copy HANA rev 59.01 to software directory ++ ansible.builtin.shell: "scp {{ software_host_user }}@{{ software_host }}:{{ software_host_directory }}/x86_64/IMDB_SERVER20_059_1-80002031.SAR* {{ sap_hana_install_software_directory }}/" ++ ++ - name: Copy SAP Hostagent to software directory ++ ansible.builtin.shell: "scp {{ software_host_user }}@{{ software_host }}:{{ software_host_directory }}/x86_64/SAPHOSTAGENT55_55-80004822.SAR* {{ sap_hana_install_software_directory }}/" +diff --git a/roles/sap_hana_install/tests/install/remove-all-firewall-ports.yml b/roles/sap_hana_install/tests/install/remove-all-firewall-ports.yml +new file mode 100644 +index 0000000..7e958b5 +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/remove-all-firewall-ports.yml +@@ -0,0 +1,67 @@ ++--- ++ ++- name: Remove all defined firewall ports as per field 'ports' in 'firewall-cmd --list-all' ++ hosts: all ++ become: true ++ vars_files: ++ - install-vars.yml ++ gather_facts: false ++ ++ tasks: ++ - name: Get the defined current firewall ports before removal ++ shell: | ++ firewall-cmd --list-all | awk '/ ports: /{gsub (" ports: ", ""); print}' ++ register: __register_firewall_ports_current_before_removal ++ ++ - name: Display the defined current firewall ports before removal ++ debug: ++ var: __register_firewall_ports_current_before_removal.stdout ++ ++ - name: Remove all defined current ports in the default zone ++ shell: | ++ firewall-cmd --list-all | \ ++ awk '/ ports: /{gsub (" ports: ", ""); if (length($0)!=0)print}' | \ ++ awk 'BEGIN{RS=" "}{printf ("--remove-port=%s\n", $0)}' | \ ++ eval $(awk 'BEGIN{printf("firewall-cmd ")}{printf ("%s ", $0)}END{print("")}') ++ register: __register_firewall_remove_ports_current ++ when: __register_firewall_ports_current_before_removal.stdout | length > 0 ++ ++ - name: Get the defined current firewall ports after removal ++ shell: | ++ firewall-cmd --list-all | awk '/ ports: /{gsub (" ports: ", ""); print}' ++ register: __register_firewall_ports_current_after_removal ++ when: __register_firewall_ports_current_before_removal.stdout | length > 0 ++ ++ - name: Display the defined current firewall ports after removal ++ debug: ++ var: __register_firewall_ports_current_after_removal.stdout ++ when: __register_firewall_ports_current_before_removal.stdout | length > 0 ++ ++ - name: Get the defined permanent firewall ports before removal ++ shell: | ++ firewall-cmd --list-all --permanent | awk '/ ports: /{gsub (" ports: ", ""); print}' ++ register: __register_firewall_ports_permanent_before_removal ++ ++ - name: Display the defined current firewall ports before removal ++ debug: ++ var: __register_firewall_ports_permanent_before_removal.stdout ++ ++ - name: Remove all defined permanent ports in the default zone ++ shell: | ++ firewall-cmd --list-all --permanent | \ ++ awk '/ ports: /{gsub (" ports: ", ""); if (length($0)!=0)print}' | \ ++ awk 'BEGIN{RS=" "}{printf ("--remove-port=%s\n", $0)}' | \ ++ eval $(awk 'BEGIN{printf("firewall-cmd --permanent ")}{printf ("%s ", $0)}END{print("")}') ++ register: __register_firewall_remove_ports_permanent ++ when: __register_firewall_ports_permanent_before_removal.stdout | length > 0 ++ ++ - name: Get the defined permanent firewall ports after removal ++ shell: | ++ firewall-cmd --list-all --permanent | awk '/ ports: /{gsub (" ports: ", ""); print}' ++ register: __register_firewall_ports_permanent_after_removal ++ when: __register_firewall_ports_current_before_removal.stdout | length > 0 ++ ++ - name: Display the defined current firewall ports after removal ++ debug: ++ var: __register_firewall_ports_permanent_after_removal.stdout ++ when: __register_firewall_ports_current_before_removal.stdout | length > 0 +diff --git a/roles/sap_hana_install/tests/install/run-install-test-01.yml b/roles/sap_hana_install/tests/install/run-install-test-01.yml +new file mode 100644 +index 0000000..a5ab136 +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/run-install-test-01.yml +@@ -0,0 +1,11 @@ ++--- ++ ++- name: test ++ hosts: all ++ collections: ++ - community.sap_install ++ become: true ++ vars_files: ++ - install-vars.yml ++ roles: ++ - sap_hana_install +diff --git a/roles/sap_hana_install/tests/install/run-install-test-02.yml b/roles/sap_hana_install/tests/install/run-install-test-02.yml +new file mode 100644 +index 0000000..a5ab136 +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/run-install-test-02.yml +@@ -0,0 +1,11 @@ ++--- ++ ++- name: test ++ hosts: all ++ collections: ++ - community.sap_install ++ become: true ++ vars_files: ++ - install-vars.yml ++ roles: ++ - sap_hana_install +diff --git a/roles/sap_hana_install/tests/install/run-install-test-03.yml b/roles/sap_hana_install/tests/install/run-install-test-03.yml +new file mode 100644 +index 0000000..ad91b88 +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/run-install-test-03.yml +@@ -0,0 +1,13 @@ ++--- ++ ++- name: test ++ hosts: all ++ collections: ++ - community.sap_install ++ become: true ++ vars_files: ++ - install-vars.yml ++ vars: ++ sap_hana_install_addhosts: 'node02' ++ roles: ++ - sap_hana_install +diff --git a/roles/sap_hana_install/tests/install/run-sap_hana_install-install-tests.py b/roles/sap_hana_install/tests/install/run-sap_hana_install-install-tests.py +new file mode 100755 +index 0000000..fbf422e +--- /dev/null ++++ b/roles/sap_hana_install/tests/install/run-sap_hana_install-install-tests.py +@@ -0,0 +1,191 @@ ++#!/usr/bin/env python ++ ++import os ++import sys ++import datetime ++import subprocess ++import re ++import shlex ++import yaml ++ ++ ++def print_log(text): ++ sys.stdout.write(str(text)) ++ __filedescriptor.write(str(text)) ++ ++ ++# output field delimiter for displaying the results: ++__field_delimiter = '\t' ++ ++if(len(sys.argv) != 3): ++ print('Please provide the name of the managed node and the user name for logging in.') ++ __managed_node = input('Name of managed node: ') ++ __username = input('User name for connecting to managed node: ') ++else: ++ __managed_node = sys.argv[1] ++ __username = sys.argv[2] ++ ++__datestr = datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S') ++__logfile_prefix = 'hana-install-test-' ++ ++print('Running HANA install tests for role sap_hana_install...\n') ++print('Managed node: ' + __managed_node) ++print('Username: ' + __username) ++ ++with open("install-vars.yml", 'r') as __filedescriptor: ++ __yml_data = yaml.safe_load(__filedescriptor) ++ ++print(__yml_data) ++# print('sap_hana_install_sapcar_filename: ' + __yml_data.get('sap_hana_install_sapcar_filename')) ++# print('sap_hana_install_sarfiles: ' + str(__yml_data.get('sap_hana_install_sarfiles')[0])) ++# print('sap_hana_install_sarfiles: ' + str(__yml_data.get('sap_hana_install_sarfiles')[1])) ++ ++# input('Press RETURN to continue: ') ++ ++__mn_rhel_release = subprocess.getoutput( ++ "ssh " ++ + __username ++ + "@" ++ + __managed_node ++ + " cat /etc/redhat-release | \ ++ awk 'BEGIN{FS=\"release \"}{split($2, a, \" \"); print a[1]}'") ++__mn_hw_arch = subprocess.getoutput("ssh " + __username + "@" + __managed_node + " uname -m") ++print('Managed node Red Hat release: ' + __mn_rhel_release) ++print('Managed node HW architecture: ' + __mn_hw_arch) ++ ++__logdir = 'hana-install-test-logs-' + __mn_rhel_release + '_' + __mn_hw_arch + '_' + __datestr ++print('Logdir: ' + __logdir) ++if not os.path.exists(__logdir): ++ os.mkdir(__logdir) ++ ++__tests = [ ++ { ++ 'number': '01', ++ 'name': 'install test, rev 59.01, default parameters', ++ 'command_line_parameter': '', ++ 'expected_output_string': 'SAP HANA deployment successfully completed:', ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ } ++ ] ++ }, ++ { ++ 'number': '02', ++ 'name': 'install test, rev 59.01, check installation, checksum and signature verification', ++ 'command_line_parameter': '', ++ 'expected_output_string': 'SAP HANA deployment successfully completed:', ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_install_check_installation': True, ++ 'sap_hana_install_verify_checksums': True, ++ 'sap_hana_install_verify_signature': True ++ } ++ ] ++ }, ++ { ++ 'number': '03', ++ 'name': 'install test, rev 59.01, scale-out', ++ 'command_line_parameter': '', ++ 'expected_output_string': 'SAP HANA deployment successfully completed:', ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ } ++ ] ++ }, ++] ++ ++# Loop over tests: ++for par1 in __tests[0:3]: ++ print('\n' + 'Test ' + par1['number'] + ': ' + par1['name']) ++# prepare the test: ++ command = ('ansible-playbook prepare-install-test-' ++ + par1['number'] ++ + '.yml ' ++ + '-l ' ++ + __managed_node) ++ args = shlex.split(command) ++# _py_rc = os.system(command) ++ __logfile = __logdir + '/' + __logfile_prefix + __datestr + '-prepare-' + par1['number'] + '.log' ++ with open(__logfile, 'wb') as __filedescriptor: ++ process = subprocess.Popen(args, stdout=subprocess.PIPE) ++ for line in iter(process.stdout.readline, b''): ++ sys.stdout.write(line.decode(sys.stdout.encoding)) ++ __filedescriptor.write(line) ++ __filedescriptor.flush() ++ ++# run the test: ++ command = ('ansible-playbook run-install-test-' ++ + par1['number'] ++ + '.yml ' ++ + par1['command_line_parameter'] ++ + '-l ' ++ + __managed_node ++ + ' ' ++ + '-e "') ++# add all role vars for this test: ++ for par2 in par1['role_vars']: ++ command += str(par2) ++ command += '"' ++ print("command: " + command) ++ args = shlex.split(command) ++# _output = subprocess.getoutput(command) ++ __logfile = __logdir + '/' + __logfile_prefix + __datestr + '-run-' + par1['number'] + '.log' ++ with open(__logfile, 'wb') as __filedescriptor: ++ process = subprocess.Popen(args, stdout=subprocess.PIPE) ++ for line in iter(process.stdout.readline, b''): ++ sys.stdout.write(line.decode(sys.stdout.encoding)) ++ __filedescriptor.write(line) ++ __filedescriptor.flush() ++ print('Expected output string: \'' + par1['expected_output_string'] + '\'') ++ __match = open(__logfile, 'r').read().find(par1['expected_output_string']) ++ print('__match: ' + str(__match)) ++# __match = re.search(par1['expected_output_string'], _output) ++ if __match >= 0: ++ par1['rc'] = '0' ++ print('Test ' + par1['number'] + ' passed!!!') ++ else: ++ print('Test ' + par1['number'] + ' FAILED!!!') ++ ++# uninstall SAP HANA: ++ command = ('ansible-playbook hana-uninstall.yml ' ++ + '-l ' ++ + __managed_node) ++ args = shlex.split(command) ++ __logfile = __logdir + '/' + __logfile_prefix + __datestr + '-uninstall-' + par1['number'] + '.log' ++ with open(__logfile, 'wb') as __filedescriptor: ++ process = subprocess.Popen(args, stdout=subprocess.PIPE) ++ for line in iter(process.stdout.readline, b''): ++ sys.stdout.write(line.decode(sys.stdout.encoding)) ++ __filedescriptor.write(line) ++ __filedescriptor.flush() ++ ++print('\n') ++ ++__logfile = __logdir + '/' + __logfile_prefix + __datestr + '-result.log' ++with open(__logfile, 'w') as __filedescriptor: ++ print_log('Results for role sap_hana_install on ' + __managed_node + ' - RHEL ' + __mn_rhel_release + ' - ' + __mn_hw_arch + ':\n') ++ ++ print_log('\n#' ++ + __field_delimiter ++ + 'RC' + __field_delimiter ++ + 'name' + __field_delimiter ++ + 'argument' + __field_delimiter ++ + 'expected output string' + __field_delimiter ++ + 'role_vars' + '\n') ++ ++ for par1 in __tests[0:3]: ++ print_log(par1['number'] + __field_delimiter ++ + par1['rc'] + __field_delimiter ++ + par1['name'] + __field_delimiter ++ + '\'' + par1['command_line_parameter'] + '\'' + __field_delimiter ++ + '\'' + par1['expected_output_string'] + '\'' + __field_delimiter) ++# + '\'' + par1['expected_output_string'] + '\'' + __field_delimiter, end='') ++ if(len(par1['role_vars']) == 0): ++ print_log('\n') ++ else: ++ for par2 in par1['role_vars']: ++ print_log(str(par2)) ++ print_log('\n') +diff --git a/roles/sap_hana_install/tests/sapcar/prepare-sapcar-tests.yml b/roles/sap_hana_install/tests/sapcar/prepare-sapcar-tests.yml +new file mode 100644 +index 0000000..f396065 +--- /dev/null ++++ b/roles/sap_hana_install/tests/sapcar/prepare-sapcar-tests.yml +@@ -0,0 +1,45 @@ ++--- ++ ++- name: Prepare sapcar tests ++ hosts: all ++ become: true ++ vars_files: ++ - sapcar-vars.yml ++ gather_facts: false ++ ++ tasks: ++ - name: Remove '{{ sap_hana_install_software_directory }}' ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_directory }}/" ++ state: absent ++ ++ - name: Create '{{ sap_hana_install_software_directory }}' ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_directory }}" ++ state: directory ++ owner: root ++ group: root ++ mode: '0755' ++ ++# - name: Copy '/software/hana/{{ sap_hana_install_sapcar_filename }}' to '{{ sap_hana_install_software_directory }}' ++# ansible.builtin.copy: ++# src: "/software/hana/{{ sap_hana_install_sapcar_filename }}" ++# dest: "{{ sap_hana_install_software_directory }}/" ++# owner: root ++# group: root ++# mode: '0755' ++ ++ - name: Copy SAPCAR files from '/software/hana/' to '{{ sap_hana_install_software_directory }}' ++ ansible.builtin.copy: ++ src: "/software/hana/{{ item }}" ++ dest: "{{ sap_hana_install_software_directory }}/" ++ owner: root ++ group: root ++ mode: '0755' ++ loop: ++ - SAPCAR_1115-70006175.EXE ++ - SAPCAR_1115-70006177.EXE ++ - SAPCAR_1115-70006178.EXE ++ - SAPCAR_1115-70006234.EXE ++ - SAPCAR_1115-70006238.EXE ++ - SAPCAR_1211-80000935.EXE +diff --git a/roles/sap_hana_install/tests/sapcar/prepare-test-01.yml b/roles/sap_hana_install/tests/sapcar/prepare-test-01.yml +new file mode 100644 +index 0000000..abdd860 +--- /dev/null ++++ b/roles/sap_hana_install/tests/sapcar/prepare-test-01.yml +@@ -0,0 +1,19 @@ ++--- ++ ++- name: Prepare test 01 ++ hosts: all ++ become: true ++ vars_files: ++ - sapcar-vars.yml ++ gather_facts: false ++ ++ tasks: ++ - name: Prepare test 01 - Make sure there is no checksum file ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_directory }}/{{ sap_hana_install_sapcar_filename }}.sha256" ++ state: absent ++ ++ - name: Prepare test 01 - Make sure there is no SHA256 file ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_directory }}/SHA256" ++ state: absent +diff --git a/roles/sap_hana_install/tests/sapcar/prepare-test-02.yml b/roles/sap_hana_install/tests/sapcar/prepare-test-02.yml +new file mode 100644 +index 0000000..3a04208 +--- /dev/null ++++ b/roles/sap_hana_install/tests/sapcar/prepare-test-02.yml +@@ -0,0 +1,19 @@ ++--- ++ ++- name: Prepare test 02 ++ hosts: all ++ become: true ++ vars_files: ++ - sapcar-vars.yml ++ gather_facts: false ++ ++ tasks: ++ - name: Prepare test 02 - Make sure there is no SHA256 file ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_directory }}/SHA256" ++ state: absent ++ ++ - name: Prepare test 02 - Create wrong checksum file ++ ansible.builtin.shell: ++ cmd: sha256sum "{{ sap_hana_install_sapcar_filename }}" | awk '{gsub ("1", "2", $1); printf ("%s %s\n", $1, $2)}' > "{{ sap_hana_install_sapcar_filename }}.sha256" ++ chdir: "{{ sap_hana_install_software_directory }}" +diff --git a/roles/sap_hana_install/tests/sapcar/prepare-test-03.yml b/roles/sap_hana_install/tests/sapcar/prepare-test-03.yml +new file mode 100644 +index 0000000..7864eb5 +--- /dev/null ++++ b/roles/sap_hana_install/tests/sapcar/prepare-test-03.yml +@@ -0,0 +1,19 @@ ++--- ++ ++- name: Prepare test 03 ++ hosts: all ++ become: true ++ vars_files: ++ - sapcar-vars.yml ++ gather_facts: false ++ ++ tasks: ++ - name: Prepare test 03 - Make sure there is no SHA256 file ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_directory }}/SHA256" ++ state: absent ++ ++ - name: Prepare test 03 - Create correct checksum file ++ ansible.builtin.shell: ++ cmd: sha256sum "{{ sap_hana_install_sapcar_filename }}" > "{{ sap_hana_install_sapcar_filename }}.sha256" ++ chdir: "{{ sap_hana_install_software_directory }}" +diff --git a/roles/sap_hana_install/tests/sapcar/prepare-test-04.yml b/roles/sap_hana_install/tests/sapcar/prepare-test-04.yml +new file mode 100644 +index 0000000..a8b9a76 +--- /dev/null ++++ b/roles/sap_hana_install/tests/sapcar/prepare-test-04.yml +@@ -0,0 +1,21 @@ ++--- ++ ++- name: Prepare test 04 ++ hosts: all ++ become: true ++ vars_files: ++ - sapcar-vars.yml ++ vars: ++ sap_hana_install_global_checksum_file: "{{ sap_hana_install_software_directory }}/SHA256" ++ gather_facts: false ++ ++ tasks: ++ - name: Prepare test 04 - Make sure there is no checksum file ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_directory }}/{{ sap_hana_install_sapcar_filename }}.sha256" ++ state: absent ++ ++ - name: Prepare test 04 - Create wrong checksum in global checksum file ++ ansible.builtin.shell: ++ cmd: (sha256sum /usr/bin/bash; sha256sum "{{ sap_hana_install_sapcar_filename }}" | awk '{gsub ("1", "2", $1); printf ("%s %s\n", $1, $2)}'; sha256sum /usr/bin/ls) > "{{ sap_hana_install_global_checksum_file }}" ++ chdir: "{{ sap_hana_install_software_directory }}" +diff --git a/roles/sap_hana_install/tests/sapcar/prepare-test-05.yml b/roles/sap_hana_install/tests/sapcar/prepare-test-05.yml +new file mode 100644 +index 0000000..58ed193 +--- /dev/null ++++ b/roles/sap_hana_install/tests/sapcar/prepare-test-05.yml +@@ -0,0 +1,21 @@ ++--- ++ ++- name: Prepare test 05 ++ hosts: all ++ become: true ++ vars_files: ++ - sapcar-vars.yml ++ vars: ++ sap_hana_install_global_checksum_file: "{{ sap_hana_install_software_directory }}/SHA256" ++ gather_facts: false ++ ++ tasks: ++ - name: Prepare test 05 - Make sure there is no checksum file ++ ansible.builtin.file: ++ path: "{{ sap_hana_install_software_directory }}/{{ sap_hana_install_sapcar_filename }}.sha256" ++ state: absent ++ ++ - name: Prepare test 05 - Create correct checksum in global checksum file ++ ansible.builtin.shell: ++ cmd: (sha256sum /usr/bin/bash; sha256sum "{{ sap_hana_install_sapcar_filename }}"; sha256sum /usr/bin/ls) > "{{ sap_hana_install_global_checksum_file }}" ++ chdir: "{{ sap_hana_install_software_directory }}" +diff --git a/roles/sap_hana_install/tests/sapcar/run-sap_hana_install-sapcar-tests.py b/roles/sap_hana_install/tests/sapcar/run-sap_hana_install-sapcar-tests.py +new file mode 100755 +index 0000000..d9eceff +--- /dev/null ++++ b/roles/sap_hana_install/tests/sapcar/run-sap_hana_install-sapcar-tests.py +@@ -0,0 +1,186 @@ ++#!/usr/bin/env python ++ ++import os ++import sys ++import subprocess ++import re ++import yaml ++ ++# output field delimiter for displaying the results: ++_field_delimiter = '\t' ++ ++if(len(sys.argv) != 3): ++ print('Please provide the name of the managed node and the user name for logging in.') ++ _managed_node = input('Name of managed node: ') ++ _username = input('User name for connecting to managed node: ') ++else: ++ _managed_node = sys.argv[1] ++ _username = sys.argv[2] ++ ++print('Running sapcar preinstall tests for role sap_hana_install...\n') ++print('Managed node: ' + _managed_node) ++print('Username: ' + _username) ++ ++_mn_rhel_release = subprocess.getoutput( ++ "ssh " ++ + _username ++ + "@" ++ + _managed_node ++ + " cat /etc/redhat-release | \ ++ awk 'BEGIN{FS=\"release \"}{split ($2, a, \" \"); print a[1]}'") ++print('Managed node Red Hat release: ' + _mn_rhel_release) ++_mn_hw_arch = subprocess.getoutput("ssh " + _username + "@" + _managed_node + " uname -m") ++print('Managed node HW architecture: ' + _mn_hw_arch) ++ ++_vars_file = 'sapcar-vars.yml' ++with open(_vars_file, 'r') as _file: ++ _vars_1 = yaml.safe_load(_file) ++ ++sap_hana_install_sapcar_filename = _vars_1.get('sap_hana_install_sapcar_filename_' + _mn_hw_arch) ++print('sap_hana_install_sapcar_filename: ' + sap_hana_install_sapcar_filename) ++ ++__tests = [ ++ { ++ 'number': '01', ++ 'name': 'SAPCAR checksum test, missing sha256 file', ++ 'command_line_parameter': '--tags=sap_hana_install_prepare_sapcar ', ++ 'expected_output_string': 'FAIL: Missing checksum file \'/software/sap_hana_install_test/' + sap_hana_install_sapcar_filename + '.sha256\'!', ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_install_verify_checksums': True, ++ 'sap_hana_install_sapcar_filename': sap_hana_install_sapcar_filename ++ } ++ ] ++ }, ++ { ++ 'number': '02', ++ 'name': 'SAPCAR checksum test, sha256 file exists but checksum is not correct', ++ 'command_line_parameter': '--tags=sap_hana_install_prepare_sapcar ', ++ 'expected_output_string': ' does not match the checksum stored in file \'/software/sap_hana_install_test/' ++ + sap_hana_install_sapcar_filename ++ + '.sha256\'!', ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_install_verify_checksums': True, ++ 'sap_hana_install_sapcar_filename': sap_hana_install_sapcar_filename ++ } ++ ] ++ }, ++ { ++ 'number': '03', ++ 'name': 'SAPCAR checksum test, sha256 file exists with correct checksum', ++ 'command_line_parameter': '--tags=sap_hana_install_prepare_sapcar ', ++ 'expected_output_string': ' matches the checksum stored in file \'/software/sap_hana_install_test/' + sap_hana_install_sapcar_filename + '.sha256\'.', ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_install_verify_checksums': True, ++ 'sap_hana_install_sapcar_filename': sap_hana_install_sapcar_filename ++ } ++ ] ++ }, ++ { ++ 'number': '04', ++ 'name': 'SAPCAR checksum test, SHA256 file exists but checksum is not correct', ++ 'command_line_parameter': '--tags=sap_hana_install_prepare_sapcar ', ++ 'expected_output_string': ' does not match the checksum stored in file \'/software/sap_hana_install_test/SHA256\'!', ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_install_verify_checksums': True, ++ 'sap_hana_install_sapcar_filename': sap_hana_install_sapcar_filename, ++ 'sap_hana_install_global_checksum_file': "{{ sap_hana_install_software_directory }}/SHA256" ++ } ++ ] ++ }, ++ { ++ 'number': '05', ++ 'name': 'SAPCAR checksum test, SHA256 file exists with correct checksum', ++ 'command_line_parameter': '--tags=sap_hana_install_prepare_sapcar ', ++ 'expected_output_string': ' matches the checksum stored in file \'/software/sap_hana_install_test/SHA256\'.', ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_install_verify_checksums': True, ++ 'sap_hana_install_sapcar_filename': sap_hana_install_sapcar_filename, ++ 'sap_hana_install_global_checksum_file': "{{ sap_hana_install_software_directory }}/SHA256" ++ } ++ ] ++ }, ++] ++ ++command = ('ansible-playbook prepare-sapcar-tests.yml ' ++ + '-l ' ++ + _managed_node) ++_py_rc = os.system(command) ++ ++for par1 in __tests[0:5]: ++ print('\n' + 'Test ' + par1['number'] + ': ' + par1['name']) ++ command = ('ansible-playbook prepare-test-' ++ + par1['number'] ++ + '.yml ' ++ + '-l ' ++ + _managed_node ++ + ' -e "' ++ + '{ sap_hana_install_sapcar_filename: ' ++ + sap_hana_install_sapcar_filename ++ + ' }"') ++ print('command: >' + command + '<') ++ _py_rc = os.system(command) ++ command = ('ansible-playbook run-sapcar-test.yml ' ++ + par1['command_line_parameter'] ++ + '-l ' ++ + _managed_node ++ + ' -e "') ++ for par2 in par1['role_vars']: ++ command += str(par2) ++ command += '"' ++ print("command: >" + command + '<') ++# _py_rc = os.system(command) ++# _py_rc = os.popen(command).read() ++# _output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True) ++ _output = subprocess.getoutput(command) ++ print('Output of test: ' + _output) ++ _match = re.search(par1['expected_output_string'], _output) ++ if _match: ++ par1['rc'] = '0' ++ print('Test ' + par1['number'] + ' passed!!!') ++# par1['rc'] = str(int(_py_rc/256)) ++# if(_py_rc != 0): ++# if par1['ignore_error_final']: ++# print('Test ' + par1['number'] + ' finished with return code ' + par1['rc'] + '. Continuing with the next test') ++# else: ++# print('Test ' + par1['number'] + ' finished with return code ' + par1['rc'] + '.') ++# exit(_py_rc) ++# else: ++# print('Test ' + par1['number'] + ' finished with return code ' + par1['rc'] + '.') ++ ++print('\nResults for role sap_hana_install preinstall: ' ++ + _managed_node ++ + ' - RHEL ' ++ + _mn_rhel_release ++ + ' - ' ++ + _mn_hw_arch ++ + ':') ++ ++print('\n#' ++ + _field_delimiter ++ + 'RC' + _field_delimiter ++ + 'name' + _field_delimiter ++ + 'argument' + _field_delimiter ++ + 'expected error string' + _field_delimiter ++ + 'role_vars') ++ ++for par1 in __tests[0:5]: ++ print(par1['number'] + _field_delimiter ++ + par1['rc'] + _field_delimiter ++ + par1['name'] + _field_delimiter ++ + '\'' + par1['command_line_parameter'] + '\'' + _field_delimiter ++ + '\'' + par1['expected_output_string'] + '\'' + _field_delimiter, end='') ++ if (len(par1['role_vars']) == 0): ++ print("") ++ else: ++ for par2 in par1['role_vars']: ++ print(str(par2)) +diff --git a/roles/sap_hana_install/tests/sapcar/run-sapcar-test.yml b/roles/sap_hana_install/tests/sapcar/run-sapcar-test.yml +new file mode 100644 +index 0000000..8bc6b98 +--- /dev/null ++++ b/roles/sap_hana_install/tests/sapcar/run-sapcar-test.yml +@@ -0,0 +1,11 @@ ++--- ++ ++- name: test ++ hosts: all ++ collections: ++ - community.sap_install ++ become: true ++ vars_files: ++ - sapcar-vars.yml ++ roles: ++ - sap_hana_install +diff --git a/roles/sap_hana_install/tests/sapcar/sapcar-vars.yml b/roles/sap_hana_install/tests/sapcar/sapcar-vars.yml +new file mode 100644 +index 0000000..0b904f6 +--- /dev/null ++++ b/roles/sap_hana_install/tests/sapcar/sapcar-vars.yml +@@ -0,0 +1,10 @@ ++--- ++ ++sap_hana_install_sid: T01 ++sap_hana_install_number: 01 ++sap_hana_install_software_directory: '/software/sap_hana_install_test' ++sap_hana_install_checksum_algorithm: sha256 ++# sap_hana_install_sapcar_filename_ppc64: SAPCAR_1115-70006175.EXE # ppc64 ++sap_hana_install_sapcar_filename_ppc64le: SAPCAR_1115-70006238.EXE # ppc64le ++# sap_hana_install_sapcar_filename: SAPCAR_1211-80000935.EXE # x86_64, rel 721, patch 1211 ++sap_hana_install_sapcar_filename_x86_64: SAPCAR_1115-70006178.EXE # x86_64, rel 722, patch 1115 +diff --git a/roles/sap_hana_preconfigure/tests/.pylintrc b/roles/sap_hana_preconfigure/tests/.pylintrc +new file mode 120000 +index 0000000..0d402e7 +--- /dev/null ++++ b/roles/sap_hana_preconfigure/tests/.pylintrc +@@ -0,0 +1 @@ ++../../../.pylintrc +\ No newline at end of file +diff --git a/roles/sap_hana_preconfigure/tests/beautify-assert-output.sh b/roles/sap_hana_preconfigure/tests/beautify-assert-output.sh +new file mode 120000 +index 0000000..9a2e976 +--- /dev/null ++++ b/roles/sap_hana_preconfigure/tests/beautify-assert-output.sh +@@ -0,0 +1 @@ ++../tools/beautify-assert-output.sh +\ No newline at end of file +diff --git a/roles/sap_hana_preconfigure/tests/run-sap_hana_preconfigure-tests.py b/roles/sap_hana_preconfigure/tests/run-sap_hana_preconfigure-tests.py +new file mode 100755 +index 0000000..08bc7f5 +--- /dev/null ++++ b/roles/sap_hana_preconfigure/tests/run-sap_hana_preconfigure-tests.py +@@ -0,0 +1,242 @@ ++#!/usr/bin/env python ++ ++""" ++Tests for role sap_hana_preconfigure ++""" ++ ++import os ++import sys ++import subprocess ++ ++# output field delimiter for displaying the results: ++FIELD_DELIMITER = '\t' ++ ++if len(sys.argv) == 1: ++ _managed_node = input("Provide name of managed node: ") ++else: ++ _managed_node = sys.argv[1] ++ ++print('Running tests for role sap_hana_preconfigure...\n') ++print('Managed node: ' + _managed_node) ++ ++_mn_rhel_release = subprocess.getoutput( ++ "ssh root@" ++ + _managed_node ++ + " cat /etc/redhat-release | \ ++ awk 'BEGIN{FS=\"release \"}{split($2, a, \" \"); print a[1]}'") ++print('Managed node Red Hat release: ' + _mn_rhel_release) ++_mn_hw_arch = subprocess.getoutput("ssh root@" + _managed_node + " uname -m") ++print('Managed node HW architecture: ' + _mn_hw_arch) ++ ++__tests = [ ++ { ++ 'number': '1', ++ 'name': 'Run in check mode on new system.', ++ 'command_line_parameter': '--check ', ++ 'ignore_error_final': True, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [] ++ }, ++ { ++ 'number': '2', ++ 'name': 'Run in assert mode on new system, \ ++ ignore assert errors.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': False, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_preconfigure_assert': True, ++ 'sap_hana_preconfigure_assert_ignore_errors': True, ++ } ++ ] ++ }, ++ { ++ 'number': '3', ++ 'name': 'Run in normal mode on new system, \ ++ check for possible RHEL update, \ ++ allow a reboot.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': False, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_preconfigure_update': True, ++ 'sap_hana_preconfigure_reboot_ok': True, ++ } ++ ] ++ }, ++ { ++ 'number': '4', ++ 'name': 'Idempotency check: Run in normal mode again, \ ++ check for possible RHEL update, \ ++ allow a reboot.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': False, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_preconfigure_update': True, ++ 'sap_hana_preconfigure_reboot_ok': True, ++ } ++ ] ++ }, ++ { ++ 'number': '5', ++ 'name': 'Run in assert mode on modified system, \ ++ check for possible RHEL update, \ ++ ignore any assert error.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': False, ++ 'compact_assert_output': True, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_preconfigure_assert': True, ++ 'sap_hana_preconfigure_assert_ignore_errors': True, ++ 'sap_hana_preconfigure_update': True, ++ } ++ ] ++ }, ++ { ++ 'number': '6', ++ 'name': 'Run in normal mode, \ ++ do not use tuned, \ ++ allow a reboot.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': False, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_preconfigure_use_tuned': False, ++ 'sap_hana_preconfigure_reboot_ok': True, ++ } ++ ] ++ }, ++ { ++ 'number': '7', ++ 'name': 'Run in normal mode, \ ++ use tuned and also modify boot command line, \ ++ allow a reboot.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': False, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_preconfigure_use_tuned': True, ++ 'sap_hana_preconfigure_modify_grub_cmdline_linux': True, ++ 'sap_hana_preconfigure_reboot_ok': True, ++ } ++ ] ++ }, ++ { ++ 'number': '8', ++ 'name': 'Idempotency check: Run in normal mode again, \ ++ use tuned and also modify boot command line, \ ++ allow a reboot.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': False, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_preconfigure_use_tuned': True, ++ 'sap_hana_preconfigure_modify_grub_cmdline_linux': True, ++ 'sap_hana_preconfigure_reboot_ok': True, ++ } ++ ] ++ }, ++ { ++ 'number': '9', ++ 'name': 'Run in assert mode, \ ++ check for possible RHEL update, \ ++ check all config, \ ++ compact output, \ ++ ignore any assert error.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': True, ++ 'compact_assert_output': True, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_hana_preconfigure_assert': True, ++ 'sap_hana_preconfigure_assert_all_config': True, ++ 'sap_hana_preconfigure_assert_ignore_errors': True, ++ } ++ ] ++ }, ++ { ++ 'number': '10', ++ 'name': 'Run in check mode on modified system.', ++ 'command_line_parameter': '--check ', ++ 'ignore_error_final': False, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [] ++ } ++] ++ ++for par1 in __tests: ++ print('\n' + 'Test ' + par1['number'] + ': ' + par1['name']) ++ command = ('ansible-playbook sap_hana_preconfigure-default-settings.yml ' ++ + par1['command_line_parameter'] ++ + '-l ' ++ + _managed_node ++ + ' ' ++ + '-e "') ++ for par2 in par1['role_vars']: ++ command += str(par2) ++ command += '"' ++ if par1['compact_assert_output']: ++ command += ' | ./beautify-assert-output.sh' ++ print("command: " + command) ++ _py_rc = os.system(command) ++ par1['rc'] = str(int(_py_rc / 256)) ++ if _py_rc != 0: ++ if par1['ignore_error_final']: ++ print('Test ' ++ + par1['number'] ++ + ' finished with return code ' ++ + par1['rc'] ++ + '. Continuing with the next test') ++ else: ++ print('Test ' ++ + par1['number'] ++ + ' finished with return code ' ++ + par1['rc'] + '.') ++ sys.exit(_py_rc) ++ else: ++ print('Test ' + par1['number'] + ' finished with return code ' + par1['rc'] + '.') ++ ++print('\nResults for role sap_hana_preconfigure: ' ++ + _managed_node ++ + ' - RHEL ' ++ + _mn_rhel_release ++ + ' - ' ++ + _mn_hw_arch + ':') ++ ++print('\n#' ++ + FIELD_DELIMITER ++ + 'RC' + FIELD_DELIMITER ++ + 'name' + FIELD_DELIMITER ++ + 'argument' + FIELD_DELIMITER ++ + 'compact' + FIELD_DELIMITER ++ + 'role_vars') ++ ++for par1 in __tests: ++ print(par1['number'] + FIELD_DELIMITER ++ + par1['rc'] + FIELD_DELIMITER ++ + par1['name'] + FIELD_DELIMITER ++ + par1['command_line_parameter'] + FIELD_DELIMITER ++ + str(par1['compact_assert_output']) + FIELD_DELIMITER, end='') ++ if len(par1['role_vars']) == 0: ++ print("") ++ else: ++ for par2 in par1['role_vars']: ++ print(str(par2)) +diff --git a/roles/sap_hana_preconfigure/tests/sap_hana_preconfigure-default-settings.yml b/roles/sap_hana_preconfigure/tests/sap_hana_preconfigure-default-settings.yml +new file mode 100644 +index 0000000..561b391 +--- /dev/null ++++ b/roles/sap_hana_preconfigure/tests/sap_hana_preconfigure-default-settings.yml +@@ -0,0 +1,6 @@ ++--- ++- hosts: all ++ collections: ++ - community.sap_install ++ roles: ++ - sap_hana_preconfigure +diff --git a/roles/sap_netweaver_preconfigure/tests/.pylintrc b/roles/sap_netweaver_preconfigure/tests/.pylintrc +new file mode 120000 +index 0000000..0d402e7 +--- /dev/null ++++ b/roles/sap_netweaver_preconfigure/tests/.pylintrc +@@ -0,0 +1 @@ ++../../../.pylintrc +\ No newline at end of file +diff --git a/roles/sap_netweaver_preconfigure/tests/beautify-assert-output.sh b/roles/sap_netweaver_preconfigure/tests/beautify-assert-output.sh +new file mode 120000 +index 0000000..9a2e976 +--- /dev/null ++++ b/roles/sap_netweaver_preconfigure/tests/beautify-assert-output.sh +@@ -0,0 +1 @@ ++../tools/beautify-assert-output.sh +\ No newline at end of file +diff --git a/roles/sap_netweaver_preconfigure/tests/run-sap_netweaver_preconfigure-tests.py b/roles/sap_netweaver_preconfigure/tests/run-sap_netweaver_preconfigure-tests.py +new file mode 100755 +index 0000000..30cc250 +--- /dev/null ++++ b/roles/sap_netweaver_preconfigure/tests/run-sap_netweaver_preconfigure-tests.py +@@ -0,0 +1,153 @@ ++#!/usr/bin/env python ++ ++""" ++Tests for role sap_netweaver_preconfigure ++""" ++ ++import os ++import sys ++import subprocess ++ ++# output field delimiter for displaying the results: ++FIELD_DELIMITER = '\t' ++ ++if len(sys.argv) == 1: ++ _managed_node = input("Provide name of managed node: ") ++else: ++ _managed_node = sys.argv[1] ++ ++print('Running tests for role sap_netweaver_preconfigure...\n') ++print('Managed node: ' + _managed_node) ++ ++_mn_rhel_release = subprocess.getoutput( ++ "ssh root@" ++ + _managed_node ++ + " cat /etc/redhat-release | \ ++ awk 'BEGIN{FS=\"release \"}{split($2, a, \" \"); print a[1]}'") ++print('Managed node Red Hat release: ' + _mn_rhel_release) ++_mn_hw_arch = subprocess.getoutput("ssh root@" + _managed_node + " uname -m") ++print('Managed node HW architecture: ' + _mn_hw_arch) ++ ++__tests = [ ++ { ++ 'number': '1', ++ 'name': 'Run in check mode on new system.', ++ 'command_line_parameter': '--check ', ++ 'ignore_error_final': True, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [] ++ }, ++ { ++ 'number': '2', ++ 'name': 'Run in assert mode on new system, \ ++ ignore assert errors.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': True, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_netweaver_preconfigure_assert': True, ++ 'sap_netweaver_preconfigure_assert_ignore_errors': True, ++ } ++ ] ++ }, ++ { ++ 'number': '3', ++ 'name': 'Run in normal mode on new system. \ ++ Do not fail in case not enough swap space is configured.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': False, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_netweaver_preconfigure_fail_if_not_enough_swap_space_configured': False, ++ } ++ ] ++ }, ++ { ++ 'number': '4', ++ 'name': 'Run in assert mode on modified system, \ ++ compact output, \ ++ ignore any assert error.', ++ 'command_line_parameter': '', ++ 'ignore_error_final': True, ++ 'compact_assert_output': True, ++ 'rc': '99', ++ 'role_vars': [ ++ { ++ 'sap_netweaver_preconfigure_assert': True, ++ 'sap_netweaver_preconfigure_assert_ignore_errors': True, ++ } ++ ] ++ }, ++ { ++ 'number': '5', ++ 'name': 'Run in check mode on configured system. Ignore a final error.', ++ 'command_line_parameter': '--check ', ++ 'ignore_error_final': True, ++ 'compact_assert_output': False, ++ 'rc': '99', ++ 'role_vars': [] ++ }, ++] ++ ++for par1 in __tests: ++ print('\n' + 'Test ' + par1['number'] + ': ' + par1['name']) ++ command = ('ansible-playbook sap_netweaver_preconfigure-default-settings.yml ' ++ + par1['command_line_parameter'] ++ + '-l ' ++ + _managed_node ++ + ' ' ++ + '-e "') ++ for par2 in par1['role_vars']: ++ command += str(par2) ++ command += '"' ++ if par1['compact_assert_output']: ++ command += ' | ./beautify-assert-output.sh' ++ print("command: " + command) ++ _py_rc = os.system(command) ++ par1['rc'] = str(int(_py_rc / 256)) ++ if _py_rc != 0: ++ if par1['ignore_error_final']: ++ print('Test ' ++ + par1['number'] ++ + ' finished with return code ' ++ + par1['rc'] ++ + '. Continuing with the next test') ++ else: ++ print('Test ' ++ + par1['number'] ++ + ' finished with return code ' ++ + par1['rc'] + '.') ++ sys.exit(_py_rc) ++ else: ++ print('Test ' + par1['number'] + ' finished with return code ' + par1['rc'] + '.') ++ ++print('\nResults for role sap_netweaver_preconfigure: ' ++ + _managed_node ++ + ' - RHEL ' ++ + _mn_rhel_release ++ + ' - ' + _mn_hw_arch + ':') ++ ++print('\n#' ++ + FIELD_DELIMITER ++ + 'RC' + FIELD_DELIMITER ++ + 'name' + FIELD_DELIMITER ++ + 'argument' + FIELD_DELIMITER ++ + 'compact' + FIELD_DELIMITER ++ + 'role_vars') ++ ++for par1 in __tests: ++ print(par1['number'] + FIELD_DELIMITER ++ + par1['rc'] + FIELD_DELIMITER ++ + par1['name'] + FIELD_DELIMITER ++ + par1['command_line_parameter'] + FIELD_DELIMITER ++ + str(par1['compact_assert_output']) + FIELD_DELIMITER, end='') ++ if len(par1['role_vars']) == 0: ++ print("") ++ else: ++ for par2 in par1['role_vars']: ++ print(str(par2)) +diff --git a/roles/sap_netweaver_preconfigure/tests/sap_netweaver_preconfigure-default-settings.yml b/roles/sap_netweaver_preconfigure/tests/sap_netweaver_preconfigure-default-settings.yml +new file mode 100644 +index 0000000..e9e772a +--- /dev/null ++++ b/roles/sap_netweaver_preconfigure/tests/sap_netweaver_preconfigure-default-settings.yml +@@ -0,0 +1,6 @@ ++--- ++- hosts: all ++ collections: ++ - community.sap_install ++ roles: ++ - sap_netweaver_preconfigure diff --git a/redhat.sap_install-1.3.4-add_tools.patch b/redhat.sap_install-1.3.4-add_tools.patch new file mode 100644 index 0000000..38f2900 --- /dev/null +++ b/redhat.sap_install-1.3.4-add_tools.patch @@ -0,0 +1,128 @@ +commit 83db825f7f30445408efa6061631d8dd0590e891 +Author: Than Ngo +Date: Thu Jan 25 16:17:21 2024 +0100 + + add missing tools folders + + Signed-off-by: Than Ngo + +diff --git a/roles/sap_general_preconfigure/tools/beautify-assert-output.sh b/roles/sap_general_preconfigure/tools/beautify-assert-output.sh +new file mode 100755 +index 0000000..f48087c +--- /dev/null ++++ b/roles/sap_general_preconfigure/tools/beautify-assert-output.sh +@@ -0,0 +1,34 @@ ++#!/bin/bash ++ ++# default font color: Light Cyan, which should be readable on both bright and dark background ++__FONT_COLOR=36m ++ ++if [[ ${1}. == "font_light_gray". ]]; then ++ __FONT_COLOR=37m ++elif [[ ${1}. == "font_no_color". ]]; then ++ __FONT_COLOR=30m ++fi ++ ++if [[ ${2}. == "reset." ]]; then ++ awk 'BEGIN{printf ("\033['${__FONT_COLOR}'Resetting font color\n")}' ++ exit ++fi ++ ++awk '{sub (" \"msg\": ", "")} ++ /TASK/{task_line=$0} ++ /fatal:/{fatal_line=$0; nfatal[host]++} ++ /...ignoring/{nfatal[host]--; if (nfatal[host]<0) nfatal[host]=0} ++ /^[a-z]/&&/: \[/{gsub ("\\[", ""); gsub ("]", ""); gsub (":", ""); host=$2} ++ /SAP note/{print "\033['${__FONT_COLOR}'[" host"] "$0} ++ /FAIL:/{nfail[host]++; print "\033[31m[" host"] "$0} ++ /WARN:/{nwarn[host]++; print "\033[33m[" host"] "$0} ++ /PASS:/{npass[host]++; print "\033[32m[" host"] "$0} ++ /INFO:/{print "\033[34m[" host"] "$0} ++ /changed/&&/unreachable/{print "\033['${__FONT_COLOR}'[" host"] "$0} ++ END{print ("---"); for (var in npass) {printf ("[%s] ", var); if (nfatal[var]>0) { ++ printf ("\033[31mFATAL ERROR!!! Playbook might have been aborted!!!\033['${__FONT_COLOR}' Last TASK and fatal output:\n"); print task_line, fatal_line ++ exit 199 ++ } ++ else printf ("\033[31mFAIL: %d \033[33mWARN: %d \033[32mPASS: %d\033['${__FONT_COLOR}'\n", nfail[var], nwarn[var], npass[var])} ++ if (nfail[var] != 0) exit (nfail[var]) ++ }' +diff --git a/roles/sap_hana_preconfigure/tools/beautify-assert-output.sh b/roles/sap_hana_preconfigure/tools/beautify-assert-output.sh +new file mode 100755 +index 0000000..f48087c +--- /dev/null ++++ b/roles/sap_hana_preconfigure/tools/beautify-assert-output.sh +@@ -0,0 +1,34 @@ ++#!/bin/bash ++ ++# default font color: Light Cyan, which should be readable on both bright and dark background ++__FONT_COLOR=36m ++ ++if [[ ${1}. == "font_light_gray". ]]; then ++ __FONT_COLOR=37m ++elif [[ ${1}. == "font_no_color". ]]; then ++ __FONT_COLOR=30m ++fi ++ ++if [[ ${2}. == "reset." ]]; then ++ awk 'BEGIN{printf ("\033['${__FONT_COLOR}'Resetting font color\n")}' ++ exit ++fi ++ ++awk '{sub (" \"msg\": ", "")} ++ /TASK/{task_line=$0} ++ /fatal:/{fatal_line=$0; nfatal[host]++} ++ /...ignoring/{nfatal[host]--; if (nfatal[host]<0) nfatal[host]=0} ++ /^[a-z]/&&/: \[/{gsub ("\\[", ""); gsub ("]", ""); gsub (":", ""); host=$2} ++ /SAP note/{print "\033['${__FONT_COLOR}'[" host"] "$0} ++ /FAIL:/{nfail[host]++; print "\033[31m[" host"] "$0} ++ /WARN:/{nwarn[host]++; print "\033[33m[" host"] "$0} ++ /PASS:/{npass[host]++; print "\033[32m[" host"] "$0} ++ /INFO:/{print "\033[34m[" host"] "$0} ++ /changed/&&/unreachable/{print "\033['${__FONT_COLOR}'[" host"] "$0} ++ END{print ("---"); for (var in npass) {printf ("[%s] ", var); if (nfatal[var]>0) { ++ printf ("\033[31mFATAL ERROR!!! Playbook might have been aborted!!!\033['${__FONT_COLOR}' Last TASK and fatal output:\n"); print task_line, fatal_line ++ exit 199 ++ } ++ else printf ("\033[31mFAIL: %d \033[33mWARN: %d \033[32mPASS: %d\033['${__FONT_COLOR}'\n", nfail[var], nwarn[var], npass[var])} ++ if (nfail[var] != 0) exit (nfail[var]) ++ }' +diff --git a/roles/sap_netweaver_preconfigure/tools/beautify-assert-output.sh b/roles/sap_netweaver_preconfigure/tools/beautify-assert-output.sh +new file mode 100755 +index 0000000..f48087c +--- /dev/null ++++ b/roles/sap_netweaver_preconfigure/tools/beautify-assert-output.sh +@@ -0,0 +1,34 @@ ++#!/bin/bash ++ ++# default font color: Light Cyan, which should be readable on both bright and dark background ++__FONT_COLOR=36m ++ ++if [[ ${1}. == "font_light_gray". ]]; then ++ __FONT_COLOR=37m ++elif [[ ${1}. == "font_no_color". ]]; then ++ __FONT_COLOR=30m ++fi ++ ++if [[ ${2}. == "reset." ]]; then ++ awk 'BEGIN{printf ("\033['${__FONT_COLOR}'Resetting font color\n")}' ++ exit ++fi ++ ++awk '{sub (" \"msg\": ", "")} ++ /TASK/{task_line=$0} ++ /fatal:/{fatal_line=$0; nfatal[host]++} ++ /...ignoring/{nfatal[host]--; if (nfatal[host]<0) nfatal[host]=0} ++ /^[a-z]/&&/: \[/{gsub ("\\[", ""); gsub ("]", ""); gsub (":", ""); host=$2} ++ /SAP note/{print "\033['${__FONT_COLOR}'[" host"] "$0} ++ /FAIL:/{nfail[host]++; print "\033[31m[" host"] "$0} ++ /WARN:/{nwarn[host]++; print "\033[33m[" host"] "$0} ++ /PASS:/{npass[host]++; print "\033[32m[" host"] "$0} ++ /INFO:/{print "\033[34m[" host"] "$0} ++ /changed/&&/unreachable/{print "\033['${__FONT_COLOR}'[" host"] "$0} ++ END{print ("---"); for (var in npass) {printf ("[%s] ", var); if (nfatal[var]>0) { ++ printf ("\033[31mFATAL ERROR!!! Playbook might have been aborted!!!\033['${__FONT_COLOR}' Last TASK and fatal output:\n"); print task_line, fatal_line ++ exit 199 ++ } ++ else printf ("\033[31mFAIL: %d \033[33mWARN: %d \033[32mPASS: %d\033['${__FONT_COLOR}'\n", nfail[var], nwarn[var], npass[var])} ++ if (nfail[var] != 0) exit (nfail[var]) ++ }' diff --git a/rhel-system-roles-sap.spec b/rhel-system-roles-sap.spec index da6660d..34c0efa 100644 --- a/rhel-system-roles-sap.spec +++ b/rhel-system-roles-sap.spec @@ -45,7 +45,7 @@ Name: %{package_name} Summary: System Roles to configure RHEL for running SAP NetWeaver- or SAP HANA-based products Version: 3.6.0 -Release: 1%{?dist} +Release: 2%{?dist} License: GPL-3.0-or-later Url: https://github.com/redhat-sap/community.sap_install Source0: https://github.com/linux-system-roles/auto-maintenance/archive/%{mainid}/auto-maintenance-%{mainid}.tar.gz @@ -68,6 +68,12 @@ Patch4: redhat.sap_install-ed9bc223635d3e08661b506fdb9d62aef56032b0.patch # add collection files Patch5: redhat.sap_install-a5b1b5d4e79bebafd9ba75926dc56ada53f28e2d.patch +# add tests files +Patch6: redhat.sap_install-1.3.4-add_tests.patch + +# add tools files +Patch7: redhat.sap_install-1.3.4-add_tools.patch + BuildArch: noarch Requires: rhel-system-roles @@ -146,12 +152,18 @@ sed -i -e "s|for POWER ||g" roles/sap_hana_preconfigure/README.md %patch -P3 -p1 %patch -P4 -p1 %patch -P5 -p1 +%patch -P6 -p1 +%patch -P7 -p1 popd # remove zero file and symlinks find . -type f -size 0 -delete find . -type l -delete +# fix python and bash shebangs +find -type f \( -iname "*.py" \) -exec sed -i '1s=^#! */usr/bin/\(python\|env python\)[23]\?=#!/usr/bin/env python3=' {} + +find -type f \( -iname "*.sh" \) -exec sed -i '1s=^#! */bin/bash=#!/usr/bin/bash=' {} + + %build %if %{with html} readmes="" @@ -250,6 +262,11 @@ popd %endif %changelog +* Thu Jan 25 2024 Than Ngo - 3.6.0-2 +- add tests and tools +- fix bash and python shebangs +Related: RHEL-16895 + * Mon Jan 22 2024 Than Ngo - 3.6.0-1 - rebase sap roles to version 1.3.4 - add collection files