/
main_common.pm
2309 lines (2147 loc) · 82.2 KB
/
main_common.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SUSE's openQA tests
#
# Copyright © 2018 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: Attempt to merge common parts of sle/main.pm and opensuse/main.pm
# Maintainer: Anton Smorodskyi<asmorodskyi@suse.com>
package main_common;
use base Exporter;
use File::Basename;
use File::Find;
use Exporter;
use testapi qw(check_var get_var get_required_var set_var check_var_array diag);
use autotest;
use utils;
use version_utils qw(:VERSION :BACKEND :SCENARIO);
use bmwqemu ();
use strict;
use warnings;
our @EXPORT = qw(
any_desktop_is_applicable
bootencryptstep_is_applicable
boot_hdd_image
check_env
chromestep_is_applicable
chromiumstep_is_applicable
console_is_applicable
consolestep_is_applicable
default_desktop
get_ltp_tag
gnomestep_is_applicable
guiupdates_is_applicable
have_scc_repos
init_main
installyaststep_is_applicable
installzdupstep_is_applicable
is_desktop
is_kernel_test
is_ltp_test
is_livesystem
is_mediacheck
is_mediacheck
is_memtest
is_memtest
is_server
is_sles4sap
is_sles4sap_standard
is_updates_test_repo
is_updates_tests
kdestep_is_applicable
kdump_is_applicable
load_autoyast_clone_tests
load_autoyast_tests
load_bootloader_s390x
load_boot_tests
load_common_installation_steps_tests
load_common_opensuse_sle_tests
load_common_x11
load_consoletests
load_create_hdd_tests
load_extra_tests
load_extra_tests_docker
load_filesystem_tests
load_inst_tests
load_iso_in_external_tests
load_jeos_tests
load_kernel_tests
load_networkd_tests
load_nfv_master_tests
load_nfv_trafficgen_tests
load_public_cloud_patterns_validation_tests
load_transactional_role_tests
load_reboot_tests
load_rescuecd_tests
load_rollback_tests
load_security_tests_apparmor
load_security_tests_core
load_security_tests_crypt
load_security_tests_misc
load_security_tests_openscap
load_security_tests_selinux
load_security_tests_web
load_shutdown_tests
load_slepos_tests
load_sles4sap_tests
load_ssh_key_import_tests
load_svirt_boot_tests
load_svirt_vm_setup_tests
load_syscontainer_tests
load_systemd_patches_tests
load_system_update_tests
loadtest
load_testdir
load_toolchain_tests
load_virtualization_tests
load_wicked_tests
load_x11tests
load_xen_tests
load_yast2_gui_tests
load_yast2_ncurses_tests
load_zdup_tests
logcurrentenv
map_incidents_to_repo
need_clear_repos
noupdatestep_is_applicable
remove_common_needles
remove_desktop_needles
replace_opensuse_repos_tests
rescuecdstep_is_applicable
set_defaults_for_username_and_password
setup_env
snapper_is_applicable
ssh_key_import
unregister_needle_tags
updates_is_applicable
we_is_applicable
);
sub init_main {
set_defaults_for_username_and_password();
setup_env();
check_env();
}
sub loadtest {
my ($test, %args) = @_;
autotest::loadtest("tests/$test.pm", %args);
}
sub load_testdir {
my ($testsuite) = @_;
my $testdir = testapi::get_required_var('CASEDIR') . "/tests/$testsuite";
map { loadtest "$testsuite/" . basename($_, '.pm') } glob("$testdir/*.pm");
}
sub set_defaults_for_username_and_password {
if (get_var("LIVETEST")) {
$testapi::username = "root";
$testapi::password = '';
}
else {
if (get_var('FLAVOR', '') =~ /SAP/ or get_var('SLE_PRODUCT', '') =~ /sles4sap/) {
$testapi::username = "root"; #in sles4sap only root user created
}
else {
$testapi::username = "bernhard";
}
$testapi::password = "nots3cr3t";
}
$testapi::username = get_var("USERNAME") if get_var("USERNAME");
$testapi::password = get_var("PASSWORD") if defined get_var("PASSWORD");
if (get_var("LIVETEST") && (get_var("LIVECD") || get_var("PROMO"))) {
$testapi::username = "linux"; # LiveCD account
$testapi::password = "";
}
}
sub setup_env {
# Tests currently rely on INSTLANG=en_US, so set it by default
unless (get_var('INSTLANG')) {
set_var('INSTLANG', 'en_US');
}
if (get_var('UEFI') && !check_var('ARCH', 'aarch64')) {
# avoid having to update all job templates, but newer qemu
# BIOS wants to have the bios passed differently
# https://github.com/os-autoinst/os-autoinst/pull/377
# Does _not_ work on aarch64
set_var('UEFI_PFLASH', 1);
}
# By default format DASD devices before installation
if (check_var('BACKEND', 's390x')) {
# Format DASD before the installation by default
# Skip format dasd before origin system installation by autoyast in 'Upgrade on zVM'
# due to channel not activation issue. Need further investigation on it.
# Also do not format if activate existing partitions
my $format_dasd = get_var('S390_DISK') || get_var('UPGRADE') || get_var('ENCRYPT_ACTIVATE_EXISTING') ? 'never' : 'pre_install';
set_var('FORMAT_DASD', get_var('FORMAT_DASD', $format_dasd));
}
}
sub data_integrity_is_applicable {
# Other backends than qemu, i.e.Xen, zKVM or Hyper-V will check it later after the image is downloaded
return check_var('BACKEND', 'qemu') &&
grep { /^CHECKSUM_/ } keys %bmwqemu::vars;
}
sub any_desktop_is_applicable {
return get_var("DESKTOP") !~ /textmode/;
}
sub console_is_applicable {
return !any_desktop_is_applicable();
}
sub logcurrentenv {
for my $k (@_) {
my $e = get_var("$k");
next unless defined $e;
diag("usingenv $k=$e");
}
}
sub have_addn_repos {
return
!get_var("NET")
&& !get_var("EVERGREEN")
&& get_var("SUSEMIRROR")
&& !get_var("FLAVOR", '') =~ m/^Staging2?[\-]DVD$/;
}
sub is_livesystem {
return (check_var("FLAVOR", 'Rescue-CD') || get_var("LIVETEST"));
}
sub is_kde_live {
return get_var('FLAVOR', '') =~ /KDE-Live/;
}
sub packagekit_available {
return !check_var('FLAVOR', 'Rescue-CD');
}
sub is_ltp_test {
return (get_var('INSTALL_LTP')
|| get_var('LTP_COMMAND_FILE'));
}
sub is_kernel_test {
return is_ltp_test() ||
(get_var('QA_TEST_KLP_REPO')
|| get_var('INSTALL_KOTD')
|| get_var('VIRTIO_CONSOLE_TEST')
|| get_var('NVMFTESTS')
|| get_var('TRINITY'));
}
sub get_ltp_tag {
my $tag = get_var('LTP_RUNTEST_TAG');
if (!defined $tag && defined get_var('HDD_1')) {
$tag = get_var('PUBLISH_HDD_1');
$tag = get_var('HDD_1') if (!defined $tag);
$tag = basename($tag);
} else {
$tag = get_var('DISTRI') . '-' . get_var('VERSION') . '-' . get_var('ARCH') . '-' . get_var('BUILD') . '-' . get_var('FLAVOR') . '@' . get_var('MACHINE');
}
return $tag . '.txt';
}
# Isolate the loading of LTP tests because they often rely on newer features
# not present on all workers. If they are isolated then only the LTP tests
# will fail to load when there is a version mismatch instead of all tests.
{
local $@;
eval 'use main_ltp';
if ($@) {
bmwqemu::fctwarn("Failed to load main_ltp.pm:\n$@", 'main_common.pm');
eval q%{
sub load_kernel_tests {
if (is_kernel_test())
{
die "Can not run kernel tests because evaluating main_ltp.pm failed";
}
return 0;
}
%;
}
}
sub replace_opensuse_repos_tests {
return if get_var('CLEAR_REPOS');
loadtest "update/zypper_clear_repos";
set_var('CLEAR_REPOS', 1);
loadtest "console/zypper_ar";
loadtest "console/zypper_ref";
}
sub is_updates_tests {
my $flavor = get_required_var('FLAVOR');
# Incidents might be also Incidents-Gnome or Incidents-Kernel
return $flavor =~ /-Updates$/ || $flavor =~ /-Incidents/;
}
sub is_updates_test_repo {
# mru stands for Maintenance Released Updates and skips unreleased updates
return get_var('TEST') !~ /^mru-/ && is_updates_tests && get_required_var('FLAVOR') !~ /-Minimal$/;
}
sub is_repo_replacement_required {
return is_opensuse() # Is valid scenario onlu for openSUSE
&& !is_staging() # Do not have mirrored repos on staging
&& !get_var('KEEP_ONLINE_REPOS') # Set variable no to replace variables
&& get_var('SUSEMIRROR') # Skip if required variable is not set (leap live tests)
&& !get_var('ZYPPER_ADD_REPOS') # Skip if manual repos are specified
&& !get_var('OFFLINE_SUT') # Do not run if SUT is offine
&& !get_var('ZDUP'); # Do not run on ZDUP as these tests handle repos on their own
}
sub is_memtest {
return get_var('MEMTEST');
}
sub is_mediacheck {
return get_var('MEDIACHECK');
}
sub is_desktop {
return get_var('FLAVOR', '') =~ /^Desktop/ || check_var('SLE_PRODUCT', 'sled');
}
sub is_desktop_module_selected {
# desktop applications module is selected if following variables have following values:
# ha require desktop applications on sle <15, so it's preselected
# same is true for sles4sap
return
get_var('ADDONS', '') =~ /all-packages|desktop|we/
|| get_var('WORKAROUND_MODULES', '') =~ /desktop|we/
|| get_var('ADDONURL', '') =~ /desktop|we/
|| (!is_sle('15+') && get_var('SCC_ADDONS', '') =~ /desktop|we|productivity|ha/)
|| (is_sle('15+') && get_var('SCC_ADDONS', '') =~ /desktop|we/)
|| is_sles4sap;
}
sub default_desktop {
return 'textmode' if (get_var('SYSTEM_ROLE') && !check_var('SYSTEM_ROLE', 'default'));
return if get_var('VERSION', '') lt '12';
return 'gnome' if get_var('VERSION', '') lt '15';
# with SLE 15 LeanOS only the default is textmode
return 'gnome' if get_var('BASE_VERSION', '') =~ /^12/;
return 'gnome' if is_desktop_module_selected;
# default system role for sles and sled
return 'textmode' if is_server || !get_var('SCC_REGISTER') || !check_var('SCC_REGISTER', 'installation');
# remaining cases are is_desktop and check_var('SCC_REGISTER', 'installation'), hence gnome
return 'gnome';
}
sub uses_qa_net_hardware {
return check_var("BACKEND", "ipmi") || check_var("BACKEND", "generalhw");
}
sub load_shutdown_tests {
loadtest("shutdown/cleanup_before_shutdown");
loadtest "shutdown/shutdown";
}
sub load_svirt_boot_tests {
# Unless GRUB2 supports framebuffer on Xen PV (bsc#961638), grub2 tests
# has to be skipped there.
if (!(check_var('VIRSH_VMM_FAMILY', 'xen') && check_var('VIRSH_VMM_TYPE', 'linux'))) {
if (get_var("UEFI") || is_jeos) {
loadtest "installation/bootloader_uefi";
}
elsif (!get_var('NETBOOT')) {
loadtest "installation/bootloader";
}
}
}
sub load_svirt_vm_setup_tests {
return unless check_var('BACKEND', 'svirt');
set_bridged_networking;
if (check_var("VIRSH_VMM_FAMILY", "hyperv")) {
# Loading bootloader_hyperv here when UPGRADE is on (i.e. offline migration is underway)
# means loading it for the second time. Which might be apropriate if we want to reconfigure
# the VM, but currently we don't want to.
loadtest "installation/bootloader_hyperv" unless get_var('UPGRADE');
}
else {
loadtest "installation/bootloader_svirt";
}
unless (is_installcheck || is_memtest || is_rescuesystem || is_mediacheck) {
load_svirt_boot_tests;
}
}
sub load_boot_tests {
if (get_var("ISO_MAXSIZE") && (!is_remote_backend() || is_svirt_except_s390x())) {
loadtest "installation/isosize";
}
if ((get_var("UEFI") || is_jeos()) && !check_var("BACKEND", "svirt")) {
loadtest "installation/bootloader_uefi";
}
elsif (is_svirt_except_s390x()) {
load_svirt_vm_setup_tests;
}
elsif (uses_qa_net_hardware() || get_var("PXEBOOT")) {
loadtest "boot/boot_from_pxe";
set_var("DELAYED_START", get_var("PXEBOOT"));
}
elsif (check_var('BACKEND', 'spvm')) {
loadtest "installation/bootloader_spvm";
}
else {
loadtest "installation/bootloader" unless load_bootloader_s390x();
}
}
sub load_reboot_tests {
# there is encryption passphrase prompt which is handled in installation/boot_encrypt
if (check_var("ARCH", "s390x") && !get_var('ENCRYPT')) {
loadtest "installation/reconnect_s390";
}
if (uses_qa_net_hardware()) {
loadtest "boot/qa_net_boot_from_hdd";
}
if (installyaststep_is_applicable()) {
# test makes no sense on s390 because grub2 can't be captured
if (!(check_var("ARCH", "s390x") or (check_var('VIRSH_VMM_FAMILY', 'xen') and check_var('VIRSH_VMM_TYPE', 'linux')))) {
loadtest "installation/grub_test";
if ((snapper_is_applicable()) && get_var("BOOT_TO_SNAPSHOT")) {
loadtest "installation/boot_into_snapshot";
}
}
if (get_var('ENCRYPT')) {
loadtest "installation/boot_encrypt";
# reconnect after installation/boot_encrypt
if (check_var('ARCH', 's390x')) {
loadtest "installation/reconnect_s390";
}
}
loadtest "installation/first_boot";
loadtest "installation/system_workarounds" if check_var('ARCH', 'aarch64');
}
if (get_var("DUALBOOT")) {
loadtest "installation/reboot_eject_cd";
loadtest "installation/boot_windows";
}
}
sub load_rescuecd_tests {
if (rescuecdstep_is_applicable()) {
loadtest "rescuecd/rescuecd";
}
}
sub load_autoyast_clone_tests {
loadtest "console/system_prepare";
loadtest "console/consoletest_setup";
loadtest "console/yast2_clone_system";
loadtest "console/consoletest_finish";
}
sub load_zdup_tests {
loadtest 'installation/setup_zdup';
if (get_var("LOCK_PACKAGE")) {
loadtest "console/lock_package";
}
loadtest 'installation/zdup';
loadtest 'installation/post_zdup';
# Restrict version switch to sle until opensuse adopts it
loadtest "migration/version_switch_upgrade_target" if is_sle and get_var("UPGRADE_TARGET_VERSION");
loadtest 'boot/boot_to_desktop';
}
sub load_autoyast_tests {
# init boot in load_boot_tests
loadtest("autoyast/installation");
loadtest("autoyast/console");
loadtest("autoyast/login");
loadtest("autoyast/wicked");
loadtest("autoyast/autoyast_verify") if get_var("AUTOYAST_VERIFY");
loadtest('autoyast/' . get_var("AUTOYAST_VERIFY_MODULE")) if get_var("AUTOYAST_VERIFY_MODULE");
if (get_var("SUPPORT_SERVER_GENERATOR")) {
loadtest("support_server/configure");
}
else {
loadtest("autoyast/repos");
loadtest("autoyast/clone");
loadtest("autoyast/logs");
}
loadtest("autoyast/autoyast_reboot");
# next boot in load_reboot_tests
}
sub load_slepos_tests {
if (get_var("SLEPOS") =~ /^adminserver/) {
loadtest("boot/boot_to_desktop");
loadtest "slepos/prepare";
loadtest "slepos/zypper_add_repo";
loadtest "slepos/zypper_install_adminserver";
loadtest "slepos/run_posInitAdminserver";
loadtest "slepos/zypper_install_imageserver";
loadtest "slepos/use_smt_for_kiwi";
loadtest "slepos/build_images_kiwi";
loadtest "slepos/register_images";
loadtest "slepos/build_offline_image_kiwi";
loadtest "slepos/wait";
}
elsif (get_var("SLEPOS") =~ /^branchserver/) {
loadtest("boot/boot_to_desktop");
loadtest "slepos/prepare";
loadtest "slepos/zypper_add_repo";
loadtest "slepos/zypper_install_branchserver";
loadtest "slepos/run_posInitBranchserver";
loadtest "slepos/run_possyncimages";
loadtest "slepos/wait";
}
elsif (get_var("SLEPOS") =~ /^imageserver/) {
loadtest("boot/boot_to_desktop");
loadtest "slepos/prepare";
loadtest "slepos/zypper_add_repo";
loadtest "slepos/zypper_install_imageserver";
loadtest "slepos/use_smt_for_kiwi";
loadtest "slepos/build_images_kiwi";
}
elsif (get_var("SLEPOS") =~ /^terminal-online/) {
set_var("DELAYED_START", "1");
loadtest "slepos/boot_image";
}
elsif (get_var("SLEPOS") =~ /^terminal-offline/) {
loadtest "slepos/boot_image";
}
}
sub load_system_role_tests {
# This part is relevant only for openSUSE
if (is_opensuse) {
if (installwithaddonrepos_is_applicable() && !get_var("LIVECD")) {
loadtest "installation/setup_online_repos";
}
# Do not run on REMOTE_CONTROLLER, IPMI and on Hyper-V in GUI mode
if (!check_var('BACKEND', 'ipmi') && !is_hyperv_in_gui && !get_var("LIVECD") && !check_var('BACKEND', 'spvm')) {
loadtest "installation/logpackages";
}
}
if (is_using_system_role) {
loadtest "installation/system_role";
}
elsif (is_opensuse) {
loadtest "installation/installer_desktopselection";
}
}
sub load_jeos_tests {
if (get_var('PREPARE_RPI')) {
loadtest "boot/boot_to_desktop";
loadtest "jeos/prepare_rpi_image";
loadtest "shutdown/shutdown";
return;
}
unless (get_var('LTP_COMMAND_FILE')) {
load_boot_tests();
loadtest "jeos/firstrun";
loadtest "jeos/record_machine_id";
unless (get_var('INSTALL_LTP')) {
loadtest "console/force_scheduled_tasks";
loadtest "jeos/grub2_gfxmode";
loadtest 'jeos/revive_xen_domain' if check_var('VIRSH_VMM_FAMILY', 'xen');
loadtest "jeos/diskusage";
loadtest "jeos/root_fs_size";
loadtest "jeos/mount_by_label";
}
if (is_sle) {
loadtest "console/suseconnect_scc";
}
}
loadtest "jeos/glibc_locale" if is_sle('15+') && get_var('JEOSINSTLANG');
}
sub installzdupstep_is_applicable {
return !get_var("NOINSTALL") && !get_var("RESCUECD") && get_var("ZDUP");
}
sub snapper_is_applicable {
# run snapper tests on opensuse only for system_performance testsuite
return 0 if (is_opensuse && !get_var('SOFTFAIL_BSC1063638'));
# snapshots are only proposed by the installer if the available space is
# big enough
my $snapshots_available = get_var('FILESYSTEM', 'btrfs') =~ /btrfs/ && get_var("HDDSIZEGB", 10) > 10;
return (!get_var('LIVETEST') && $snapshots_available);
}
sub chromestep_is_applicable {
return is_opensuse && (check_var('ARCH', 'i586') || check_var('ARCH', 'x86_64'));
}
sub chromiumstep_is_applicable {
return chromestep_is_applicable();
}
sub gnomestep_is_applicable {
return check_var("DESKTOP", "gnome");
}
sub installyaststep_is_applicable {
return !get_var("NOINSTALL") && !get_var("RESCUECD") && !get_var("ZDUP");
}
sub kdestep_is_applicable {
return check_var("DESKTOP", "kde");
}
# kdump is not supported on aarch64 (bsc#990418), and Xen PV (feature not implemented)
sub kdump_is_applicable {
return !check_var('ARCH', 'aarch64') && !check_var('VIRSH_VMM_TYPE', 'linux');
}
sub consolestep_is_applicable {
return !get_var("INSTALLONLY") && !get_var("DUALBOOT") && !get_var("RESCUECD") && !is_gnome_next && !is_krypton_argon;
}
sub rescuecdstep_is_applicable {
return get_var("RESCUECD");
}
sub ssh_key_import {
return get_var("SSH_KEY_IMPORT") || get_var("SSH_KEY_DO_NOT_IMPORT");
}
sub we_is_applicable {
return
is_server()
&& (get_var("ADDONS", "") =~ /we/ or get_var("SCC_ADDONS", "") =~ /we/ or get_var("ADDONURL", "") =~ /we/)
&& get_var('MIGRATION_REMOVE_ADDONS', '') !~ /we/;
}
sub installwithaddonrepos_is_applicable {
return get_var("HAVE_ADDON_REPOS") && !get_var("UPGRADE") && !get_var("NET");
}
sub need_clear_repos {
return !get_var('ZDUP')
&& (!get_var('INSTALLONLY') || get_var('PUBLISH_HDD_1'))
&& !get_var('BOOT_TO_SNAPSHOT')
&& !get_var('LIVETEST')
&& !get_var('DUALBOOT')
&& (is_opensuse && !is_updates_tests)
&& !(is_jeos && !is_staging)
|| (is_sle && get_var("FLAVOR", '') =~ m/^Staging2?[\-]DVD$/ && get_var("SUSEMIRROR"));
}
sub have_scc_repos {
return check_var('SCC_REGISTER', 'console');
}
sub rt_is_applicable {
return is_server() && get_var("ADDONS", "") =~ /rt/;
}
sub xfcestep_is_applicable {
return check_var("DESKTOP", "xfce");
}
sub lxdestep_is_applicable {
return check_var("DESKTOP", "lxde");
}
sub is_smt {
# Smt is replaced with rmt in SLE 15, see bsc#1061291
return ((get_var("PATTERNS", '') || get_var('HDD_1', '')) =~ /smt/) && is_sle('<15');
}
sub is_rmt {
return ((get_var("PATTERNS", '') || get_var('HDD_1', '')) =~ /rmt/) && is_sle('>=15');
}
sub remove_common_needles {
my $no_skipto = get_var('SKIPTO') ? 0 : 1;
unregister_needle_tags("ENV-SKIPTO-$no_skipto");
remove_desktop_needles("lxde");
remove_desktop_needles("kde");
remove_desktop_needles("gnome");
remove_desktop_needles("xfce");
remove_desktop_needles("minimalx");
remove_desktop_needles("textmode");
if (!check_var("VIDEOMODE", "text")) {
unregister_needle_tags("ENV-VIDEOMODE-text");
}
if (get_var("INSTLANG") && get_var("INSTLANG") ne "en_US") {
unregister_needle_tags("ENV-INSTLANG-en_US");
}
if (!check_var('ARCH', 's390x')) {
unregister_needle_tags('ENV-ARCH-s390x');
}
else { # english default
unregister_needle_tags("ENV-INSTLANG-de_DE");
}
}
sub remove_desktop_needles {
my $desktop = shift;
if (!check_var("DESKTOP", $desktop) && !check_var("FULL_DESKTOP", $desktop)) {
unregister_needle_tags("ENV-DESKTOP-$desktop");
}
}
sub map_incidents_to_repo {
my ($incidents, $templates) = @_;
my @maint_repos;
for my $a (keys %$incidents) {
for my $b (split(/,/, $incidents->{$a})) {
if ($b) {
push @maint_repos, join($b, split('%INCIDENTNR%', $templates->{$a}));
}
}
}
my $ret = join(',', @maint_repos);
# do not start with ','
$ret =~ s/^,//s;
return $ret;
}
our %valueranges = (
# LVM=>[0,1],
NOIMAGES => [0, 1],
USEIMAGES => [0, 1],
DOCRUN => [0, 1],
# BTRFS=>[0,1],
DESKTOP => [qw(kde gnome xfce lxde minimalx textmode serverro)],
# ROOTFS=>[qw(ext3 xfs jfs btrfs reiserfs)],
VIDEOMODE => ["", "text", "ssh-x"],
);
sub check_env {
for my $k (keys %valueranges) {
next unless get_var($k);
unless (grep { get_var($k) eq $_ } @{$valueranges{$k}}) {
die sprintf("%s must be one of %s\n", $k, join(',', @{$valueranges{$k}}));
}
}
}
sub unregister_needle_tags {
my ($tag) = @_;
my @a = @{needle::tags($tag)};
for my $n (@a) { $n->unregister($tag); }
}
sub load_bootloader_s390x {
return 0 unless check_var("ARCH", "s390x");
if (check_var("BACKEND", "s390x")) {
loadtest "installation/bootloader_s390";
}
else {
loadtest "installation/bootloader_zkvm";
}
return 1;
}
sub boot_hdd_image {
# On JeOS we don't need to load any test to boot, but to keep main.pm sane just return.
is_jeos() ? return 1 : get_required_var('BOOT_HDD_IMAGE');
if (check_var('BACKEND', 'svirt')) {
if (check_var('VIRSH_VMM_FAMILY', 'hyperv')) {
loadtest 'installation/bootloader_hyperv';
}
else {
loadtest 'installation/bootloader_svirt' unless load_bootloader_s390x;
}
}
if (get_var('UEFI') && (get_var('BOOTFROM') || get_var('BOOT_HDD_IMAGE'))) {
loadtest 'boot/uefi_bootmenu';
}
loadtest 'boot/boot_to_desktop';
}
sub load_common_installation_steps_tests {
loadtest 'installation/await_install';
unless (get_var('REMOTE_CONTROLLER') || is_caasp || is_hyperv_in_gui) {
loadtest 'installation/logs_from_installation_system';
}
loadtest 'installation/reboot_after_installation';
}
sub load_inst_tests {
# On SLE 15 dud addon screen is shown before product selection
if (get_var('DUD_ADDONS') && is_sle('15+')) {
loadtest "installation/dud_addon";
}
loadtest "installation/welcome";
loadtest "installation/keyboard_selection" if get_var('INSTALL_KEYBOARD_LAYOUT');
if (get_var('DUD_ADDONS') && is_sle('<15')) {
loadtest "installation/dud_addon";
}
loadtest 'installation/accept_license' if has_product_selection;
loadtest 'installation/network_configuration' if get_var('OFFLINE_SUT');
if (get_var('IBFT')) {
loadtest "installation/iscsi_configuration";
}
if (check_var('ARCH', 's390x')) {
if (check_var('BACKEND', 's390x')) {
loadtest "installation/disk_activation";
}
elsif (is_sle('<12-SP2')) {
loadtest "installation/skip_disk_activation";
}
}
if (get_var('ENCRYPT_CANCEL_EXISTING') || get_var('ENCRYPT_ACTIVATE_EXISTING')) {
loadtest "installation/encrypted_volume_activation";
}
if (get_var('MULTIPATH')) {
loadtest "installation/multipath";
}
if (is_opensuse && noupdatestep_is_applicable() && !is_livecd) {
# See https://github.com/yast/yast-packager/pull/385
loadtest "installation/online_repos";
loadtest "installation/installation_mode";
}
if (is_upgrade) {
loadtest "installation/upgrade_select";
if (check_var("UPGRADE", "LOW_SPACE")) {
loadtest "installation/disk_space_fill";
}
if (is_opensuse) {
# See https://github.com/yast/yast-packager/pull/385
loadtest "installation/online_repos";
loadtest "installation/upgrade_select_opensuse";
}
}
if (is_sle) {
loadtest 'installation/network_configuration' if get_var('NETWORK_CONFIGURATION');
# SCC registration is not required in media based upgrade since SLE15
unless (is_sle('15+') && get_var('MEDIA_UPGRADE')) {
if (check_var('SCC_REGISTER', 'installation')) {
loadtest "installation/scc_registration";
}
else {
loadtest "installation/skip_registration" unless check_var('SLE_PRODUCT', 'leanos');
}
}
if (is_sles4sap and is_sle('<15') and !is_upgrade()) {
loadtest "installation/sles4sap_product_installation_mode";
}
if (get_var('MAINT_TEST_REPO')) {
loadtest 'installation/add_update_test_repo';
}
loadtest "installation/addon_products_sle";
loadtest 'installation/releasenotes_origin' if get_var('CHECK_RELEASENOTES_ORIGIN');
}
if (noupdatestep_is_applicable()) {
# Krypton/Argon disable the network configuration stage
if (get_var("LIVECD") && !is_krypton_argon) {
loadtest "installation/livecd_network_settings";
}
# Run system_role/desktop selection tests if using the new openSUSE installation flow
if (is_using_system_role_first_flow && requires_role_selection) {
load_system_role_tests;
}
if (is_sles4sap() and is_sle('15+') and check_var('SYSTEM_ROLE', 'default') and !is_upgrade()) {
loadtest "installation/sles4sap_product_installation_mode";
}
# Kubic doesn't have a partitioning step
unless (is_caasp) {
loadtest "installation/partitioning";
if (defined(get_var("RAIDLEVEL"))) {
loadtest "installation/partitioning_raid";
}
elsif (check_var('LVM', 0) && get_var('ENCRYPT')) {
loadtest 'installation/partitioning_crypt_no_lvm';
}
elsif (get_var("LVM")) {
loadtest "installation/partitioning_lvm";
}
elsif (get_var('FULL_LVM_ENCRYPT')) {
loadtest 'installation/partitioning_full_lvm';
}
elsif (get_var('LVM_THIN_LV')) {
loadtest "installation/partitioning_lvm_thin_provisioning";
}
if (get_var("FILESYSTEM")) {
if (get_var('PARTITIONING_WARNINGS')) {
loadtest 'installation/partitioning_warnings';
}
loadtest "installation/partitioning_filesystem";
}
# boo#1093372 Leap 15.0 proposes a separate home even on small disks
# making the root partition likely to small so we should switch the
# defaults here unless we reconfigure using the guided proposal or
# expert partitioner anyway
if (get_var("TOGGLEHOME")
|| (is_leap('15.0+') && get_var('HDDSIZEGB', 0) <= 20 && !defined get_var('RAIDLEVEL') && !get_var('LVM') && !get_var('FILESYSTEM')))
{
loadtest "installation/partitioning_togglehome";
if (get_var('LVM') && get_var('RESIZE_ROOT_VOLUME')) {
loadtest "installation/partitioning_resize_root";
}
}
if (get_var("EXPERTPARTITIONER")) {
loadtest "installation/partitioning_expert";
}
if (get_var("ENLARGESWAP") && get_var("QEMURAM", 1024) > 4098) {
loadtest "installation/installation_enlargeswap";
}
if (get_var("SPLITUSR")) {
loadtest "installation/partitioning_splitusr";
}
if (get_var("DELETEWINDOWS")) {
loadtest "installation/partitioning_guided";
}
if (get_var("IBFT")) {
loadtest "installation/partitioning_iscsi";
}
if ((uses_qa_net_hardware() && !get_var('FILESYSTEM')) || get_var('SELECT_FIRST_DISK') || get_var("ISO_IN_EXTERNAL_DRIVE")) {
loadtest "installation/partitioning_firstdisk";
}
loadtest "installation/partitioning_finish";
}
}
if (is_opensuse && addon_products_is_applicable() && !is_leap('42.3+')) {
loadtest "installation/addon_products";
}
# the VNC gadget is too unreliable to click, but we
# need to be able to do installations on it. The release notes
# functionality needs to be covered by other backends
# Skip release notes test on sle 15 if have addons
if (is_sle && !check_var('BACKEND', 'generalhw') && !check_var('BACKEND', 'ipmi') && !(is_sle('15+') && get_var('ADDONURL'))) {
loadtest "installation/releasenotes";
}
if (noupdatestep_is_applicable()) {
loadtest "installation/installer_timezone" unless is_caasp;
# the test should run only in scenarios, where installed
# system is not being tested (e.g. INSTALLONLY etc.)
# The test also won't work reliably when network is bridged (non-s390x svirt).
if (!consolestep_is_applicable()
and !get_var("REMOTE_CONTROLLER")
and !is_hyperv_in_gui
and !is_bridged_networking
and !check_var('BACKEND', 's390x')
and !check_var('BACKEND', 'ipmi')
and !check_var('BACKEND', 'spvm')
and is_sle('12-SP2+'))
{
loadtest "installation/hostname_inst";
}
# Do not run system_role/desktop selection if using the new openSUSE installation flow
if (!is_using_system_role_first_flow && requires_role_selection) {
load_system_role_tests;
}
if (is_sles4sap()) {
if (
is_sles4sap_standard() # Schedule module only for SLE15 with non-default role
|| is_sle('15+') && get_var('SYSTEM_ROLE') && !check_var('SYSTEM_ROLE', 'default'))
{
loadtest "installation/user_settings";
} # sles4sap wizard installation doesn't have user_settings step
}
elsif (get_var('IMPORT_USER_DATA')) {
loadtest 'installation/user_import';
}
elsif (is_caasp 'kubic') {
loadtest "installation/kubeadm_settings" if check_var('SYSTEM_ROLE', 'kubeadm');
} else {
loadtest "installation/user_settings";
}
if (is_sle || get_var("DOCRUN") || get_var("IMPORT_USER_DATA") || get_var("ROOTONLY")) { # root user
loadtest "installation/user_settings_root" unless check_var('SYSTEM_ROLE', 'hpc-node') || check_var('SYSTEM_ROLE', 'hpc-server');
}
if (get_var('PATTERNS') || get_var('PACKAGES')) {
loadtest "installation/installation_overview_before";
loadtest "installation/select_patterns_and_packages";
}
elsif (
is_sle
&& (!check_var('DESKTOP', default_desktop)
&& (is_sle('<15') || check_var('DESKTOP', 'minimalx'))))
{
# With SLE15 we change desktop using role and not by unselecting packages (Use SYSTEM_ROLE variable),
# If we have minimalx, as there is no such a role, there we use old approach
loadtest "installation/installation_overview_before";
loadtest "installation/change_desktop";
}
}
if (get_var("UEFI") && get_var("SECUREBOOT")) {
loadtest "installation/secure_boot";
}
if (installyaststep_is_applicable()) {
loadtest "installation/installation_overview";
# On Xen PV we don't have GRUB on VNC
set_var('KEEP_GRUB_TIMEOUT', 1) if check_var('VIRSH_VMM_TYPE', 'linux');
loadtest "installation/disable_grub_timeout" unless get_var('KEEP_GRUB_TIMEOUT');
if (check_var('VIDEOMODE', 'text') && check_var('BACKEND', 'ipmi')) {
loadtest "installation/disable_grub_graphics";
}
if (check_var("UPGRADE", "LOW_SPACE")) {
loadtest "installation/disk_space_release";
}
if (ssh_key_import) {
loadtest "installation/ssh_key_setup";
}
loadtest "installation/start_install";
}