Repository: os-autoinst/os-autoinst-distri-opensuse
Pull request #21739: Improve reboot and logs in Agama
Author: login: jknphy
Labels: name: qe-yam
Created: 2025-04-08T14:21:34Z | Merged: 2025-04-09T05:32:07Z

This PR attempts to separate Page Object functionality and command line functionality.
Additionally makes optional the logs for hyper-v.


- Related PRs: 
  - https://github.com/os-autoinst/os-autoinst-distri-opensuse/pull/21724
  - https://github.com/os-autoinst/os-autoinst-distri-opensuse/pull/21726
- Verification run: https://openqa.suse.de/tests/overview?build=jknphy%2Fos-autoinst-distri-opensuse%23vmware-hyper-v&distri=sle&version=16.0



Diff:
diff --git a/lib/Distribution/Opensuse/AgamaDevel.pm b/lib/Distribution/Opensuse/AgamaDevel.pm
index fb16791420c6..2bfc63055ace 100644
--- a/lib/Distribution/Opensuse/AgamaDevel.pm
+++ b/lib/Distribution/Opensuse/AgamaDevel.pm
@@ -18,7 +18,6 @@ use Yam::Agama::Pom::GrubMenuTumbleweedPage;
 use Yam::Agama::Pom::GrubEntryEditionPage;
 use Yam::Agama::Pom::AgamaUpAndRunningPage;
 use Yam::Agama::Pom::RebootPage;
-use Yam::Agama::Pom::RebootTextmodePage;
 use Yam::Agama::Pom::EnterPassphraseBasePage;
 use Yam::Agama::Pom::EnterPassphraseForRootPage;
 use Yam::Agama::Pom::EnterPassphraseForSwapPage;
@@ -54,7 +53,6 @@ sub get_agama_up_an_running {
 }
 
 sub get_reboot {
-    return Yam::Agama::Pom::RebootTextmodePage->new() if is_s390x() || is_ppc64le();
     return Yam::Agama::Pom::RebootPage->new();
 }
 
diff --git a/lib/Yam/Agama/Pom/RebootTextmodePage.pm b/lib/Yam/Agama/Pom/RebootTextmodePage.pm
deleted file mode 100644
index 39348fcd9aa6..000000000000
--- a/lib/Yam/Agama/Pom/RebootTextmodePage.pm
+++ /dev/null
@@ -1,24 +0,0 @@
-# SUSE's openQA tests
-#
-# Copyright 2024 SUSE LLC
-# SPDX-License-Identifier: FSFAP
-
-# Summary: Handles installation reboot screen for textmode display.
-# Maintainer: QE YaST and Migration (QE Yam) <qe-yam at suse de>
-
-package Yam::Agama::Pom::RebootTextmodePage;
-use strict;
-use warnings;
-use power_action_utils 'power_action';
-
-sub new {
-    my ($class, $args) = @_;
-    return bless {}, $class;
-}
-
-sub reboot {
-    my ($self) = @_;
-    power_action('reboot', keepconsole => 1, first_reboot => 1);
-}
-
-1;
diff --git a/tests/yam/agama/agama.pm b/tests/yam/agama/agama.pm
index 4adfe87d38d3..38c0d6cc3c76 100644
--- a/tests/yam/agama/agama.pm
+++ b/tests/yam/agama/agama.pm
@@ -23,8 +23,9 @@ use testapi qw(
   select_console
   console
 );
-use Utils::Architectures qw(is_s390x);
+use Utils::Architectures qw(is_s390x is_ppc64le);
 use Utils::Backends qw(is_svirt);
+use power_action_utils 'power_action';
 
 sub run {
     my $self = shift;
@@ -52,12 +53,16 @@ sub run {
     return if get_var('INST_ABORT');
 
     # make sure we will boot from hard disk next time
-    if (is_s390x && is_svirt) {
+    if (is_s390x() && is_svirt()) {
         select_console 'installation';
         my $svirt = console('svirt')->change_domain_element(os => boot => {dev => 'hd'});
     }
 
-    $reboot_page->reboot();
+    (is_s390x() || is_ppc64le()) ?
+      # reboot via console
+      power_action('reboot', keepconsole => 1, first_reboot => 1) :
+      # graphical reboot
+      $reboot_page->reboot();
 }
 
 1;
diff --git a/tests/yam/agama/agama_auto.pm b/tests/yam/agama/agama_auto.pm
index 22f2c4821a2a..6a2d47b04c14 100644
--- a/tests/yam/agama/agama_auto.pm
+++ b/tests/yam/agama/agama_auto.pm
@@ -10,14 +10,23 @@ use strict;
 use warnings;
 
 use testapi;
+use Utils::Architectures qw(is_s390x is_ppc64le);
+use Utils::Backends qw(is_svirt is_hyperv);
+use power_action_utils 'power_action';
+use version_utils qw(is_vmware);
 
 sub run {
     my $self = shift;
     my $reboot_page = $testapi::distri->get_reboot();
 
     $reboot_page->expect_is_shown();
-    $self->upload_agama_logs();
-    $reboot_page->reboot();
+    $self->upload_agama_logs() unless is_hyperv();
+
+    (is_s390x() || is_ppc64le() || is_vmware()) ?
+      # reboot via console
+      power_action('reboot', keepconsole => 1, first_reboot => 1) :
+      # graphical reboot
+      $reboot_page->reboot();
 }
 
 1;


Reviews:
user: login: czerw
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-09T05:14:16Z
user: login: RoyCai7
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-09T05:28:46Z
user: login: jknphy
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-09T05:31:09Z
user: login: czerw
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-09T05:56:22Z

Review comments:
diff_hunk: @@ -52,12 +53,16 @@ sub run {
     return if get_var('INST_ABORT');
 
     # make sure we will boot from hard disk next time
-    if (is_s390x && is_svirt) {
+    if (is_s390x() && is_svirt()) {
         select_console 'installation';
         my $svirt = console('svirt')->change_domain_element(os => boot => {dev => 'hd'});
     }
 
-    $reboot_page->reboot();
+    (is_s390x() || is_ppc64le()) ?
+      # reboot via console
+      power_action('reboot', keepconsole => 1, first_reboot => 1) :
+      # graphical reboot
+      $reboot_page->reboot();
path: tests/yam/agama/agama.pm
user: login: czerw
body: Does it mean that it is rebooted twice? First reboot via console and second in gfx ui?
created_at: 2025-04-09T05:14:16Z
author_association: CONTRIBUTOR
diff_hunk: @@ -52,12 +53,16 @@ sub run {
     return if get_var('INST_ABORT');
 
     # make sure we will boot from hard disk next time
-    if (is_s390x && is_svirt) {
+    if (is_s390x() && is_svirt()) {
         select_console 'installation';
         my $svirt = console('svirt')->change_domain_element(os => boot => {dev => 'hd'});
     }
 
-    $reboot_page->reboot();
+    (is_s390x() || is_ppc64le()) ?
+      # reboot via console
+      power_action('reboot', keepconsole => 1, first_reboot => 1) :
+      # graphical reboot
+      $reboot_page->reboot();
path: tests/yam/agama/agama.pm
user: login: RoyCai7
body: if (is_s390x() || is_ppc64le()) {
    # reboot via console
    power_action('reboot', keepconsole => 1, first_reboot => 1);
} else {
    # graphical reboot
    $reboot_page->reboot();
}

If it is written in this way, it will be clearer, of course, without affecting anything.
created_at: 2025-04-09T05:28:46Z
author_association: CONTRIBUTOR
diff_hunk: @@ -52,12 +53,16 @@ sub run {
     return if get_var('INST_ABORT');
 
     # make sure we will boot from hard disk next time
-    if (is_s390x && is_svirt) {
+    if (is_s390x() && is_svirt()) {
         select_console 'installation';
         my $svirt = console('svirt')->change_domain_element(os => boot => {dev => 'hd'});
     }
 
-    $reboot_page->reboot();
+    (is_s390x() || is_ppc64le()) ?
+      # reboot via console
+      power_action('reboot', keepconsole => 1, first_reboot => 1) :
+      # graphical reboot
+      $reboot_page->reboot();
path: tests/yam/agama/agama.pm
user: login: jknphy
body: no, it is a ternary,  you have a condition at the beginning and then you have lines indented below with each option, it is really useful for having each line commented with something special you do, I prefer those than the typical `{ }` for this cases, it is less verbose, specially when you don't plan to have more complex actions in each line.
```
condition ?
  branch1 :
  branch2 :
```
created_at: 2025-04-09T05:31:09Z
author_association: CONTRIBUTOR
diff_hunk: @@ -52,12 +53,16 @@ sub run {
     return if get_var('INST_ABORT');
 
     # make sure we will boot from hard disk next time
-    if (is_s390x && is_svirt) {
+    if (is_s390x() && is_svirt()) {
         select_console 'installation';
         my $svirt = console('svirt')->change_domain_element(os => boot => {dev => 'hd'});
     }
 
-    $reboot_page->reboot();
+    (is_s390x() || is_ppc64le()) ?
+      # reboot via console
+      power_action('reboot', keepconsole => 1, first_reboot => 1) :
+      # graphical reboot
+      $reboot_page->reboot();
path: tests/yam/agama/agama.pm
user: login: czerw
body: Nice, i'm used mainly to ternary one-liners and my brain  read `:` as `;` at the end of line :)
created_at: 2025-04-09T05:56:22Z
author_association: CONTRIBUTOR

PR comments:
user: login: jknphy
created_at: 2025-04-09T05:05:48Z
body: fyi @czerw @alvarocarvajald @alice-suse 
author_association: CONTRIBUTOR
user: login: RoyCai7
created_at: 2025-04-09T05:22:51Z
body: I made VR testing, all passed. Thanks for your great help to support hyperv and vmwre.
Vmware: https://openqa.oqa.prg2.suse.org/tests/17294828
Hyperv: https://openqa.oqa.prg2.suse.org/tests/17294827
author_association: CONTRIBUTOR