Skip to content

Commit 22dd231

Browse files
author
Kasturi Narra
committed
Adding new test case for robot framework
1 parent c078380 commit 22dd231

File tree

2 files changed

+74
-18
lines changed

2 files changed

+74
-18
lines changed

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

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Variables strings.py
88
Library strings.py
99

1010
Suite Setup Setup Suite With Namespace
11-
Suite Teardown Teardown Suite With Namespace
11+
Suite Teardown Teardown Suite With GDP Cleanup
1212

1313
Test Tags generic-device-plugin
1414

@@ -20,35 +20,50 @@ ${NAMESPACE} ${EMPTY}
2020
*** Test Cases ***
2121
Sanity Test
2222
[Documentation] Performs a simple test of Generic Device Plugin
23-
[Setup] Run Keywords
24-
... Enable And Configure GDP
25-
... Enable Serialsim
26-
... Copy Script To Host
23+
[Setup] GDP Test Setup ${GDP_CONFIG_DROPIN}
2724

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
3225
Create Test Job
26+
Wait For Job Completion And Check Logs
27+
28+
[Teardown] GDP Test Teardown
29+
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}
3333

34+
Create Test Job With Modified Script
3435
Wait For Job Completion And Check Logs
3536

36-
[Teardown] Run Keywords
37-
... Stop Script On Host
38-
... Disable GDP
37+
[Teardown] GDP Test Teardown
3938

4039

4140
*** Keywords ***
41+
GDP Test Setup
42+
[Documentation] Common setup for GDP tests - configures GDP, enables serialsim, prepares environment
43+
[Arguments] ${config_content}
44+
Enable And Configure GDP ${config_content}
45+
Enable Serialsim
46+
Copy Script To Host
47+
Wait Until Device Is Allocatable
48+
Command Should Work crictl pull registry.access.redhat.com/ubi9/ubi:9.6
49+
Start Script On Host
50+
51+
GDP Test Teardown
52+
[Documentation] Common teardown for GDP tests - stops script, cleans up resources, disables GDP
53+
Stop Script On Host
54+
Cleanup Test Resources
55+
Disable GDP
56+
4257
Enable And Configure GDP
4358
[Documentation] Enables GDP and adds fake device path in MicroShift configuration
44-
Drop In MicroShift Config ${GDP_CONFIG_DROPIN} 10-gdp
59+
[Arguments] ${config_content}=${GDP_CONFIG_DROPIN} ${dropin_name}=10-gdp
60+
Drop In MicroShift Config ${config_content} ${dropin_name}
4561
Restart MicroShift
4662

4763
Disable GDP
48-
[Documentation] Removes GDP configuration drop-in
49-
Remove Drop In MicroShift Config 10-gdp
50-
Restart MicroShift
51-
Restart Greenboot And Wait For Success
64+
[Documentation] Removes GDP configuration drop-in (without restart)
65+
[Arguments] ${dropin_name}=10-gdp
66+
Remove Drop In MicroShift Config ${dropin_name}
5267

5368
Enable Serialsim
5469
[Documentation] Enables the serialsim kernel module.
@@ -75,6 +90,13 @@ Stop Script On Host
7590
Command Execution systemctl stop gdp-test-comm
7691
Command Execution systemctl reset-failed gdp-test-comm
7792

93+
Cleanup Test Resources
94+
[Documentation] Cleans up test resources including configmap and job
95+
Run Keyword And Ignore Error
96+
... Oc Delete job/gdp-test -n ${NAMESPACE}
97+
Run Keyword And Ignore Error
98+
... Oc Delete configmap/gdp-script -n ${NAMESPACE}
99+
78100
Create Test Job
79101
[Documentation] Creates Job that spawns test Pod running to completion.
80102
${script}= OperatingSystem.Get File ./assets/generic-device-plugin/fake-serial-communication.py
@@ -84,11 +106,23 @@ Create Test Job
84106
Oc Create -f ${path} -n ${NAMESPACE}
85107
Oc Create -f ./assets/generic-device-plugin/job.yaml -n ${NAMESPACE}
86108

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+
87122
Wait Until Device Is Allocatable
88123
[Documentation] Waits until device device.microshift.io/fakeserial is allocatable
89124
${node}= Run With Kubeconfig oc get node -o=name
90125
${node_name}= Remove String ${node} node/
91-
92126
Wait Until Keyword Succeeds 60s 5s
93127
... Device Should Be Allocatable ${node_name}
94128

@@ -113,3 +147,14 @@ Wait For Job Completion And Check Logs
113147
... .items[*].metadata.name
114148
${logs}= Oc Logs ${pod} ${NAMESPACE}
115149
Should Contain ${logs} Test successful
150+
151+
Teardown Suite With GDP Cleanup
152+
[Documentation] Suite teardown that cleans up GDP configuration and restarts MicroShift
153+
# Clean up any remaining GDP configuration
154+
Run Keyword And Ignore Error
155+
... Remove Drop In MicroShift Config 10-gdp
156+
# Restart MicroShift to clean state for next suite
157+
Restart MicroShift
158+
Restart Greenboot And Wait For Success
159+
# Call original suite teardown
160+
Teardown Suite With Namespace

test/suites/optional/strings.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
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+
1122
CONFIGMAP_PREAMBLE = '''
1223
apiVersion: v1
1324
kind: ConfigMap

0 commit comments

Comments
 (0)