Skip to content

Commit

Permalink
PC new logs added in regristration cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
m-dati committed Jan 8, 2025
1 parent ad15b16 commit 7c1fc90
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/publiccloud/basetest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,16 @@ sub post_fail_hook {
);
return;
}

$self->post_fail_logs();
$self->_cleanup() unless $self->{cleanup_called};
}

sub post_fail_logs {
script_run("gpg -c --batch --passphrase $testapi::password --output /tmp/SCCcredentials.gpg /etc/zypp/credentials.d/SCCcredentials");
script_run('tar -cvzf /tmp/post_fail_logs.tgz /etc/hosts /var/log/cloudregister /tmp/SCCcredentials.gpg');
upload_logs('/tmp/post_fail_logs.tgz', failok => 1, log_name => 'post_fail_logs.tgz');
}

sub post_run_hook {
my ($self) = @_;
$self->_cleanup() unless $self->{cleanup_called};
Expand Down
11 changes: 10 additions & 1 deletion tests/publiccloud/registration.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,21 @@ sub run {

sub cleanup {
my ($self) = @_;
$self->{instance}->upload_log('/var/log/cloudregister', log_name => $autotest::current_test->{name} . '-cloudregister.log');
$self->{instance}->registration_logs();
if (is_azure()) {
record_info('azuremetadata', $self->{instance}->run_ssh_command(cmd => "sudo /usr/bin/azuremetadata --api latest --subscriptionId --billingTag --attestedData --signature --xml"));
}
}

sub registration_logs {
my ($instance) = @_;
# encrypt the credentials
$instance->run_ssh_command(cmd => "sudo gpg -c --batch --passphrase $testapi::password --output /tmp/SCCcredentials.gpg /etc/zypp/credentials.d/SCCcredentials");
$instance->upload_log('/tmp/SCCcredentials.gpg', log_name => $autotest::current_test->{name} . '-scc_credentials.gpg');
$instance->upload_log('/etc/hosts', log_name => $autotest::current_test->{name} . '-hosts.txt');
$instance->upload_log('/var/log/cloudregister', log_name => $autotest::current_test->{name} . '-cloudregister.txt');
}

sub test_flags {
return {fatal => 1, publiccloud_multi_module => 1};
}
Expand Down

0 comments on commit 7c1fc90

Please sign in to comment.