lib/sles4sap.pm

SYNOPSIS

Package with common methods and default values for tests on SLES for SAP Applications.

This package inherits from opensusebasetest and should be used as a class.

SAPINIT_RE & SYSTEMD_RE

$self->SAPINIT_RE();
$self->SAPINIT_RE(qr/some regexp/);
$self->SYSTEMD_RE();
$self->SYSTEMD_RE(qr/some regexp/);

Set or get a regular expressions to test on the /usr/sap/sapservices file whether the SAP workload was started via sapinit or systemd.

SYSTEMCTL_UNITS_RE

$self->SYSTEMCTL_UNITS_RE();
$self->SYSTEMCTL_UNITS_RE(qr/some regexp/);

Set or get a regular expression to test in the output of systemctl --list-unit-files whether the SAP workload was started via systemd units.

ASE_RESPONSE_FILE

$self->ASE_RESPONSE_FILE($filename);

Let the class methods know the name of the ASE response file currently in use. It is set to undef by default. Test modules testing for SAP ASE should set this property before anything else.

ensure_serialdev_permissions_for_sap

Derived from 'ensure_serialdev_permissions' function available in 'utils'.

Grant user permission to access serial port immediately as well as persisting over reboots. Used to ensure that testapi calls like script_run work for the test user as well as root.

fix_path

$self->fix_path( $uri );

Given the path to a CIFS or NFS share in $uri, this method will format the path so it can be used directly by mount(8). Returns an array with the protocol name (cifs or nfs) as the first element, and the formatted path as the second element. Croaks if an unsupported protocol is passed in $uri or if it cannot be parsed.

set_ps_cmd

$self->set_ps_cmd( $procname );

Sets in the class instance the ps command to be used to check for the presence of SAP processes in the SUT. Returns the value of the internal variable $ps_cmd.

set_sap_info

$self->set_sap_info( $SID, $instance_number );

SAP software relies on 2 identifiers, the system id (SID) which is a 3-character identifier, and the instance number. This method receives both via positional arguments, and sets the internal variables for $sid, $instance and $sapadmin accordingly. It also sets accessors that depend on $sid and $instance as well as the product type. Returns the value of $sapadmin.

user_change

$self->user_change();

Switch user in SUT to the SAP admin account, and grant serialdev permissions to the SAP admin user.

reset_user_change

$self->reset_user_change();

Exit from the SAP admin account in SUT and change serialdev permissions accordingly.

get_total_mem

$self->get_total_mem();

Returns the total memory configured in SUT.

is_saptune_installed

is_saptune_installed();

Checks if the saptune package is installed in SUT. Returns true or false.

prepare_profile

$self->prepare_profile( $profile );

Configures with saptune (if available in SUT) or sapconf the SUT according to a profile passed as argument. $profile must be either HANA or NETWEAVER. Croaks on failure.

_do_mount

_do_mount( $proto, $path, $target);

Performs a call to the mount command (used by both mount_media and copy_media) with appropiate options depending on the protocol. Function internal to the class.

copy_media

$self->copy_media( $proto, $path, $timeout, $target);

Copies installation media in SUT from the share identified by $proto and $path into the target directory $target. $timeout specifies how long to wait for the copy to complete.

After installation files are copied, this method will also verify the existence of a checksum.md5sum file in the target directory and use it to check for the integrity of the copied files. This test can be skipped by setting to a true value the DISABLE_CHECKSUM setting in the test.

The method will croak if any of the commands sent to SUT fail.

mount_media

$self->mount_media( $proto, $path, $target );

Mount installation media in SUT from the share identified by $proto and $path into the target directory $target.

add_hostname_to_hosts

$self->add_hostname_to_hosts();

Adds the IP address and the hostname of SUT to /etc/hosts. Croaks on failure.

test_pids_max

$self->test_pids_max();

Checks in SUT that the SAP admin user has no limits in the number of processes and threads that it can create.

test_forkbomb

$self->test_forkbomb();

Runs a script in SUT to create as many processes as possible, both as the SAP administrator and as root, and verifies that the SAP admin can create as many as 99% of the amount of processes that root can. Croaks if any of the commands sent to SUT fail, and record a soft failure if the SAP admin user cannot create as many processes as root.

test_version_info

$self->test_version_info();

Runs a sapcontrol command with function GetVersionInfo in SUT. Croaks on failure.

test_instance_properties

$self->test_instance_properties();

Runs a sapcontrol command with function GetInstanceProperties and verifies that the reported properties match with the SID stored in the class instance. Croaks on failure.

test_stop

$self->test_stop();

Tests with sapcontrol and functions Stop and StopService that the instance and services are succesfully stopped. Croaks on failure.

test_start

$self->test_start();

Tests with sapcontrol and functions Start and StartService that the instance and services are succesfully started. Croaks on failure.

check_service_state

$self->check_service_state( $state );

Checks in the process table of SUT for sapstartsrv up to the number of seconds specified in the WAIT_INSTANCE_STOP_TIME setting (defaults to 300, with a maximum permitted value of 600). The $state argument can be either start or stop, and it controls whether this method waits for the process to appear in the process table after service was started, or disappear from the process table after service was stopped. Croaks on failure.

check_instance_state

$self->check_instance_state( $state );

Uses sapcontrol functions GetSystemInstanceList and GetProcessList to check for up to the number of seconds defined in the WAIT_INSTANCE_STOP_TIME setting (defaults to 300, with a maximum permitted value of 600), whether the instance is in the state specified by the $state argument. This argument can be either green or gray, and it controls whether this method waits for the instance to turn to green status after a start or to turn to gray status after a stop. Croaks on failure.

check_replication_state

$self->check_replication_state();

Check status of the HANA System Replication by running the systemReplicationStatus.py script in SUT. Waits for 5 minutes for HANA System Replication to be in Active state or croaks on timeout.

Note: can only be run on active node in the cluster.

systemReplicationStatus.py return codes are: 10: No System Replication 11: Error 12: Unknown 13: Initializing 14: Syncing 15: Active

check_hanasr_attr

$self->check_hanasr_attr();

Runs SAPHanaSR-showAttr and checks in its output for up to a timeout specified in the named argument timeout (defaults to 90 seconds) that the sync_state is SOK. It also checks that no SFAIL sync_status is present in the output. Finishes by printing the full output of SAPHanaSR-showAttr. This method will only fail if SAPHanaSR-showAttr returns a non-zero return value.

check_landscape

$self->check_landscape();

Runs lanscapeHostConfiguration.py and records the information.

reboot

$self->reboot();

Restart the SUT and reconnect to the console right after.

do_hana_sr_register

$self->do_hana_sr_register( node => $node );

Register current HANA node to the node specified by the named argument node. With the named argument proceed_on_failure set to 1, method will use script_run and return the return value of the script_run call even if sr_register command fails, otherwise assert_script_run is used and the method croaks on failure.

do_hana_takeover

$self->do_hana_takeover( node => $node [, manual_takeover => $manual_takeover] [, cluster => $cluster] [, timeout => $timeout] );

Do a takeover/takeback on a HANA cluster.

Set $node to the node where HANA is/should be the primary server.

Set $manual_takeover to true, so the method performs a manual rather than an automatic takeover. Defaults to false.

Set $cluster to true so the method runs also a crm resource cleanup. Defaults to false.

Set $timeout to the amount of seconds the internal calls will wait for. Defaults to 300 seconds.

install_libopenssl_legacy

$self->install_libopenssl_legacy( $hana_path );

Install libopenssl1_0_0 for older (<SPS03) HANA versions on SLE15+

Set $hana_path to the path where the HANA installation media is located; this path should contain information on the HANA version to install, so prepare it thinking on this. For example: nfs://sap.sources.host.local/HANA2-SPS5rev52/. This method will then determine the HANA version from $hana_path and decide based on the SLES and HANA versions whether libopenssl1_0_0 must be installed.

upload_hana_install_log

$self->upload_hana_install_log();

Package and upload HANA installation logs from SUT.

upload_nw_install_log

$self->upload_nw_install_log();

Upload NetWeaver installation logs from SUT.

startup_type

$self->startup_type();

Record whether the SAP workload was started via sapinit or systemd units.

prepare_swpm

$self->prepare_swpm(sapcar_bin_path=>$sapcar_bin_path,
   sar_archives_dir=>$sar_archives_dir,
   swpm_sar_filename=>$swpm_sar_filename,
   target_path=>$target_path);

Unpacks and prepares swpm package from specified source dir into target directory using SAPCAR tool. After extraction it checks for 'sapinst' executable being present in target path. Croaks if executable is missing.

sapcar_bin_path Filename with full path to SAPCAR binary

sar_archives_dir Directory which contains all required SAR archives (SWPM, SAP kernel, Patches, etc...)

swpm_sar_filename SWPM SAR archive filename

target_path Target path for archives to be unpacked into

prepare_sapinst_profile

$self->prepare_sapinst_profile(
   profile_target_file=>$profile_target_file,
   profile_template_file=>$profile_template_file,
   sar_location_directory=>$sar_location_directory);

Copies sapinst profile template from NFS to target dir and fills in required variables.

profile_target_file Full filename and path for sapinst install profile to be created

profile_template_file Template file location from which will the profile be sceated

sar_location_directory Location of SAR files - this is filled into template

prepare_sap_instances_data

$self->prepare_sap_instances_data();

Prepares data for installation of all SAP components using openqa parameter "SAP_INSTANCES". parameter example: SAP_INSTANCES = "ASCS,ERS,PAS,AAS".

HDB = Hana database export - netweaver component, not database

ASCS = Central services

ERS = Enqueue replication

PAS = Primary application server

AAS = Additional application server

get_nw_instance_name

$self->get_nw_instance_name(instance_type=>$instance_type, instance_id=>$instance_id);

Returns standard sap instance directory name constructed from instance id and instance type.

instance_type Instance type (ASCS, ERS, PAS, AAS)

instance_id Instance ID - two digit number

is_instance_type_supported

$self->is_instance_type_supported($instance_type);

Checks if instance type is supported. Returns $instance_type with sucess, croaks with missing argument or unsupported value detected.

instance_type Instance type (ASCS, ERS, PAS, AAS)

share_hosts_entry

$self->share_hosts_entry(virtual_hostname=>$virtual_hostname,
                         virtual_ip=>$virtual_ip,
                         shared_directory_root=>shared_directory_root);

Creates file with virtual IP and hostname entry for /etc/hosts file on mounted shared device (Default: /sapmnt). This is to help creating /etc/hosts file which would include entries for all nodes.

File name: <INSTANCE_TYPE>

File content: <virtual IP> <virtual_hostname>

virtual_hostname Virtual hostname (alias) which is tied to instance and will be moved with HA IP addr resource

virtual_ip Virtual IP addr tied to an instance and HA resource

shared_directory_root Shared directory available for all instances. Separate directory 'hosts' will be created

add_hosts_file_entries

$self->add_hosts_file_entries();

Reads files in 'HOSTS_SHARED_DIRECTORY' and adds entries into /etc/hosts file.

get_sidadm

$self->get_sidadm([must_exist=>$must_exist]);

Returns sidadm username created from SAP sid - parameter INSTANCE_SID. check_if_exists - if set to true, test will fail if user does not exist. tests inconsistency between OpenQA parameter and real username

must_exist Checks if sidadm exists, croaks on failure. Default 'false'

sap_show_status_info

$self->sap_show_status_info(cluster=>1, netweaver=>1);

Prints output for standard set of commands to show info about system in various stages of the test for troubleshooting. It is possible to activate or deactivate various output sections by named args:

cluster - Shows cluster related outputs

netweaver - Shows netweaver related outputs

sapcontrol

$self->sapcontrol(instance_id=>$instance_id,
   webmethod=>$webmethod,
   [additional_args=>$additional_args,
   remote_execution=>$remote_execution]);

Executes sapcontrol webmethod for instance specified in arguments and returns exit code received from command. Allows remote execution of webmethods between instances, however not all webmethods are possible to execute in that manner.

Sapcontrol return codes:

RC 0 = webmethod call was successfull
RC 1 = webmethod call failed
RC 2 = last webmethod call in progress (processes are starting/stopping)
RC 3 = all processes GREEN
RC 4 = all processes GREY (stopped)

instance_id 2 digit instance number

webmethod webmethod name to be executed (Ex: Stop, GetProcessList, ...)

additional_args additional arguments to be appended at the end of command

return_output returns output instead of RC

remote_hostname hostname of the target instance for remote execution. Local execution does not need this.

sidadm_password Password for sidadm user. Only required for remote execution.

sapcontrol_process_check

$self->sapcontrol_process_check(expected_state=>expected_state,
   [instance_id=>$instance_id,
   loop_sleep=>$loop_sleep,
   timeout=>$timeout,
   wait_for_state=>$wait_for_state]);

Runs "sapcontrol -nr <INST_NO> -function GetProcessList" via SIDadm and compares RC against expected state. Croaks if state is not correct.

Expected return codes are:

RC 0 = webmethod call was successfull
RC 1 = webmethod call failed (This includes NIECONN_REFUSED status)
RC 2 = last webmethod call in progress (processes are starting/stopping)
RC 3 = all processes GREEN
RC 4 = all processes GREY (stopped)

Method arguments:

expected_state State that is expected (failed, started, stopped)

instance_id Instance number - two digit number

loop_sleep sleep time between checks - only used if 'wait_for_state' is true

timeout timeout for waiting for target state, after which function croaks

wait_for_state If set to true, function will wait for expected state until success or timeout

get_remote_instance_number

$self->get_instance_number(instance_type=>$instance_type);

Finds instance number from remote instance using sapcontrol "GetSystemInstanceList" webmethod. Local system instance number is required to execute sapcontrol though.

instance_type Instance type (ASCS, ERS) - this can be expanded to other instances

get_instance_profile_path

$self->get_instance_profile_path(instance_type=>$instance_type, instance_id=$instance_id);

Returns full instance profile path for specified instance type

instance_type Instance type (ASCS, ERS, PAS, AAS)

instance_id Instance number - two digit number

load_ase_env

$self->load_ase_env

Loads environment variables from ASE installation into the current shell session.

upload_ase_logs

$self->upload_ase_logs

Save and upload to openQA the SAP ASE installation logs. These are typically located in /opt/sap/log and /opt/sap/$SYBASE_ASE/install but depend on the response file used during installation.