Skip to content

Commit 74fb061

Browse files
committed
tests for code-server
1 parent 03175f9 commit 74fb061

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
*** Comments ***
2+
This test suite verifies the functionality of the Containerlab code-server tool operations:
3+
- Starting a code-server container with default settings
4+
- Checking code-server status in table and JSON formats
5+
- Stopping a code-server container
6+
- Starting a code-server container with a custom port
7+
- Verifying cleanup behaviour when no code-server containers are running
8+
9+
*** Settings ***
10+
Library OperatingSystem
11+
Library String
12+
Resource ../common.robot
13+
14+
Suite Teardown Run Keyword Cleanup Code Server Containers
15+
16+
*** Variables ***
17+
${runtime} docker
18+
${code_server_name} clab-code-server
19+
${code_server_image} ghcr.io/kaelemc/clab-code-server:main
20+
${custom_port} 10080
21+
22+
*** Test Cases ***
23+
Start Code Server With Default Settings
24+
[Documentation] Test starting code-server with default parameters
25+
${rc} ${output}= Run And Return Rc And Output
26+
... ${CLAB_BIN} --runtime ${runtime} tools code-server start
27+
Log ${output}
28+
Should Be Equal As Integers ${rc} 0
29+
Should Contain ${output} code-server container ${code_server_name} started successfully
30+
Should Contain ${output} code-server available at: http://0.0.0.0:
31+
32+
Check Code Server Status
33+
[Documentation] Verify code-server status is reported in table format
34+
${rc} ${output}= Run And Return Rc And Output
35+
... ${CLAB_BIN} --runtime ${runtime} tools code-server status
36+
Log ${output}
37+
Should Be Equal As Integers ${rc} 0
38+
Should Contain ${output} ${code_server_name}
39+
Should Contain ${output} running
40+
Should Contain ${output} ~/.clab
41+
42+
Check Code Server Status JSON Format
43+
[Documentation] Verify code-server status is reported in JSON format
44+
${rc} ${output}= Run And Return Rc And Output
45+
... ${CLAB_BIN} --runtime ${runtime} tools code-server status --format json
46+
Log ${output}
47+
Should Be Equal As Integers ${rc} 0
48+
Should Contain ${output} "${code_server_name}"
49+
Should Contain ${output} "running"
50+
Should Contain ${output} "labs_dir": "~/.clab"
51+
52+
Stop Code Server
53+
[Documentation] Test stopping the default code-server container
54+
${rc} ${output}= Run And Return Rc And Output
55+
... ${CLAB_BIN} --runtime ${runtime} tools code-server stop
56+
Log ${output}
57+
Should Be Equal As Integers ${rc} 0
58+
Should Contain ${output} Removing code-server container
59+
Should Contain ${output} name=${code_server_name}
60+
Should Contain ${output} code server container removed
61+
62+
# Verify container is removed
63+
${rc} ${output}= Run And Return Rc And Output
64+
... ${runtime} ps -a | grep ${code_server_name} || true
65+
Log ${output}
66+
Should Not Contain ${output} ${code_server_name}
67+
68+
Start Code Server With Custom Port
69+
[Documentation] Test starting code-server with a custom host port
70+
${rc} ${output}= Run And Return Rc And Output
71+
... ${CLAB_BIN} --runtime ${runtime} tools code-server start --port ${custom_port}
72+
Log ${output}
73+
Should Be Equal As Integers ${rc} 0
74+
Should Contain ${output} code-server container ${code_server_name} started successfully
75+
Should Contain ${output} code-server available at: http://0.0.0.0:${custom_port}
76+
77+
Verify Code Server Status With Custom Port
78+
[Documentation] Verify code-server status reflects the custom port value
79+
${rc} ${output}= Run And Return Rc And Output
80+
... ${CLAB_BIN} --runtime ${runtime} tools code-server status
81+
Log ${output}
82+
Should Be Equal As Integers ${rc} 0
83+
Should Contain ${output} ${code_server_name}
84+
Should Contain ${output} running
85+
Should Contain ${output} ${custom_port}
86+
87+
Stop Code Server Custom Port
88+
[Documentation] Stop the code-server container started with custom port
89+
${rc} ${output}= Run And Return Rc And Output
90+
... ${CLAB_BIN} --runtime ${runtime} tools code-server stop
91+
Log ${output}
92+
Should Be Equal As Integers ${rc} 0
93+
Should Contain ${output} Removing code-server container
94+
Should Contain ${output} name=${code_server_name}
95+
Should Contain ${output} code server container removed
96+
97+
Verify Empty Code Server List
98+
[Documentation] Verify status command reports no code-server containers running
99+
${rc} ${output}= Run And Return Rc And Output
100+
... ${CLAB_BIN} --runtime ${runtime} tools code-server status
101+
Log ${output}
102+
Should Be Equal As Integers ${rc} 0
103+
Should Contain ${output} No active code-server containers found
104+
105+
Verify Empty Code Server List JSON Format
106+
[Documentation] Verify JSON status is empty when no code-server containers exist
107+
${rc} ${output}= Run And Return Rc And Output
108+
... ${CLAB_BIN} --runtime ${runtime} tools code-server status --format json
109+
Log ${output}
110+
Should Be Equal As Integers ${rc} 0
111+
Should Be Equal ${output} []
112+
113+
*** Keywords ***
114+
Cleanup Code Server Containers
115+
[Documentation] Cleanup all code-server containers
116+
Run Keyword And Ignore Error Run ${CLAB_BIN} --runtime ${runtime} tools code-server stop --name ${code_server_name}
117+
Run Keyword And Ignore Error Run ${runtime} rm -f ${code_server_name}

0 commit comments

Comments
 (0)