From 2adee423714ce63b1e7fe1df893b5d7e9c69e15b Mon Sep 17 00:00:00 2001 From: Michele Pagot Date: Wed, 24 Jul 2024 16:10:01 +0200 Subject: [PATCH] Add registration to IpAddr2 test Optionally add registration. Enabled by IPADDR2_REGISTER configured to 1. The SCC code has to be provided in SCC_REGCODE_SLES4SAP. Add code to wait for ssh stable connection to internal VMs. --- lib/sles4sap/ipaddr2.pm | 29 ++++++++++++++++++++--------- t/22_ipaddr2.t | 1 + tests/sles4sap/ipaddr2/configure.pm | 1 - 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/sles4sap/ipaddr2.pm b/lib/sles4sap/ipaddr2.pm index c8ae62e566ff..1a9eb88c842f 100644 --- a/lib/sles4sap/ipaddr2.pm +++ b/lib/sles4sap/ipaddr2.pm @@ -827,7 +827,6 @@ sub ipaddr2_ssh_bastion_assert_script_run { "'$args{cmd}'")); } - =head2 ipaddr2_ssh_bastion_script_run my $ret = ipaddr2_ssh_bastion_script_run( @@ -939,15 +938,17 @@ sub ipaddr2_ssh_internal_cmd { run a command on one of the two internal VM through the bastion using the assert_script_run API -=over 3 +=over 4 =item B - ID of the internal VM. Used to compose its name and as address for ssh. +=item B - Command to be run on the internal VM. + =item B - 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. -=item B - Command to be run on the internal VM. +=item B - Execution timeout, default 90sec =back =cut @@ -957,11 +958,14 @@ sub ipaddr2_ssh_internal { foreach (qw(id cmd)) { croak("Argument < $_ > missing") unless $args{$_}; } $args{bastion_ip} //= ipaddr2_bastion_pubip(); + $args{timeout} //= 90; - assert_script_run(ipaddr2_ssh_internal_cmd( + assert_script_run( + ipaddr2_ssh_internal_cmd( id => $args{id}, bastion_ip => $args{bastion_ip}, - cmd => $args{cmd})); + cmd => $args{cmd}), + timeout => $args{timeout}); } =head2 ipaddr2_ssh_internal_output @@ -974,15 +978,17 @@ sub ipaddr2_ssh_internal { Runs $cmd through the bastion on one of the two internal VMs using script_output. Return the command output. -=over 3 +=over 4 =item B - ID of the internal VM. Used to compose its name and as address for ssh. +=item B - Command to be run on the internal VM. + =item B - 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. -=item B - Command to be run on the internal VM. +=item B - Execution timeout, default 90sec =back =cut @@ -992,11 +998,14 @@ sub ipaddr2_ssh_internal_output { foreach (qw(id cmd)) { croak("Argument < $_ > missing") unless $args{$_}; } $args{bastion_ip} //= ipaddr2_bastion_pubip(); + $args{timeout} //= 90; - return script_output(ipaddr2_ssh_internal_cmd( + return script_output( + ipaddr2_ssh_internal_cmd( id => $args{id}, bastion_ip => $args{bastion_ip}, - cmd => $args{cmd})); + cmd => $args{cmd}), + timeout => $args{timeout}); } =head2 ipaddr2_create_cluster @@ -1084,6 +1093,8 @@ sub ipaddr2_registeration_check { croak("Argument < id > missing") unless $args{id}; $args{bastion_ip} //= ipaddr2_bastion_pubip(); + + # Initially suppose is registered my $registered = 1; my $json = decode_json(ipaddr2_ssh_internal_output( id => $args{id}, diff --git a/t/22_ipaddr2.t b/t/22_ipaddr2.t index 05ba188502d1..60de51c9672a 100644 --- a/t/22_ipaddr2.t +++ b/t/22_ipaddr2.t @@ -424,4 +424,5 @@ subtest '[ipaddr2_registeration_set]' => sub { ok((any { /registercloudguest.*clean/ } @calls), 'registercloudguest clean'); ok((any { /registercloudguest.*-r.*1234567890/ } @calls), 'registercloudguest register'); }; + done_testing; diff --git a/tests/sles4sap/ipaddr2/configure.pm b/tests/sles4sap/ipaddr2/configure.pm index 8eadef5fc78c..d855955d489b 100644 --- a/tests/sles4sap/ipaddr2/configure.pm +++ b/tests/sles4sap/ipaddr2/configure.pm @@ -46,7 +46,6 @@ sub run { } } - record_info("TEST STAGE", "Init and configure the Pacemaker cluster"); ipaddr2_create_cluster(bastion_ip => $bastion_ip); }