Skip to content

Commit 5cb0d2d

Browse files
[desktop-lite] - add tests for running xtigervnc and novnc (#1090)
* [desktop-lite] - add tests for running xtigervnc and novnc * change for error while running test scenario * changed test * Update devcontainer-feature.json --------- Co-authored-by: Samruddhi Khandale <[email protected]>
1 parent 28ca71a commit 5cb0d2d

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

src/desktop-lite/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "desktop-lite",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"name": "Light-weight Desktop",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/desktop-lite",
66
"description": "Adds a lightweight Fluxbox based desktop to the container that can be accessed using a VNC viewer or the web. GUI-based commands executed from the built-in VS code terminal will open on the desktop automatically.",

src/desktop-lite/install.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,12 @@ else
394394
fi
395395
396396
# Run whatever was passed in
397-
log "Executing \"\$@\"."
398-
exec "$@"
397+
if [ -n "$1" ]; then
398+
log "Executing \"\$@\"."
399+
exec "$@"
400+
else
401+
log "No command provided to execute."
402+
fi
399403
log "** SCRIPT EXIT **"
400404
EOF
401405

test/desktop-lite/scenarios.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"test_xtigervnc_novnc_started": {
3+
"image": "ubuntu:noble",
4+
"features": {
5+
"desktop-lite": {}
6+
}
7+
}
8+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
# Check if xtigervnc & noVnc processes are running after successful installation and initialization
9+
check_process_running() {
10+
port=$1
11+
# Get process id of process running on specific port
12+
PID=$(lsof -i :$port | awk 'NR==2 {print $2}')
13+
if [ -n "$PID" ]; then
14+
CMD=$(ps -p $PID -o cmd --no-headers)
15+
GREEN='\033[0;32m'; NC='\033[0m'; RED='\033[0;31m'; YELLOW='\033[0;33m';
16+
echo -e "${GREEN}Command running on port $port: ${YELLOW}$CMD${NC}"
17+
else
18+
echo -e "${RED}No process found listening on port $port.${NC}"
19+
fi
20+
}
21+
22+
check "Whether xtigervnc is Running" check_process_running 5901
23+
sleep 1
24+
check "Whether no_vnc is Running" check_process_running 6080
25+
26+
check "desktop-init-exists" bash -c "ls /usr/local/share/desktop-init.sh"
27+
check "log-exists" bash -c "ls /tmp/container-init.log"
28+
check "log file contents" bash -c "cat /tmp/container-init.log"
29+
30+
# Report result
31+
reportResults

0 commit comments

Comments
 (0)