Skip to content

Commit

Permalink
[desktop-lite] - add tests for running xtigervnc and novnc (#1090)
Browse files Browse the repository at this point in the history
* [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 <samruddhikhandale@github.com>
  • Loading branch information
gauravsaini04 and samruddhikhandale authored Aug 15, 2024
1 parent 28ca71a commit 5cb0d2d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/desktop-lite/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "desktop-lite",
"version": "1.2.3",
"version": "1.2.4",
"name": "Light-weight Desktop",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/desktop-lite",
"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.",
Expand Down
8 changes: 6 additions & 2 deletions src/desktop-lite/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,12 @@ else
fi
# Run whatever was passed in
log "Executing \"\$@\"."
exec "$@"
if [ -n "$1" ]; then
log "Executing \"\$@\"."
exec "$@"
else
log "No command provided to execute."
fi
log "** SCRIPT EXIT **"
EOF

Expand Down
8 changes: 8 additions & 0 deletions test/desktop-lite/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"test_xtigervnc_novnc_started": {
"image": "ubuntu:noble",
"features": {
"desktop-lite": {}
}
}
}
31 changes: 31 additions & 0 deletions test/desktop-lite/test_xtigervnc_novnc_started.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

# Check if xtigervnc & noVnc processes are running after successful installation and initialization
check_process_running() {
port=$1
# Get process id of process running on specific port
PID=$(lsof -i :$port | awk 'NR==2 {print $2}')
if [ -n "$PID" ]; then
CMD=$(ps -p $PID -o cmd --no-headers)
GREEN='\033[0;32m'; NC='\033[0m'; RED='\033[0;31m'; YELLOW='\033[0;33m';
echo -e "${GREEN}Command running on port $port: ${YELLOW}$CMD${NC}"
else
echo -e "${RED}No process found listening on port $port.${NC}"
fi
}

check "Whether xtigervnc is Running" check_process_running 5901
sleep 1
check "Whether no_vnc is Running" check_process_running 6080

check "desktop-init-exists" bash -c "ls /usr/local/share/desktop-init.sh"
check "log-exists" bash -c "ls /tmp/container-init.log"
check "log file contents" bash -c "cat /tmp/container-init.log"

# Report result
reportResults

0 comments on commit 5cb0d2d

Please sign in to comment.