Skip to content

Commit

Permalink
Enable POM structure and libyui for firstboot
Browse files Browse the repository at this point in the history
  • Loading branch information
JRivrain committed Apr 8, 2021
1 parent 629d00d commit 5679e5a
Show file tree
Hide file tree
Showing 19 changed files with 320 additions and 7 deletions.
30 changes: 30 additions & 0 deletions data/autoyast_opensuse/autoyast_firstboot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,34 @@
<timeout config:type="integer">0</timeout>
</yesno_messages>
</report>
<scripts>
<chroot-scripts config:type="list">
<script>
<chrooted config:type="boolean">true</chrooted>
<source>
<![CDATA[#!/bin/bash
for i in YUI_HTTP_PORT={{YUI_PORT}} YUI_HTTP_REMOTE=1 YUI_REUSE_PORT=1 Y2DEBUG=1; do
echo "export $i" >> /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api;
done
chmod +x /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api;
]]>
</source>
</script>
</chroot-scripts>
<post-scripts config:type="list">
<script>
<filename>install_libyui.sh</filename>
<interpreter>shell</interpreter>
<location/>
<feedback config:type="boolean">false</feedback>
<source><![CDATA[#!/bin/sh
mv /var/run/zypp.pid /var/run/zypp.sav
zypper ar https://openqa.opensuse.org/assets/repo/openSUSE-Tumbleweed-oss-i586-x86_64-Snapshot{{BUILD}} tumb
zypper -n in libyui-rest-api
mv /var/run/zypp.sav /var/run/zypp.pid
systemctl disable firewalld
]]></source>
</script>
</post-scripts>
</scripts>
</profile>
30 changes: 30 additions & 0 deletions data/autoyast_opensuse/autoyast_firstboot_leap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,34 @@
<timeout config:type="integer">0</timeout>
</yesno_messages>
</report>
<scripts>
<chroot-scripts config:type="list">
<script>
<chrooted config:type="boolean">true</chrooted>
<source>
<![CDATA[#!/bin/bash
for i in YUI_HTTP_PORT={{YUI_PORT}} YUI_HTTP_REMOTE=1 YUI_REUSE_PORT=1 Y2DEBUG=1; do
echo "export $i" >> /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api;
done
chmod +x /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api;
]]>
</source>
</script>
</chroot-scripts>
<post-scripts config:type="list">
<script>
<filename>install_libyui.sh</filename>
<interpreter>shell</interpreter>
<location/>
<feedback config:type="boolean">false</feedback>
<source><![CDATA[#!/bin/sh
mv /var/run/zypp.pid /var/run/zypp.sav
zypper ar http://openqa.opensuse.org/assets/repo/openSUSE-Leap-{{VERSION}}-oss-Build{{BUILD}} leap
zypper -n in libyui-rest-api
mv /var/run/zypp.sav /var/run/zypp.pid
systemctl disable firewalld
]]></source>
</script>
</post-scripts>
</scripts>
</profile>
53 changes: 52 additions & 1 deletion data/autoyast_sle15/autoyast_firstboot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<version>{{VERSION}}</version>
<arch>{{ARCH}}</arch>
</addon>
<addon>
<name>sle-module-development-tools</name>
<version>{{VERSION}}</version>
<arch>{{ARCH}}</arch>
</addon>
<addon>
<name>sle-module-desktop-applications</name>
<version>{{VERSION}}</version>
Expand All @@ -34,6 +39,23 @@
<networking>
<keep_install_network config:type="boolean">true</keep_install_network>
</networking>
<firewall>
<zones config:type="list">
<zone>
<name>external</name>
<services config:type="list">
<service>http</service>
<service>https</service>
</services>
<ports config:type="list">
<port>{{YUI_PORT}}/tcp</port>
</ports>
</zone>
</zones>
<log_denied_packets>off</log_denied_packets>
<enable_firewall config:type="boolean">false</enable_firewall>
<start_firewall config:type="boolean">false</start_firewall>
</firewall>
<software>
<products config:type="list">
<product>SLES</product>
Expand All @@ -43,6 +65,7 @@
<package>sles-release</package>
<package>yast2-firstboot</package>
<package>yast2-registration</package>
<!--<package>libyui-rest-api15</package>-->
</packages>
<patterns config:type="list">
<pattern>apparmor</pattern>
Expand All @@ -55,7 +78,7 @@
<pattern>minimal_base</pattern>
<pattern>x11</pattern>
<pattern>x11_enhanced</pattern>
</patterns>
</patterns>
</software>
<users config:type="list">
<user>
Expand Down Expand Up @@ -95,4 +118,32 @@
<timeout config:type="integer">0</timeout>
</yesno_messages>
</report>
<scripts>
<chroot-scripts config:type="list">
<script>
<chrooted config:type="boolean">true</chrooted>
<source>
<![CDATA[#!/bin/bash
for i in YUI_HTTP_PORT={{YUI_PORT}} YUI_HTTP_REMOTE=1 YUI_REUSE_PORT=1 Y2DEBUG=1; do
echo "export $i" >> /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api;
done
chmod +x /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api;
]]>
</source>
</script>
</chroot-scripts>
<post-scripts config:type="list">
<script>
<filename>install_libyui.sh</filename>
<interpreter>shell</interpreter>
<location/>
<feedback config:type="boolean">false</feedback>
<source><![CDATA[#!/bin/sh
mv /var/run/zypp.pid /var/run/zypp.sav
zypper -n in libyui-rest-api
mv /var/run/zypp.sav /var/run/zypp.pid
]]></source>
</script>
</post-scripts>
</scripts>
</profile>
5 changes: 5 additions & 0 deletions lib/Distribution/Opensuse/Tumbleweed.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use Installation::Partitioner::LibstorageNG::v4_3::ExpertPartitionerController;
use YaST::NetworkSettings::v4_3::NetworkSettingsController;
use Installation::SystemRole::SystemRoleController;
use YaST::SystemSettings::SystemSettingsController;
use YaST::Installer::InstallerController;

sub get_partitioner {
return Installation::Partitioner::LibstorageNG::GuidedSetupController->new();
Expand Down Expand Up @@ -52,4 +53,8 @@ sub get_suggested_partitioning() {
return Installation::Partitioner::LibstorageNG::v4_3::SuggestedPartitioningController->new();
}

sub get_firstboot {
return YaST::Installer::InstallerController->new();
}

1;
39 changes: 39 additions & 0 deletions lib/YaST/Installer/GenericPage.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SUSE's openQA tests
#
# Copyright © 2021 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.

package YaST::Installer::GenericPage;
use strict;
use warnings;
use testapi;

sub new {
my ($class, $args) = @_;
my $self = bless {
app => $args->{app}
}, $class;
return $self->init();
}

sub init {
my ($self) = @_;
$self->{btn_next} = $self->{app}->button({id => 'next'});
# $self->{debug_label} = $self->{app}->debug_label({debug_label => $debug_label}); # to be implemented as part of poo#89866
return $self;
}

sub assert_page {
return; # to be implemented as part of poo#89866
}

sub press_next {
my ($self) = @_;
return $self->{btn_next}->click();
}

1;
57 changes: 57 additions & 0 deletions lib/YaST/Installer/InstallerController.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# SUSE's openQA tests
#
# Copyright © 2021 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.

# Summary: Controller for firstboot page
# Maintainer: QE YaST <qa-sle-yast@suse.de>

package YaST::Installer::InstallerController;
use strict;
use warnings;
use YuiRestClient;
use YaST::Installer::GenericPage;
# use YaST::Installer::Firstboot::LanPage;
use testapi;

sub new {
my ($class, $args) = @_;
my $self = bless {}, $class;
return $self->init($args);
}

sub init {
my ($self, $args) = @_;
$self->{GenericPage} = YaST::Installer::GenericPage->new({app => YuiRestClient::get_app()});
# $self->{LanPage} = YaST::Firstboot::LanPage->new({app => YuiRestPage::get_app()});
return $self;
}

sub get_generic_page {
my ($self) = @_;
$self->{GenericPage};
}

sub get_lan_page {
my ($self) = @_;
$self->{LanPage};
}

# sub inst_lan {
# my ($self) = @_;
# $self->{GenericPage}->assert_page('Network_settings');
# $self->get_lan_page->is_shown();
# $self->{GenericPage}->press_next();
# }

sub check_and_skip_page {
my ($self, $debug_label) = @_;
$self->get_generic_page->assert_page($debug_label);
$self->get_generic_page->press_next();
}

1;
10 changes: 10 additions & 0 deletions lib/YuiRestClient.pm
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,14 @@ sub set_libyui_backend_vars {
set_var('YUI_SERVER', $server);
}

sub setup_libyui_firstboot {
my $port = get_var('YUI_PORT');
zypper_call('in libyui-rest-api');
assert_script_run "firewall-cmd --zone=public --add-port=$port/tcp --permanent";
foreach my $export ("YUI_HTTP_PORT=$port", "YUI_HTTP_REMOTE=1", "YUI_REUSE_PORT=1", "Y2DEBUG=1") {
assert_script_run "echo export $export >> /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api";
}
assert_script_run "chmod +x /usr/lib/YaST2/startup/Firstboot-Stage/S01-rest-api";
}

1;
1 change: 1 addition & 0 deletions schedule/yast/firstboot/autoyast_y2_firstboot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ schedule:
- autoyast/prepare_profile
- installation/isosize
- installation/bootloader_start
- installation/setup_libyui
- autoyast/installation
- installation/yast2_firstboot
- installation/first_boot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ schedule:
- autoyast/prepare_profile
- installation/isosize
- installation/bootloader_start
- installation/setup_libyui
- autoyast/installation
- installation/yast2_firstboot
- installation/first_boot
Expand Down
2 changes: 2 additions & 0 deletions schedule/yast/firstboot/yast2_firstboot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ schedule:
- console/consoletest_setup
- console/hostname
- installation/enable_y2_firstboot
- installation/setup_libyui_firstboot
- autoyast/autoyast_reboot
- installation/grub_test
- boot/check_libyui_firstboot
- installation/yast2_firstboot
- installation/first_boot
- console/validate_yast2_firstboot_configuration
Expand Down
3 changes: 3 additions & 0 deletions schedule/yast/firstboot/yast2_firstboot_custom-opensuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ schedule:
- console/consoletest_setup
- console/hostname
- installation/enable_y2_firstboot
- installation/setup_libyui_firstboot
- autoyast/autoyast_reboot
- installation/grub_test
- boot/check_libyui_firstboot
- installation/yast2_firstboot
- installation/first_boot
- console/validate_yast2_firstboot_configuration
Expand All @@ -25,5 +27,6 @@ test_data:
- firstboot_hostname
- firstboot_timezone
- firstboot_user
- firstboot_finish
custom_control_file: "firstboot_custom-opensuse.xml"
sysconfig_firstboot: "sysconfig_firstboot"
3 changes: 3 additions & 0 deletions schedule/yast/firstboot/yast2_firstboot_custom-sle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ schedule:
- console/consoletest_setup
- console/hostname
- installation/enable_y2_firstboot
- installation/setup_libyui_firstboot
- autoyast/autoyast_reboot
- installation/grub_test
- boot/check_libyui_firstboot
- installation/yast2_firstboot
- installation/first_boot
- console/validate_yast2_firstboot_configuration
Expand All @@ -25,5 +27,6 @@ test_data:
- firstboot_hostname
- firstboot_timezone
- firstboot_user
- firstboot_finish
custom_control_file: "firstboot_custom-sle.xml"
sysconfig_firstboot: "sysconfig_firstboot"
1 change: 1 addition & 0 deletions test_data/yast/firstboot/yast2_firstboot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ clients:
- firstboot_timezone
- firstboot_user
- firstboot_root
- firstboot_finish
1 change: 1 addition & 0 deletions test_data/yast/firstboot/yast2_firstboot_sle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ clients:
- firstboot_user
- firstboot_root
- firstboot_registration
- firstboot_finish
3 changes: 3 additions & 0 deletions tests/autoyast/installation.pm
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ sub run {
send_key 'ret'; # press enter if grub timeout is disabled, like we have in reinstall scenarios
last; # if see grub, we get to the second stage, as it appears after bios-boot which we may miss
}
elsif (match_has_tag('linuxrc-start-shell-after-installation')) {
type_string_slow "exit\n";
}
elsif (match_has_tag('import-untrusted-gpg-key')) {
handle_untrusted_gpg_key;
@needles = grep { $_ ne 'import-untrusted-gpg-key' } @needles;
Expand Down
27 changes: 27 additions & 0 deletions tests/boot/check_libyui_firstboot.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SUSE's openQA tests
#
# Copyright © 2021 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.

# Summary: Check that libyui is available before firstboot
# Maintainer: QE YaST <qa-sle-yast@suse.de>

use base 'bootbasetest';
use strict;
use warnings;
use testapi;

sub run {
my ($self) = @_;
YuiRestClient::connect_to_app();
}

sub test_flags {
return {fatal => 1, milestone => 1};
}

1;
Loading

0 comments on commit 5679e5a

Please sign in to comment.