lib/sles4sap/ipaddr2.pm
SYNOPSIS
Library to manage ipaddr2 tests
ipaddr2_azure_resource_group
my $rg = ipaddr2_azure_resource_group();
Get the Azure resource group name for this test
ipaddr2_azure_storage_account
my $storage account = ipaddr2_azure_storage_account();
Get a unique storage account name. Not including the jobId result in error like: The storage account named ip2tstorageaccount already exists under the subscription
ipaddr2_azure_deployment
my $rg = ipaddr2_azure_deployment();
Create a deployment in Azure designed for this specific test.
1. Create a resource group to contain all 2. Create a vnet and subnet in it 3. Create one Public IP 4. Create 2 VM to run the cluster, both running a web server and that are behind the LB 5. Create 1 additional VM that get 6. Create a Load Balancer with 2 VM in backend and with an IP as frontend
- region - existing resource group
-
- os - existing Load balancer NAME
-
- diagnostic - enable diagnostic features if 1
-
- cloudinit - enable cloud-init features if 1. This feature is used to install the web server using cloud-init, by providing an external cloud-init config file. This feature cannot be used for BYOS images as installing additional packages is not supported before the image registration. This feature could be problematic when testing maintenance update: problem is that the config file also perform a `zypper patch`. It happens at the first boot during the deployment so before any other part of the test can add additional repo to test.
-
- scc_code - if cloudinit is enabled, it is also possible to add register command in it. This argument is just ignored if cloudinit is 0. This argument become mandatory is cloudinit is 1 and image is BYOS. This is because cloud-init also try to install nginx, but installing packages is not possible for BYOS images, before registering.
-
ipaddr2_bastion_pubip
my $bastion_ip = ipaddr2_bastion_pubip();
Get the only public IP in the deployment associated to the VM used as bastion.
ipaddr2_bastion_ssh_addr
script_run(join(' ', 'ssh', ipaddr2_bastion_ssh_addr(), 'whoami');
Help to create ssh command that target the only VM in the deployment that has public IP.
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_bastion_key_accept
ipaddr2_bastion_key_accept()
For the worker to accept the ssh key of the bastion
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_internal_key_accept
ipaddr2_internal_key_accept()
For the worker to accept the ssh key of the internal VMs
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_internal_key_gen
ipaddr2_internal_key_gen()
Create, on the /tmp folder of the Worker, two ssh key set. One ssk key pair for each internal VM Then upload in each internal VM the ssh key pair using scp in Proxy mode
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_deployment_sanity
ipaddr2_deployment_sanity()
Run some checks on the existing deployment using the az command line. die in case of failure
ipaddr2_os_sanity
ipaddr2_os_sanity()
Run some OS level checks on the various VMs composing the deployment. die in case of failure. Tests are targeting all the VM. Tests are independent by the cluster status.
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_cluster_sanity
ipaddr2_cluster_sanity()
Run some cluster level checks...
- id - ID of the internal VM where to run the crm commands. Default is 1.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_os_connectivity_sanity
ipaddr2_os_connectivity_sanity()
Run some OS level checks about internal connectivity. die in case of failure
- bastion has to be able to ping the internal VM using the internal private IP - bastion has to be able to ping the internal VM using the internal VM hostname
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_os_cloud_init_sanity
ipaddr2_os_cloud_init_sanity()
Run some checks about cloud-init
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_os_cloud_init_logs
ipaddr2_os_cloud_init_logs()
Collect some cloud-init related logs
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_os_network_sanity
ipaddr2_os_network_sanity()
Check that private IP are in the network configuration on the internal VMs
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_os_ssh_sanity
ipaddr2_os_ssh_sanity()
Run some OS level checks on the various VMs ssh keys and configurations. die in case of failure
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_ssh_bastion_assert_script_run
ipaddr2_ssh_bastion_assert_script_run(
bastion_ip => '1.2.3.4',
cmd => 'whoami');
run a command on the bastion using assert_script_run
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- cmd - command to run there
-
ipaddr2_ssh_bastion_script_run
my $ret = ipaddr2_ssh_bastion_script_run(
bastion_ip => '1.2.3.4',
cmd => 'whoami');
run a command on the bastion using script_run
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- cmd - command to run there
-
ipaddr2_ssh_bastion_script_output
my $ret = ipaddr2_ssh_bastion_script_output(
bastion_ip => '1.2.3.4',
cmd => 'whoami');
run a command on the bastion using script_output
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- cmd - command to run there
-
ipaddr2_ssh_internal_cmd
script_run(ipaddr2_ssh_internal_cmd(
id => 2,
bastion_ip => '1.2.3.4',
cmd => 'whoami'));
Compose an ssh command. Command is composed to be executed on one of the two internal VM. Command will use -J option to use the bastion as a proxy. This function does not really execute any command, it only return a string. Other functions can use result command string as input for various testapi functions, like assert_script_run or script_output.
- id - ID of the internal VM. Used to compose its name and as address for ssh.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- cmd - Command to be run on the internal VM.
-
ipaddr2_ssh_internal
ipaddr2_ssh_internal(
id => 2,
bastion_ip => '1.2.3.4',
cmd => 'whoami');
run a command on one of the two internal VM through the bastion using the assert_script_run API
- id - ID of the internal VM. Used to compose its name and as address for ssh.
-
- cmd - Command to be run on the internal VM.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- timeout - Execution timeout, default 90sec
-
ipaddr2_ssh_internal_output
ipaddr2_ssh_internal_output(
id => 2,
bastion_ip => '1.2.3.4',
cmd => 'whoami');
Runs $cmd through the bastion on one of the two internal VMs using script_output. Return the command output.
- id - ID of the internal VM. Used to compose its name and as address for ssh.
-
- cmd - Command to be run on the internal VM.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
- timeout - Execution timeout, default 90sec
-
ipaddr2_create_cluster
ipaddr2_create_cluster();
Initialize and configure the Pacemaker cluster on the two internal nodes
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_registeration_check
my $is_registered = ipaddr2_registeration_check(id => 1);
Check if image is registered. Return 1 is it is registered, 0 if at least one is not.
- id - VM id where to install and configure the web server
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_registeration_set
ipaddr2_registeration_set(id => 1, scc_code => '1234567890');
Register the image. Notice that this library also support registration through ipaddr2_azure_deployment
- id - VM id where to install and configure the web server
-
- scc_code - registration code
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_configure_web_server(id => 1);
This function is in charge to: 1. install the nginx package 2. create a web page file 3. enable and start the system
- id - VM id where to install and configure the web server
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_deployment_logs
ipaddr2_deployment_logs()
Collect logs from the cloud infrastructure
ipaddr2_destroy
ipaddr2_destroy();
Destroy the deployment by deleting the resource group
ipaddr2_get_internal_vm_name
my $vm_name = ipaddr2_get_internal_vm_name(id => 42);
compose and return a string for the vm name
- id - VM id number
-
ipaddr2_get_internal_vm_private_ip
my $private_ip = ipaddr2_get_internal_vm_private_ip(id => 42);
compose and return a string representing the VM private IP
- id - VM id number
-
ipaddr2_get_worker_tmp_for_internal_vm
my $vm_tmp = ipaddr2_get_worker_tmp_for_internal_vm(42);
Return a path in /tmp of the worker used to store files associated two one of the internal VM
ipaddr2_crm_move
ipaddr2_crm_move(destination => 2);
move the rsc_web_00 resource to the indicated node
- destination - VM id where to move the rsc_web_00 resource
-
- id - VM id where to run the command, not so important as long as it is in the cluster. Default 1.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_crm_clear
ipaddr2_crm_clear();
clear all location constrain used during the test
- id - VM id where to run the command, not so important as long as it is in the cluster. Default 1.
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_wait_for_takeover
die "Takeover does not happens in time" unless ipaddr2_wait_for_takeover(destination => 2);
Wait that web server is responding from the node indicated by id. This check is implemented running a curl request from the bastion and using the virtual IP address ar URL. This is possible because the webserver on each node is configured to return its hostname in the response. Return 1 as soon as it gets the id in the response. Return 0 if not within 10 minutes.
- destination - VM id that from where the web server response is expected to come from
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_get_web
ipaddr2_get_web(str_match => 'openqa_vm_01');
Runs a curl request from the bastion and using the virtual IP address as URL. Return result of searching str_match in the curl response
- web_url - webserver url
-
- str_match - string to search in the curl output
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_test_master_vm
ipaddr2_test_master_vm(id => 2);
Check the status on the VM that is supposed to have the resources.
- id - VM id that is expected to be master
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-
ipaddr2_test_other_vm
ipaddr2_test_other_vm(id => 1);
Check the status on the VM that is supposed not to have the resources.
- id - VM id that is expected not to be master
-
- bastion_ip - Public IP address of the bastion. Calculated if not provided. Providing it as an argument is recommended in order to avoid having to query Azure to get it.
-