-
Notifications
You must be signed in to change notification settings - Fork 266
/
yast2_migration.pm
291 lines (270 loc) · 11.7 KB
/
yast2_migration.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
# SLE12 online migration tests
#
# Copyright © 2016-2020 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: sle12 online migration testsuite
# Maintainer: yutao <yuwang@suse.com>
use base 'y2_installbase';
use strict;
use warnings;
use testapi;
use utils;
use power_action_utils 'power_action';
use version_utils qw(is_desktop_installed is_sle);
use x11utils qw(ensure_unlocked_desktop turn_off_gnome_screensaver);
sub yast2_migration_gnome_remote {
return check_var('MIGRATION_METHOD', 'yast') && check_var('DESKTOP', 'gnome') && get_var('REMOTE_CONNECTION');
}
sub yast2_migration_gnome_x11 {
# just use this workaround for sles15+
return check_var('MIGRATION_METHOD', 'yast') && check_var('DESKTOP', 'gnome') && is_sle('15+');
}
# deal with yast2 online migration conflicts in gnome x11 with yast2
sub yast2_migration_handle_conflicts_x11 {
my $self = shift;
# give a little time to check package
assert_screen 'yast2-migration-summary', 120;
if (check_screen("yast2-migration-conflicts", 30)) {
if (check_screen('manual-intervention', 0)) {
# In function deal_with_dependency_issues we handle different actions by VIDEOMODE,
# here we need change VIDEOMODE to something not text.
my $orig_videomode = get_var('VIDEOMODE', '');
set_var("VIDEOMODE", 'ssh-x');
$self->deal_with_dependency_issues;
set_var("VIDEOMODE", $orig_videomode);
}
}
}
# deal with yast2 online migration conflicts in text with yast
sub yast2_migration_handle_conflicts_text {
# give a little time to check package conflicts
assert_screen 'yast2-migration-summary', 120;
if (check_screen("yast2-migration-conflicts", 15)) {
if (!is_desktop_installed()) {
send_key "alt-c";
send_key "alt-p"; # show package dependencies
}
else {
assert_and_click 'migration-proposal-packages';
}
wait_still_screen(5); # package dependencies need a few second to open in x11
save_screenshot;
if (get_var('RESOLVE_PACKAGE_CONFLICTS')) {
while (1) {
assert_screen ['package-conflict-resolution', 'addon-yast2-patterns'], 90;
last if match_has_tag 'addon-yast2-patterns';
if (match_has_tag 'package-conflict-resolution') {
wait_screen_change { send_key 'alt-1' };
if (!check_screen 'radio-button-selected', 0) { ## no critic (ProhibitDeepNests)
wait_screen_change { send_key 'spc' };
}
wait_screen_change { send_key 'alt-o' };
}
# wait for next screen, wait_screen_change is sometimes too fast
wait_still_screen 3;
}
wait_screen_change { send_key 'alt-a' };
while (1) {
assert_screen ['automatic-changes', '3rdpartylicense'];
if (match_has_tag '3rdpartylicense') {
wait_screen_change { send_key 'alt-a' };
}
elsif (match_has_tag 'automatic-changes') {
wait_screen_change { send_key 'alt-o' };
last;
}
}
assert_screen 'yast2-migration-proposal';
wait_screen_change { send_key 'alt-n' };
}
else {
die "package conflicts";
}
}
}
sub run {
my $self = shift;
# According to bsc#1106017, use yast2 migration in gnome environment is not possible on s390x
# due to vnc session over xinetd service could be stopped during migration that cause gnome exit
# so use yast2 migration under root console
if (!is_desktop_installed() || yast2_migration_gnome_remote) {
select_console 'root-console';
}
else {
select_console 'x11', await_console => 0;
ensure_unlocked_desktop;
mouse_hide(1);
assert_screen 'generic-desktop';
x11_start_program('xterm');
turn_off_gnome_screensaver if check_var('DESKTOP', 'gnome');
become_root;
if (check_var('HDDVERSION', '12') && get_var('MIGRATION_REMOVE_ADDONS')) {
# use latest yast2-registration version because is not officially available
assert_script_run 'wget --quiet ' . data_url('yast2-registration-3.1.129.18-1.noarch.rpm');
zypper_call '--no-gpg-checks in yast2-registration-3.1.129.18-1.noarch.rpm';
record_info 'workaround', 'until the package is available for SLE 12 GA';
}
}
# remove add-on and leave it registered to setup inconsistency for migration
# https://trello.com/c/CyjL1Was/837-0-yast-migration-warn-user-in-case-of-inconsistencies
if (get_var('MIGRATION_REMOVE_ADDONS')) {
script_run("yast2 add-on; echo yast2-addon-done-\$? > /dev/$serialdev", 0);
assert_screen 'addon-products';
send_key 'tab';
for my $addon (split(/,/, get_var('MIGRATION_REMOVE_ADDONS'))) {
send_key_until_needlematch 'addon-list-is-selected', 'tab'; # select add-on list
send_key_until_needlematch 'addon-list-first-adon-selected', 'home'; # go on first addon in list
send_key_until_needlematch 'addon-' . $addon . '-selected-to-remove', 'down';
send_key 'alt-t';
assert_screen 'addon-remove-warning';
send_key 'alt-t';
while (1) {
assert_screen ['addon-yast2-patterns', 'package-conflict-resolution'];
last if match_has_tag 'addon-yast2-patterns';
if (match_has_tag 'package-conflict-resolution') {
wait_screen_change { send_key 'alt-2' }; # 1 can end in unresolvable loop
wait_screen_change { send_key 'spc' };
wait_screen_change { send_key 'alt-o' };
}
# wait for next screen, wait_screen_change is sometimes too fast
wait_still_screen 3;
}
send_key 'alt-a'; # accept
assert_screen 'addon-products', 90;
}
wait_still_screen 2;
send_key 'alt-o'; # ok
wait_serial('yast2-addon-done-0') || die 'yast2 add-on failed';
}
# add-on service should have same name and the rest will be filled with tab
my %service = qw(
ha SUSE_Linux_Enterprise_High_Availability_Extension_
sdk SUSE_Linux_Enterprise_Software_Development_Kit_
we SUSE_Linux_Enterprise_Workstation_Extension_
);
for my $addon (split(/,/, get_var('MIGRATION_REMOVE_ADDONS'))) {
zypper_call "rs $service{$addon}\t"; # remove service
}
script_run("yast2 migration; echo yast2-migration-done-\$? > /dev/$serialdev", 0);
# yast2 migration would check and install minimal update before migration
# if the system doesn't perform full update or minimal update
if (!(get_var("FULL_UPDATE") || get_var("MINIMAL_UPDATE"))) {
assert_screen 'yast2-migration-onlineupdates';
send_key "alt-y";
assert_screen 'yast2-migration-updatesoverview';
if (!is_desktop_installed()) {
send_key "alt-a";
}
else {
# the shortcut key alt-a doesn't work in graphic mode
assert_and_click 'yast2-migration-accept-patch';
}
}
# wait for migration target after needed updates installed
assert_screen ['yast2-migration-target', 'yast2-migration-inconsistency'], 300;
if (match_has_tag 'yast2-migration-inconsistency') {
if (get_var('MIGRATION_INCONSISTENCY_DEACTIVATE')) {
send_key 'alt-d'; # deactivate
}
elsif (get_var('MIGRATION_INCONSISTENCY_INSTALL')) {
wait_screen_change { send_key 'alt-t' }; # install product
assert_screen ['yast2-migration-addon-not-installed', 'yast2-migration-inconsistency', 'yast2-migration-target'], 150;
if (match_has_tag 'yast2-migration-addon-not-installed') {
send_key 'alt-o'; # ok
assert_screen 'yast2-migration-inconsistency';
send_key 'alt-c'; # continue
for my $addon (split(/,/, get_var('MIGRATION_REMOVE_ADDONS'))) {
assert_screen 'yast2-migration-add-addon';
send_key 'alt-y'; # yes
}
}
if (match_has_tag 'yast2-migration-inconsistency') {
wait_screen_change { send_key 'alt-c' }; # continue
}
}
}
assert_screen 'yast2-migration-target';
send_key "alt-p"; # focus on the item of possible migration targets
assert_screen 'yast2-migration-target-list-selected', 20;
send_key_until_needlematch 'migration-target-' . get_var("VERSION"), 'down', 20, 3;
send_key "alt-n";
assert_screen ['yast2-migration-installupdate', 'yast2-migration-proposal'], 500;
if (match_has_tag 'yast2-migration-installupdate') {
send_key 'alt-y';
}
if (yast2_migration_gnome_x11) {
yast2_migration_handle_conflicts_x11($self);
}
else {
yast2_migration_handle_conflicts_text;
}
send_key "alt-n";
assert_screen 'yast2-migration-startupgrade', 90;
send_key "alt-u";
assert_screen "yast2-migration-upgrading";
# start migration
my $timeout = 7200;
my @tags = qw(
yast2-migration-wrongdigest yast2-migration-packagebroken yast2-migration-internal-error
yast2-migration-finish yast2-migration-notifications
);
while (1) {
assert_screen \@tags, $timeout;
if (match_has_tag("yast2-migration-internal-error")) {
$self->result('fail');
send_key "alt-o";
save_screenshot;
return;
}
elsif (match_has_tag("yast2-migration-packagebroken")) {
$self->result('fail');
send_key "alt-d";
save_screenshot;
send_key "alt-s";
return;
}
elsif (match_has_tag("yast2-migration-wrongdigest")) {
$self->result('fail');
send_key "alt-a";
save_screenshot;
send_key "alt-n";
return;
}
elsif (match_has_tag("yast2-migration-notifications")) {
# close notification window
send_key "alt-o";
# wait a second after pressing close button
wait_still_screen(1);
}
last if (match_has_tag("yast2-migration-finish"));
}
send_key "alt-f";
# after migration yast may ask to reboot system
if (check_screen("yast2-ask-reboot", 5)) {
# reboot
send_key "alt-r";
power_action('reboot', observe => 1, keepconsole => 1);
# sometimes reboot takes longer time after online migration
# give more time to reboot
$self->wait_boot(bootloader_time => 300, textmode => !is_desktop_installed);
}
else {
wait_serial("yast2-migration-done-0", $timeout) || die "yast2 migration failed";
type_string "exit\n" if (is_desktop_installed());
}
}
sub test_flags {
return {fatal => 1};
}
sub post_fail_hook {
my ($self) = @_;
select_console 'log-console';
$self->save_and_upload_log('journalctl -b', '/tmp/journal.log', {screenshot => 1});
$self->export_logs_desktop;
$self->SUPER::post_fail_hook;
}
1;