ssh_script_retry(command[, retry => 3][, delay => 10][, timeout => 90][, ssh_opts =>'..'][, username => 'XXX']);
Run a command via ssh in the given PC instance until it succeeds or the given number of retries is exhausted and an exception is thrown. Timeout can be set by timeout or 90 sec by default. The command is passed in single quotes to SSH. With <ssh_opts='...'>> you can overwrite all default ops which are in <$instance-ssh_opts>>. Use argument username to specify a different username then <$instance-username()>>.
This function is deprecated. Please use ssh_script_retry instead.
C<args> - reference to args hash. it is important to pass reference so function can modify timeout passed to script_run by the caller
to make sure it is bigger than value defined in timeout command which suppose to kill what script_run needs to execute
C<ssh_cmd> - reference to string containing command which will be executed by script_run. function will tweak it to include timeout call
which will kill underlying command after time defined by args{timeout}
ssh_script_run($cmd [, timeout => $timeout] [,quiet => $quiet] [,ssh_opts => $ssh_opts] [,username => $username][, apply_graceful_timeout => $apply_graceful_timeout])
C<timeout> - TTL for command execution measured in seconds . After that period of time execution will be aborded
C<quiet> - avoid recording serial_results ( value pass to script_run call)
C<ssh_opts> - additional ssh options passed to ssh
C<username> - username used for ssh tunnel
C<apply_graceful_timeout> - in case waiting longer than timeout normally script_run will die. Setting this parameter to true
will avoid such failure
Runs a command cmd via ssh on the publiccloud instance and returns the return code, using testapi::script_run.
ssh_assert_script_run($cmd [, timeout => $timeout] [, fail_message => $fail_message] [,quiet => $quiet] [,ssh_opts => $ssh_opts] [,username => $username][, apply_graceful_timeout => $apply_graceful_timeout])
Runs a command cmd via ssh on the publiccloud instance and die on error.
Use the parameters of ssh_script_run.
ssh_script_output($script [, $wait, type_command => 1, proceed_on_failure => 1] [,quiet => $quiet] [,ssh_opts => $ssh_opts] [,username => $username])
Executing script inside SUT with bash -eo and directs stdout (but not stderr!) to the serial console and returns the output if the script exits with 0. Otherwise the test is set to failed.
ssh_script_retry($cmd, [expect => $expect], [retry => $retry], [delay => $delay], [timeout => $timeout], [die => $die] [,ssh_opts => $ssh_opts] [,username => $username])
Repeat command until expected result or timeout.
scp($from, $to [, timeout => 90] [, proceed_on_failure => 0][, apply_graceful_timeout => $apply_graceful_timeout]);
Copy a file to or from this instance using scp.
Arguments:
$from - source path. When it starts with remote:, the prefix is replaced with <username>@<public_ip>: so the file is read from this instance (download). Otherwise it is treated as a local path. Using remote: is only a convenience: you are free to pass an explicit user@host:/path instead, which is left untouched by this function.
$to - destination path. Uses the same remote: rewriting as $from, so a remote: destination uploads a local file to this instance. As with $from, an explicit user@host:/path can be passed and is left untouched.
timeout - maximum time in seconds allowed for the scp command. Defaults to SSH_TIMEOUT (90 seconds).
proceed_on_failure - when set to a true value a failing scp does not abort the test: the command is run via script_run and only an informational message is recorded. When false (the default) the copy is run via assert_script_run so a failure dies. Defaults to 0.
apply_graceful_timeout - same parameter as ssh_script_run.
Any -E <file> logging options present in $instance->ssh_opts are stripped, because scp does not accept them.
E.g. to download the file /var/log/cloudregister into /tmp:
$instance->scp('remote:/var/log/cloudregister', '/tmp');
and to upload a local /tmp/foo to the instance home directory:
$instance->scp('/tmp/foo', 'remote:/home/user/foo');
upload_log($filename);
Upload a file from this instance to openqa using upload_logs(). If the file doesn't exists on the instance, no error is thrown.
upload_check_logs_tar(@files);
Check remote log files status and upload tar.gz of only ok logs, to oqa UI.
Input: @files full-path-files array;
Return 1 true explicit, as stateless and never impact calling code.
wait_for_guestregister([timeout => 300]);
Run command systemctl is-active guestregister on the instance in a loop and wait till guestregister is ready. If guestregister finish with state failed, a soft-failure will be recorded. If guestregister will not finish within timeout seconds, job dies. In case of BYOS images we checking that service is inactive and quit Returns the time needed to wait for the guestregister to complete.
update_instance_ip(timeout => 600)
This subroutine checks the public IP cloud provider provides for the VM. When the IP differs from `$self->public_ip` we update `$self->public_ip`.
isok($exit_code);
To convert in a true or 1 value for perl tests the exit_code 0 of shell script ok.
Return: the positive test status of a shell exit code, that is true(1) and ok when its value is defined and zero: $x == 0 otherwise false(undef).
($shutdown_time, $bootup_time) = softreboot([timeout => 600] [, scan_ssh_host_key => ?]);
Does a softreboot of the instance by running the command shutdown -r. Return an array of two values, first one is the time till the instance isn't reachable anymore. The second one is the estimated bootup time.
stop();
Stop the instance using the CSP api calls.
start([timeout => ?] [, scan_ssh_host_key => ?]);
Start the instance and wait for the system to be up. Returns the number of seconds till the system up and running.
get_state();
Get the status of the instance using the CSP api calls.
network_speed_test();
Test the network speed.
check_system_boottime();
Check the system boot time, measured by systemd-analyze, to be under a threshold. Assign the threshold in seconds to PUBLIC_CLOUD_BOOTTIME_MAX in test settings. The boot time is saved in a local json structure, then printed in the test's logs: when the threshold is exceeded the job is stopped. The routine is skipped when the threshold is undefined or zero.