Skip to content

Commit 31c38b0

Browse files
author
Kasturi Narra
committed
Add test to verify count in GDP config
1 parent 1bea7d5 commit 31c38b0

File tree

2 files changed

+72
-27
lines changed

2 files changed

+72
-27
lines changed

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

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,46 @@ ${DEVICE_COUNT} 5
2121
*** Test Cases ***
2222
Sanity Test
2323
[Documentation] Performs a simple test of Generic Device Plugin
24-
[Setup] GDP Test Setup ${GDP_CONFIG_DROPIN}
24+
[Setup] Run Keywords
25+
... Enable And Configure GDP
26+
... Enable Serialsim
27+
... Copy Script To Host
2528

29+
Wait Until Device Is Allocatable
30+
31+
Command Should Work crictl pull registry.access.redhat.com/ubi9/ubi:9.6
32+
Start Script On Host
2633
Create Test Job
34+
2735
Wait For Job Completion And Check Logs
2836

29-
[Teardown] GDP Test Teardown
37+
[Teardown] Run Keywords
38+
... Stop Script On Host
39+
... Disable GDP
3040

31-
Verify that mountPath correctly renames the device within the container
32-
[Documentation] Performs a test of Generic Device Plugin with custom mountPath configuration
33-
[Setup] GDP Test Setup ${GDP_CONFIG_DROPIN_WITH_MOUNT}
41+
Verify FUSE device allocation and accessibility
42+
[Documentation] Verifies FUSE device configuration, allocation, and accessibility in pods
43+
[Tags] fuse-device
3444
35-
Create Test Job With Modified Script
36-
Wait For Job Completion And Check Logs
45+
Enable And Configure GDP ${GDP_CONFIG_FUSE_COUNT}
46+
Wait Until Device Is Allocatable 10 fuse
47+
# Create and deploy pod requesting 4 FUSE devices
48+
${path}= Create Random Temp File ${POD_FUSE_DEVICE}
49+
Oc Create -f ${path} -n ${NAMESPACE}
50+
51+
# Wait for pod to be ready and verify device accessibility
52+
Oc Wait -n ${NAMESPACE} pod/fuse-test-pod --for=condition=Ready --timeout=120s
53+
54+
# Verify /dev/fuse is accessible in the pod
55+
${fuse_device}= Run With Kubeconfig oc exec -n ${NAMESPACE} fuse-test-pod -- ls -l /dev/fuse
56+
Should Contain ${fuse_device} /dev/fuse
3757

38-
[Teardown] GDP Test Teardown
58+
# Verify node allocation shows 4 FUSE devices allocated
59+
${node}= Run With Kubeconfig oc get node -o=name
60+
${node_name}= Remove String ${node} node/
61+
${describe_output}= Run With Kubeconfig oc describe node ${node_name}
62+
Should Contain ${describe_output} device.microshift.io/fuse: 10
63+
Should Contain ${describe_output} device.microshift.io/fuse 4 4
3964

4065
Verify ttyUSB glob pattern device discovery and allocation
4166
[Documentation] Tests GDP with glob pattern to discover multiple ttyUSB devices and verify device allocation across multiple pods
@@ -117,35 +142,22 @@ Create Test Job
117142
Oc Create -f ${path} -n ${NAMESPACE}
118143
Oc Create -f ./assets/generic-device-plugin/job.yaml -n ${NAMESPACE}
119144

120-
Create Test Job With Modified Script
121-
[Documentation] Creates Job that spawns test Pod running to completion with modified script.
122-
${script}= OperatingSystem.Get File ./assets/generic-device-plugin/fake-serial-communication.py
123-
${modified_script}= Replace String
124-
... ${script}
125-
... DEVICE_POD = "/dev/ttyPipeB0"
126-
... DEVICE_POD = "/dev/myrenamedserial"
127-
${configmap}= Append To Preamble ${modified_script}
128-
Log ${configmap}
129-
${path}= Create Random Temp File ${configmap}
130-
Oc Create -f ${path} -n ${NAMESPACE}
131-
Oc Create -f ./assets/generic-device-plugin/job.yaml -n ${NAMESPACE}
132-
133145
Wait Until Device Is Allocatable
134-
[Documentation] Waits until device device.microshift.io/fakeserial is allocatable
135-
[Arguments] ${expected_count}=1
146+
[Documentation] Waits until specified device is allocatable
147+
[Arguments] ${expected_count}=1 ${device_type}=fakeserial
136148
${node}= Run With Kubeconfig oc get node -o=name
137149
${node_name}= Remove String ${node} node/
138150
Wait Until Keyword Succeeds 60s 5s
139-
... Device Should Be Allocatable ${node_name} ${expected_count}
151+
... Device Should Be Allocatable ${node_name} ${expected_count} ${device_type}
140152

141153
Device Should Be Allocatable
142-
[Documentation] Checks if device device.microshift.io/fakeserial is allocatable
143-
[Arguments] ${node_name} ${expected_count}=1
154+
[Documentation] Checks if specified device is allocatable
155+
[Arguments] ${node_name} ${expected_count}=1 ${device_type}=fakeserial
144156
${device_amount}= Oc Get JsonPath
145157
... node
146158
... ${EMPTY}
147159
... ${node_name}
148-
... .status.allocatable.device\\.microshift\\.io/fakeserial
160+
... .status.allocatable.device\\.microshift\\.io/${device_type}
149161
Should Be Equal As Integers ${device_amount} ${expected_count}
150162

151163
Wait For Job Completion And Check Logs

test/suites/optional/strings.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,39 @@
2929
- path: /dev/ttyUSB*
3030
'''
3131

32+
GDP_CONFIG_FUSE_COUNT = '''
33+
genericDevicePlugin:
34+
status: Enabled
35+
devices:
36+
- name: fuse
37+
groups:
38+
- count: 10
39+
paths:
40+
- path: /dev/fuse
41+
'''
42+
43+
POD_FUSE_DEVICE = '''
44+
apiVersion: v1
45+
kind: Pod
46+
metadata:
47+
name: fuse-test-pod
48+
spec:
49+
containers:
50+
- name: fuse-app-container
51+
image: registry.access.redhat.com/ubi9/ubi:9.6
52+
command: ["sleep", "infinity"]
53+
resources:
54+
limits:
55+
device.microshift.io/fuse: "4"
56+
securityContext:
57+
allowPrivilegeEscalation: false
58+
capabilities:
59+
drop: ["ALL"]
60+
runAsNonRoot: true
61+
seccompProfile:
62+
type: "RuntimeDefault"
63+
'''
64+
3265
CONFIGMAP_PREAMBLE = '''
3366
apiVersion: v1
3467
kind: ConfigMap

0 commit comments

Comments
 (0)