Skip to content

Commit 264513f

Browse files
author
Kasturi Narra
committed
Add test for testing hot plug of devices
1 parent 22dd231 commit 264513f

File tree

2 files changed

+23
-36
lines changed

2 files changed

+23
-36
lines changed

test/suites/optional/generic-device-plugin.robot

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,31 @@ ${NAMESPACE} ${EMPTY}
2020
*** Test Cases ***
2121
Sanity Test
2222
[Documentation] Performs a simple test of Generic Device Plugin
23-
[Setup] GDP Test Setup ${GDP_CONFIG_DROPIN}
23+
[Setup] Run Keywords
24+
... Enable And Configure GDP
25+
... Enable Serialsim
26+
... Copy Script To Host
2427

28+
Wait Until Device Is Allocatable
29+
30+
Command Should Work crictl pull registry.access.redhat.com/ubi9/ubi:9.6
31+
Start Script On Host
2532
Create Test Job
26-
Wait For Job Completion And Check Logs
2733

28-
[Teardown] GDP Test Teardown
34+
Wait For Job Completion And Check Logs
2935

30-
Verify that mountPath correctly renames the device within the container
31-
[Documentation] Performs a test of Generic Device Plugin with custom mountPath configuration
32-
[Setup] GDP Test Setup ${GDP_CONFIG_DROPIN_WITH_MOUNT}
36+
[Teardown] Run Keywords
37+
... Stop Script On Host
38+
... Disable GDP
3339

34-
Create Test Job With Modified Script
35-
Wait For Job Completion And Check Logs
40+
Verify GDP handles hot plugging of Devices
41+
[Documentation] Verify that GDP reacts to devices being added or removed after MicroShift has started
42+
[Tags] hot-plug
43+
Enable And Configure GDP
44+
Wait Until Device Is Allocatable 0
3645

37-
[Teardown] GDP Test Teardown
46+
Enable Serialsim
47+
Wait Until Device Is Allocatable 1
3848

3949

4050
*** Keywords ***
@@ -106,35 +116,23 @@ Create Test Job
106116
Oc Create -f ${path} -n ${NAMESPACE}
107117
Oc Create -f ./assets/generic-device-plugin/job.yaml -n ${NAMESPACE}
108118

109-
Create Test Job With Modified Script
110-
[Documentation] Creates Job that spawns test Pod running to completion with modified script.
111-
${script}= OperatingSystem.Get File ./assets/generic-device-plugin/fake-serial-communication.py
112-
${modified_script}= Replace String
113-
... ${script}
114-
... DEVICE_POD = "/dev/ttyPipeB0"
115-
... DEVICE_POD = "/dev/myrenamedserial"
116-
${configmap}= Append To Preamble ${modified_script}
117-
Log ${configmap}
118-
${path}= Create Random Temp File ${configmap}
119-
Oc Create -f ${path} -n ${NAMESPACE}
120-
Oc Create -f ./assets/generic-device-plugin/job.yaml -n ${NAMESPACE}
121-
122119
Wait Until Device Is Allocatable
123120
[Documentation] Waits until device device.microshift.io/fakeserial is allocatable
121+
[Arguments] ${expected_count}=1
124122
${node}= Run With Kubeconfig oc get node -o=name
125123
${node_name}= Remove String ${node} node/
126124
Wait Until Keyword Succeeds 60s 5s
127-
... Device Should Be Allocatable ${node_name}
125+
... Device Should Be Allocatable ${node_name} ${expected_count}
128126

129127
Device Should Be Allocatable
130128
[Documentation] Checks if device device.microshift.io/fakeserial is allocatable
131-
[Arguments] ${node_name}
129+
[Arguments] ${node_name} ${expected_count}=1
132130
${device_amount}= Oc Get JsonPath
133131
... node
134132
... ${EMPTY}
135133
... ${node_name}
136134
... .status.allocatable.device\\.microshift\\.io/fakeserial
137-
Should Be Equal As Integers ${device_amount} 1
135+
Should Be Equal As Integers ${device_amount} ${expected_count}
138136

139137
Wait For Job Completion And Check Logs
140138
[Documentation] Waits for Job completion and checks Pod logs looking for 'Test successful' message

test/suites/optional/strings.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,6 @@
88
- path: /dev/ttyPipeB0
99
'''
1010

11-
GDP_CONFIG_DROPIN_WITH_MOUNT = '''
12-
genericDevicePlugin:
13-
status: Enabled
14-
devices:
15-
- name: fakeserial
16-
groups:
17-
- paths:
18-
- path: /dev/ttyPipeB0
19-
mountPath: /dev/myrenamedserial
20-
'''
21-
2211
CONFIGMAP_PREAMBLE = '''
2312
apiVersion: v1
2413
kind: ConfigMap

0 commit comments

Comments
 (0)