@@ -14,7 +14,8 @@ Test Tags generic-device-plugin
14
14
15
15
16
16
*** Variables ***
17
- ${NAMESPACE } ${EMPTY }
17
+ ${NAMESPACE } ${EMPTY }
18
+ ${DEVICE_COUNT } 5
18
19
19
20
20
21
*** Test Cases ***
@@ -36,6 +37,18 @@ Verify that mountPath correctly renames the device within the container
36
37
37
38
[Teardown] GDP Test Teardown
38
39
40
+ Verify ttyUSB glob pattern device discovery and allocation
41
+ [Documentation] Tests GDP with glob pattern to discover multiple ttyUSB devices and verify device allocation across multiple pods
42
+ [Tags] glob-pattern
43
+ [Setup] TtyUSB Glob Test Setup
44
+
45
+ # Create and verify pods with device allocation
46
+ Create Pod And Verify Allocation serial-test-pod 2 2
47
+ Create Pod And Verify Allocation serial-test-pod1 1 3
48
+ Create Pod And Verify Allocation serial-test-pod2 2 5
49
+
50
+ [Teardown] TtyUSB Glob Test Teardown
51
+
39
52
40
53
*** Keywords ***
41
54
GDP Test Setup
@@ -119,20 +132,21 @@ Create Test Job With Modified Script
119
132
120
133
Wait Until Device Is Allocatable
121
134
[Documentation] Waits until device device.microshift.io/fakeserial is allocatable
135
+ [Arguments] ${expected_count } =1
122
136
${node } = Run With Kubeconfig oc get node -o=name
123
137
${node_name } = Remove String ${node } node/
124
138
Wait Until Keyword Succeeds 60s 5s
125
- ... Device Should Be Allocatable ${node_name }
139
+ ... Device Should Be Allocatable ${node_name } ${ expected_count }
126
140
127
141
Device Should Be Allocatable
128
142
[Documentation] Checks if device device.microshift.io/fakeserial is allocatable
129
- [Arguments] ${node_name }
143
+ [Arguments] ${node_name } ${ expected_count } = 1
130
144
${device_amount } = Oc Get JsonPath
131
145
... node
132
146
... ${EMPTY }
133
147
... ${node_name }
134
148
... .status.allocatable.device\\.microshift\\.io/fakeserial
135
- Should Be Equal As Integers ${device_amount } 1
149
+ Should Be Equal As Integers ${device_amount } ${ expected_count }
136
150
137
151
Wait For Job Completion And Check Logs
138
152
[Documentation] Waits for Job completion and checks Pod logs looking for 'Test successful' message
@@ -146,12 +160,69 @@ Wait For Job Completion And Check Logs
146
160
${logs } = Oc Logs ${pod } ${NAMESPACE }
147
161
Should Contain ${logs } Test successful
148
162
163
+ Create TtyUSB Devices
164
+ [Documentation] Creates dummy ttyUSB devices
165
+ FOR ${i } IN RANGE ${DEVICE_COUNT }
166
+ Command Execution sudo mknod --mode=666 /dev/ttyUSB${i } c 166 ${i }
167
+ END
168
+
169
+ Remove Dummy TtyUSB Devices
170
+ [Documentation] Removes dummy ttyUSB devices
171
+ FOR ${i } IN RANGE ${DEVICE_COUNT }
172
+ Command Execution sudo rm -f /dev/ttyUSB${i }
173
+ END
174
+
175
+ TtyUSB Glob Test Setup
176
+ [Documentation] Setup for ttyUSB glob pattern test - creates devices, configures GDP, waits for allocation
177
+ Create TtyUSB Devices
178
+ Drop In MicroShift Config ${GDP_CONFIG_SERIAL_GLOB } 10 -gdp
179
+ Restart MicroShift
180
+ Wait Until Device Is Allocatable ${DEVICE_COUNT }
181
+
182
+ TtyUSB Glob Test Teardown
183
+ [Documentation] Cleanup for ttyUSB glob pattern test
184
+ Oc Delete pod --all -n ${NAMESPACE }
185
+ Remove Dummy TtyUSB Devices
186
+ Disable GDP
187
+
188
+ Verify Node Device Allocation
189
+ [Documentation] Verifies device allocation on the node matches expected total
190
+ [Arguments] ${expected_total_allocated }
191
+ ${node } = Run With Kubeconfig oc get node -o=name
192
+ ${node_name } = Remove String ${node } node/
193
+ ${describe_output } = Run With Kubeconfig oc describe node ${node_name }
194
+ ${allocated_line } = Get Lines Containing String ${describe_output } device.microshift.io/fakeserial
195
+ ${allocated_count } = Get Regexp Matches
196
+ ... ${allocated_line }
197
+ ... device\\.microshift\\.io/fakeserial\\s+(\\d+)
198
+ ... 1
199
+ VAR ${allocated_count } = ${allocated_count[0] }
200
+ Should Be Equal As Integers ${allocated_count } ${expected_total_allocated }
201
+
202
+ Create Pod And Verify Allocation
203
+ [Documentation] Creates a pod using dynamic spec generation and verifies device allocation
204
+ [Arguments] ${pod_name } ${requested_devices } ${expected_total_allocated }
205
+
206
+ # Generate pod spec dynamically
207
+ ${pod_spec } = Get Ttyusb Pod Definition ${pod_name } ${requested_devices }
208
+
209
+ # Create and wait for pod
210
+ ${path } = Create Random Temp File ${pod_spec }
211
+ Oc Create -f ${path } -n ${NAMESPACE }
212
+ Oc Wait -n ${NAMESPACE } pod/${pod_name } --for=condition=Ready --timeout=120s
213
+
214
+ # Verify correct number of devices allocated to pod
215
+ ${devices_in_pod } = Oc Exec ${pod_name } ls /dev/ | grep ttyUSB | wc -l ${NAMESPACE }
216
+ Should Be Equal As Integers ${devices_in_pod } ${requested_devices }
217
+
218
+ # Verify node shows correct allocation
219
+ Verify Node Device Allocation ${expected_total_allocated }
220
+
149
221
Teardown Suite With GDP Cleanup
150
222
[Documentation] Suite teardown that cleans up GDP configuration and restarts MicroShift
151
223
# Clean up any remaining GDP configuration
152
224
Remove Drop In MicroShift Config 10-gdp
153
225
# Restart MicroShift to clean state for next suite
154
226
Restart MicroShift
155
227
Restart Greenboot And Wait For Success
156
- # Call original suite teardown
157
228
Teardown Suite With Namespace
0 commit comments