-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathutils.resource
More file actions
265 lines (200 loc) · 7.09 KB
/
utils.resource
File metadata and controls
265 lines (200 loc) · 7.09 KB
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
*** Settings ***
Documentation authd test resources
Resource kvm.resource
Library ./Journal.py AS Journal
Library ./StringUtils.py AS StringUtils
Library ./VideoLogger.py AS VideoLogger
Library ./VNCRecorder.py AS VNCRecorder
Library ./Snapshot.py AS Snapshot
Library ./SSH.py AS SSH
Library Process
Library OperatingSystem
*** Variables ***
${SUITE_OUTPUT_DIR} ${OUTPUT_DIR}/${SUITE_NAME.rsplit('.')[-1]}
# Save yarf debug screenshots as files in the suite output directory so that
# they are referenced by relative URLs in log.html instead of being embedded
# as base64. Set to an empty string to fall back to inline base64 embedding.
${YARF_IMAGE_DIR} ${SUITE_OUTPUT_DIR}/screenshots
*** Keywords ***
Log In
Set OCR Confidence Threshold 0.94
Set OCR Coincidence Threshold 92
Log In With Password ubuntu
Log In With Password
[Arguments] ${password}
Match Text Not listed 300
Wait Until User Selected
Hid.Type String ${password}
Hid.Keys Combo Return
Wait Until Desktop Ready
Log In And Set Password
[Arguments] ${new_password}
Match Text Not listed 300
Wait Until User Selected
Hid.Type String ubuntu
Hid.Keys Combo Return
Match Text You are required to change your password immediately 30
Match Text Changing password 30
Sleep 2
Hid.Type String ubuntu
Hid.Keys Combo Return
Match Text New password 30
Hid.Type String ${new_password}
Hid.Keys Combo Return
Match Text Retype new password 30
Hid.Type String ${new_password}
Hid.Keys Combo Return
Wait Until Desktop Ready
Wait Until User Selected
Wait Until Keyword Succeeds 120 sec 1 sec
... Try Select User
Try Select User
Hid.Keys Combo Return
Match Text Password
Log Out
Run Command gnome-session-quit --logout --no-prompt
Wait Until Desktop Ready
Wait Until Keyword Succeeds 1 min 1 sec
... Try Desktop Ready
# Before 26.04, GNOME Shell sometimes starts with the Activities overview
# opened, see https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/2145704.
# That causes the next steps to fail, so we need to ensure the overview is
# closed before proceeding.
${matches}= Find Text Type to search
IF ${matches}
Log Activities Overview is open, closing it
Close Activities Overview
END
Close Activities Overview
WHILE True
Hid.Keys Combo Escape
BuiltIn.Sleep 1
${matches}= Find Text Type to search
IF not ${matches}
BREAK
END
END
Try Desktop Ready
Hid.Move Pointer To Proportional 1 1
BuiltIn.Sleep 1
Hid.Move Pointer To Proportional 0 1
Match Text Show Apps 2
Open Terminal
Run Command x-terminal-emulator
Hid.Move Pointer To Proportional 1 1
Match Text @ubuntu:~$ 120
Hid.Keys Combo F11
Hid.Move Pointer To Proportional 1 1
Match Text @ubuntu:~$ 120
Open Terminal In Sudo Mode
Open Terminal
Enter Sudo Mode In Terminal
Enter Sudo Mode In Terminal
Hid.Type String clear
Hid.Keys Combo Return
Hid.Type String sudo -s
Hid.Keys Combo Return
Match Text root@ubuntu 120
Hid.Type String clear
Hid.Keys Combo Return
Match Text root@ubuntu 120
Close Focused Window
Hid.Keys Combo Alt_L F4
Close Terminal In Sudo Mode
Hid.Type String clear
Hid.Keys Combo Return
Match Text root@ubuntu 120
Hid.Type String exit
Hid.Keys Combo Return
Close Focused Window
Log Out From Terminal Session
Match Text @ubuntu 120
# We are in a machinectl session, so we need to ^] thrice to exit properly
Hid.Keys Combo Control_L ]
Hid.Keys Combo Control_L ]
Hid.Keys Combo Control_L ]
Log Out From SSH Session
Hid.Type String exit
Hid.Keys Combo Return
Match Text ubuntu@ubuntu 120
Run Command In Terminal
[Arguments] ${command} ${timeout}=${600}
Open Terminal
# Y21kLWZpbmlzaGVkCg== is the base64 encoding of "cmd-finished\n"
# We use it to avoid that the `Match Text` below matches the command itself,
# before the first clear is executed.
Hid.Type String clear && ${command} && echo Y21kLWZpbmlzaGVkCg== | base64 -d
Hid.Keys Combo Return
Match Text cmd-finished ${timeout}
Close Focused Window
Left Button Click
BuiltIn.Sleep 0.5
Click LEFT Button
BuiltIn.Sleep 0.5
Hid.Move Pointer To Proportional 1 1
Run Command
[Arguments] ${command}
Hid.Keys Combo Alt_L F2
Match Text Run a Command 15
Hid.Type String ${command}
Wait Until Keyword Succeeds 5s 1s Submit Run Command Dialog
Submit Run Command Dialog
Hid.Keys Combo Return
# Ensure the dialog is closed, because sometimes the Return keypress does
# not trigger the command execution and the dialog remains open.
${matches}= Find Text Run a Command
Should Be Empty ${matches}
Start Application
[Arguments] ${application}
Run Command ${application}
Cancel Operation
Match Text @ubuntu 15
Hid.Keys Combo Control_L C
Update And Upgrade Packages
SSH.Execute apt-get update
SSH.Execute apt-get upgrade -y timeout=1200
Sync System Time
${output} = SSH.Execute nm-online -q && systemctl restart systemd-timesyncd
Log ${output} level=DEBUG
${output} = SSH.Execute timedatectl show -p NTPSynchronized | grep -q NTPSynchronized=yes
Log ${output} level=DEBUG
Wait Until System Time Synced
Wait Until Keyword Succeeds 1 min 1 sec
... Sync System Time
Try machinectl login Prompt
VAR ${tries} 3
WHILE ${tries} > 0
Hid.Type String machinectl login
Hid.Keys Combo Return
${match} = Run Keyword And Return Status
... Match Text ubuntu login: 120
IF '${match}' == 'True'
BREAK
END
Hid.Keys Combo Control_L ]
Hid.Keys Combo Control_L ]
Hid.Keys Combo Control_L ]
${tries} = Evaluate ${tries} - 1
END
Force Password Change
Hid.Type String passwd -e ubuntu
Hid.Keys Combo Return
Match Text passwd: password changed. 30
### Setup ###
Restore Snapshot
[Arguments] ${snapshot}
Snapshot.Restore ${snapshot}
Wait Until System Time Synced
Test Setup
[Arguments] ${snapshot}
Set Suite Metadata Ubuntu Version %{RELEASE} top=True
Set Suite Metadata Broker %{BROKER} top=True
Restore Snapshot ${snapshot}
Journal.Start Receiving Journal
VNCRecorder.Start Recording
### Teardown ###
Test Teardown
VNCRecorder.Stop Recording
Journal.Stop Receiving Journal
VideoLogger.Log videos
Journal.Log Journal