-
Notifications
You must be signed in to change notification settings - Fork 283
/
Copy pathy2_logs_helper.pm
212 lines (178 loc) · 6.52 KB
/
y2_logs_helper.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
package y2_logs_helper;
use testapi;
use strict;
use warnings;
use version_utils qw(is_sle);
use ipmi_backend_utils;
use network_utils;
use utils 'zypper_call';
use Exporter 'import';
use Utils::Architectures;
use Utils::Logging 'tar_and_upload_log';
our @EXPORT_OK = qw(
select_conflict_resolution
workaround_dependency_issues
break_dependency
vendor_change_dependency
verify_license_has_to_be_accepted
accept_license
verify_license_translations
get_available_compression
upload_autoyast_profile
upload_autoyast_schema
);
# select the conflict resolution for dependency issues
sub select_conflict_resolution {
# higher similarity level as this should only select a single
# entry, not close the dialog or something
wait_screen_change(sub { send_key 'spc' }, undef, similarity_level => 55);
# lower similarity level to not confuse the button press for
# screen change
wait_screen_change(sub { send_key 'alt-o' }, undef, similarity_level => 48);
}
# to workaround dependency issues
sub workaround_dependency_issues {
return unless check_screen 'dependency-issue', 10;
if (check_var('VIDEOMODE', 'text')) {
while (check_screen('dependency-issue', 5)) {
wait_screen_change { send_key 'alt-s' };
wait_screen_change { send_key 'ret' };
wait_screen_change { send_key 'alt-o' };
}
}
else {
while (check_screen('dependency-issue', 5)) {
wait_screen_change { send_key 'alt-1' };
select_conflict_resolution;
# Refer ticket https://progress.opensuse.org/issues/48266
wait_still_screen(2);
}
}
return 1;
}
# to break dependency issues
sub break_dependency {
return unless check_screen 'dependency-issue', 10;
if (check_var('VIDEOMODE', 'text')) {
while (check_screen('dependency-issue-text', 5)) { # repeat it untill all dependency issues are resolved
wait_screen_change { send_key 'alt-s' }; # Solution
send_key 'down'; # down to option break dependency
send_key 'ret'; # select option break dependency
wait_screen_change { send_key 'alt-o' }; # OK - Try Again
}
}
else {
while (check_screen('dependency-issue', 5)) {
# 2 is the option to break dependency
send_key 'alt-2';
select_conflict_resolution;
# Refer ticket https://progress.opensuse.org/issues/48266
wait_still_screen(2);
}
}
}
# to fix vendor change dependency issues
sub vendor_change_dependency {
return unless check_screen 'dependency-issue', 10;
while (check_screen('dependency-issue', 5)) {
# Cancel conflict
send_key 'alt-c';
# Refer ticket https://progress.opensuse.org/issues/48266
wait_still_screen(2);
}
assert_screen('software-dependency');
send_key 'alt-o';
assert_and_click('allow-vendor-change');
assert_and_click('accept-option-change');
assert_screen('automatic-change');
send_key 'alt-o';
assert_and_click('continue-unsupported-pkgs');
}
=head2 verify_license_has_to_be_accepted
verify_license_has_to_be_accepted;
Explicitly check that the license has to be accepted.
Press 'Next' button to trigger a popup saying that the License has to be accepted then close the popup.
=cut
sub verify_license_has_to_be_accepted {
send_key $cmd{next};
assert_screen 'license-not-accepted';
send_key $cmd{ok};
wait_still_screen 1;
}
=head2 accept_license
accept_license;
Select checkbox accepting the License agreement and check if it is actually selected.
Mark the test as failed if the checkbox is not selected after sending an appropriate command, otherwise proceed further.
=cut
sub accept_license {
send_key $cmd{accept};
assert_screen('license-agreement-accepted');
}
sub verify_license_translations {
return if (is_sle && get_var("BETA"));
my $current_lang = 'english-us';
for my $lang (split(/,/, get_var('EULA_LANGUAGES')), 'english-us') {
wait_screen_change { send_key 'alt-l' };
# in textmode only arrow navigation is possible
if (get_var('VIDEOMODE') =~ 'text') {
send_key_until_needlematch("license-language-selected-english-us", 'up', 61);
send_key 'ret';
}
else {
assert_and_click "license-language-selected-$current_lang";
}
wait_screen_change { type_string(substr($lang, 0, 1)) } unless (check_var('VIDEOMODE', 'text'));
send_key_until_needlematch("license-language-selected-dropbox-$lang", 'down', 61);
if (is_s390x()) {
record_soft_failure('bsc#1172738 - "Next" button is triggered, even though it is not in focus while selecting language on License Agreement screen on s390x');
assert_and_click("license-language-selected-dropbox-$lang");
}
else {
send_key 'ret';
}
assert_screen "license-content-$lang";
$current_lang = $lang;
}
}
sub get_available_compression {
my %extensions = (bzip2 => '.bz2', gzip => '.gz', xz => '.xz');
foreach my $binary (sort keys %extensions) {
return $extensions{$binary} unless script_run("type $binary");
}
return "";
}
=head2 upload_autoyast_profile
upload_autoyast_profile($self);
Uploads autoyast profile used for the installation, as well as modified profile,
in case feature to modify the profile dynamically was used.
Non existing files will be ignored.
=cut
sub upload_autoyast_profile {
# Upload autoyast profile if file exists
if (script_run('test -e /tmp/profile/autoinst.xml') == 0) {
upload_logs '/tmp/profile/autoinst.xml';
}
# Upload cloned system profile if file exists
if (script_run('test -e /root/autoinst.xml') == 0) {
upload_logs '/root/autoinst.xml';
}
# Upload modified profile if pre-install script uses this feature
if (script_run('test -e /tmp/profile/modified.xml') == 0) {
upload_logs '/tmp/profile/modified.xml';
}
save_screenshot;
}
=head2 upload_autoyast_schema
upload_autoyast_schema($self);
Uploads autoyast schema files shipped in the distribution as a tarball.
If expected directory doesn't exist, no attempt to upload logs occurs.
=cut
sub upload_autoyast_schema {
my ($self) = @_;
my $xml_schema_path = "/usr/share/YaST2/schema/autoyast/rng";
# Upload schema files if directory exists
if (script_run("test -e $xml_schema_path") == 0) {
tar_and_upload_log("$xml_schema_path/*.rng", '/tmp/autoyast_schema.tar.bz2');
}
}
1;