lib/sles4sap_publiccloud.pm
DESCRIPTION
Package with common methods and default or constant values for sles4sap tests in the cloud
run_cmd run_cmd(cmd => 'command', [runas => 'user', timeout => 60]);
Runs a command C<cmd> via ssh in the given VM and log the output.
All commands are executed through C<sudo>.
If 'runas' defined, command will be executed as specified user,
otherwise it will be executed as root.
- cmd - command string to be executed remotely
-
- timeout - command execution timeout
-
- title - used in record_info
-
- runas - pre-pend the command with su to execute it as specific user
-
- ... - pass through all other arguments supported by run_ssh_command
-
Checks and returns hostname of HANA promoted node according to crm shell output.
sles4sap_cleanup
Clean up Network peering and qesap deployment
This method does not internally die and try to execute
terraform destroy in any case.
Return 0 if no internal error.
- cleanup_called - flag to indicate cleanup status
-
- network_peering_present - flag to indicate network peering presence
-
- ansible_present - flag to indicate ansible has need executed as part of the deployment
-
get_hana_topology Parses command output, returns hash of hashes containing values for each host.
is_hana_online is_hana_online([timeout => 120, wait_for_start => 'false']);
Check if hana DB is online.
- wait_for_start - Define 'wait_for_start' to wait for DB to start.
-
- timeout - timeout for the wait of the online state
-
is_hana_resource_running is_hana_resource_running([quiet => 0]);
Checks if resource msl_SAPHanaCtl_* is running on given node.
- quiet - if set, returns the value without recording info (default: 0)
-
is_hana_node_up is_hana_node_up($my_instance, [timeout => 900]);
Waits until 'is_system_running' returns successfully on the target instance.
- instance - the instance the test needs to wait for
-
- timeout - how much time to wait for before aborting
-
stop_hana stop_hana([timeout => $timeout, method => $method]);
Stops HANA database using default or specified method.
"stop" - stops database using "HDB stop" command.
"kill" - kills database processes using "HDB -kill" command.
"crash" - crashes entire OS using "/proc/sysrq-trigger" method.
- method - Allow to specify a specific stop method
-
- timeout - only used for stop and kill
-
start_hana start_hana([timeout => 60]);
Start HANA DB using "HDB start" command
cleanup_resource cleanup_resource([timeout => 60]);
Cleanup resource 'msl_SAPHanaCtl_*', wait for DB start automatically.
- timeout - timeout for waiting resource to start
-
check_takeover check_takeover();
Checks takeover status and waits for finish until successful or reaches timeout.
enable_replication enable_replication([site_name => 'site_a']);
Enables replication on fenced database. Database needs to be offline.
- site_name - site name of the site to register
-
get_replication_info get_replication_info();
Parses "hdbnsutil -sr_state" command output.
Returns hash of found values converted to lowercase and replaces spaces to underscores.
Retrieves hostname from currently promoted (Master) database and returns instance data from $self->{instances}.
wait_for_sync wait_for_sync([timeout => $timeout]);
Wait for replica site to sync data with primary.
Checks "SAPHanaSR-showAttr" output and ensures replica site has "sync_state" "SOK && PRIM" and no SFAIL.
Continue after expected output matched N times continually to make sure cluster is synced.
Expected conditions:
- Both primary and replica must be online.
- primary must have sync_state 'PRIM'
- primary must have clone_state 'PROMOTED'
- replica must have sync_state 'SOK' - this means data is in sync
- replica must have clone_state 'DEMOTED'
- site order does not matter
- timeout - timeout for waiting sync state
-
wait_for_pacemaker wait_for_pacemaker([timeout => $timeout]);
Checks status of pacemaker via systemd 'is-active' command an waits for startup.
- timeout - timeout for waiting for pacemaker service
-
change_sbd_service_timeout $self->change_sbd_service_timeout(service_timeout => '30');
Overrides timeout for sbd systemd service to a value provided by argument.
This is done by creating or changing file "/etc/systemd/system/sbd.service.d/sbd_delay_start.conf"
- service_timeout - value for the TimeoutSec setting
-
setup_sbd_delay_publiccloud $self->setup_sbd_delay_publiccloud();
Set (activate or deactivate) SBD_DELAY_START setting in /etc/sysconfig/sbd.
Delay is used in case of cluster VM joining cluster too quickly after fencing operation.
For more information check sbd man page.
Setting is changed via OpenQA parameter: HA_SBD_START_DELAY
Possible values:
"no" - do not set and turn off SBD delay time
"yes" - sets default SBD value which is calculated from a formula
"<number of seconds>" - sets specific delay in seconds
Returns integer representing wait time.
return calculated sbd delay
cloud_file_content_replace cloud_file_content_replace(filename => $filename, search_pattern => $search_pattern, replace_with => $replace_with);
Replaces file content direct on PC SUT. Similar to lib/utils.pm file_content_replace()
- filename - file location
-
- search_pattern - search pattern
-
- replace_with - string to replace
-
create_instance_data
Create and populate a list of publiccloud::instance and publiccloud::provider compatible
class instances.
- provider - Instance of PC object "provider", the one usually created by provider_factory()
-
deployment_name
Return a string to be used as value for the deployment_name variable
in the qe-sap-deployment.
delete_network_peering
Delete network peering between SUT created with qe-sa-deployment
and the IBS Mirror. Function is generic over all the Cloud Providers
create_ansible_playbook_list
Detects HANA/HA scenario from function arguments and returns a list of ansible playbooks to include
in the "ansible: create:" section of config.yaml file.
- ha_enabled - Enable the installation of HANA and the cluster configuration
-
- registration - select registration mode, possible values are * registercloudguest (default) * suseconnect * noreg skip scheduling of register.yaml at all
-
- scc_code - registration code
-
- ltss - name and reg_code for LTSS extension to register. This argument is a two element comma separated list string. Like: 'SLES-LTSS-Extended-Security/12.5/x86_64,123456789' First string before the comma has to be a valid SCC extension name, later used by Ansible as argument for SUSEConnect or registercloudguest argument. Second string has to be valid registration code for the particular LTSS extension.
-
- fencing - select fencing mechanism
-
- fence_type - select Azure native fencing mechanism. Only two accepted values 'spn' or 'msi'. This argument is only applicable to Azure. (optional)
-
- spn_application_id - Application ID for the SPN Azure native fencing agent.This argument is only applicable to Azure configured with native fencing of type SPN. (optional)
-
- spn_application_password - password for the SPN Azure native fencing agent.This argument is only applicable to Azure configured with native fencing of type SPN. (optional)
-
- ptf_files - list of PTF files (optional)
-
- ptf_token - SAS token to access the PTF files (optional)
-
- ptf_account - name of the account for the ptf container (optional)
-
- ptf_container - name of the container for PTF files (optional)
-
azure_fencing_agents_playbook_args
azure_fencing_agents_playbook_args(
fence_type => 'spn'
spn_application_id=>$spn_application_id,
spn_application_password=>$spn_application_password
);
Collects data and creates string of arguments that can be supplied to playbook.
- FENCE_TYPE - Azure native fence type (spn|msi)
-
- SPN_APPLICATION_ID - application ID that allows API access for STONITH device
-
- SPN_APPLICATION_PASSWORD - password provided for application ID above
-
get_hana_site_names
Get primary and secondary site name.
This information is both needed to configure the qe-sap-deployment
and later in the test when calling `hdbnsutil -sr_register`.
This function mostly read the information from job settings
HANA_PRIMARY_SITE and HANA_SECONDARY_SITE, so main reason to have
it behind a function is to have coherent defaults.
create_hana_vars_section
Detects HANA/HA scenario from openQA variables and creates "terraform: variables:" section in config.yaml file.
display_full_status
$self->display_full_status()
Displays most useful debugging info about cluster status, database status within a 'record_info' test entry.
list_cluster_nodes
$self->list_cluster_nodes()
Returns list of hostnames that are part of a cluster using crm shell command from one of the cluster nodes.
get_hana_database_status
Run a query to the hana database, parses "hdbsql" command output and check if the connection still is alive.
Returns 1 if the response from hana database is online, 0 otherwise
- password_db - password
-
- instance_id - instance id
-
is_hana_database_online
Setup a timeout and check the hana database status is offline and there is not connection.
If the connection still is online run a wait and try again to get the status.
Returns 1 if the output of the hana database is online, 0 means that hana database is offline
- timeout - default 900
-
- total_consecutive_passes - default 5
-
is_primary_node_online
Check if primary node in a hana cluster is offline.
Returns if primary node status is offline with 0 and 1 online
- timeout - default 300
-
pacemaker_version
Returns the pacemaker version
saphanasr_showAttr_version
Returns the SAPHanaSR-showattr version
wait_for_cluster
Verifies that nodes are online, resources are started and DB is in sync
- wait_time - time to wait before retry in seconds, default 10
-
- max_retries - maximum number of retries, default 7
-
wait_for_zypper
The function attempts to run 'zypper ref' to check for a lock. If Zypper is locked, it waits for a specified delay before retrying.
Returns normally if Zypper is not locked or dies after a maximum number of retries if Zypper remains locked.
- $instance - The instance object on which the Zypper command is executed. This object must have the run_ssh_command method implemented.
-
- max_retries - The maximum number of times the function will retry checking if Zypper is locked. Default is 10.
-
- retry_delay - The number of seconds to wait between retries. Default is 20 seconds.
-
- timeout - The number of seconds to wait before aborting zypper ref
-
- runas - If 'runas' defined, command will be executed as specified user, otherwise it will be executed as cloudadmin.
-
wait_for_idle
The function wraps the `cs_wait_for_idle` command, and restarts in case of timeout (once, this
time fatal) after displaying cluster information.
- $timeout - The timeout (in seconds) for the command.
-