Fix image tests: vncserver, websockify, jupyter-remote-desktop-proxy #148
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a GitHub workflow defining a set of jobs with a set of steps. | |
# ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions | |
# | |
name: Test | |
on: | |
pull_request: | |
push: | |
branches-ignore: | |
- "dependabot/**" | |
- "pre-commit-ci-update-config" | |
tags: ["**"] | |
workflow_dispatch: | |
jobs: | |
container: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 10 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- vncserver: tigervnc | |
- vncserver: turbovnc | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install test requirements (websocat) | |
run: | | |
wget -q https://github.com/vi/websocat/releases/download/v1.12.0/websocat.x86_64-unknown-linux-musl \ | |
-O /usr/local/bin/websocat | |
chmod +x /usr/local/bin/websocat | |
websocat --help=long | |
- name: Build image | |
run: | | |
docker build --build-arg vncserver=${{ matrix.vncserver }} -t jupyter-remote-desktop-proxy . | |
- name: (inside container) websockify --help | |
run: | | |
docker run jupyter-remote-desktop-proxy websockify --help | |
- name: (inside container) vncserver -help | |
run: | | |
# -help flag is not available for TurboVNC, but it emits the -help | |
# equivalent information anyhow if passed -help, but also errors. Due | |
# to this, we fallback to use the errorcode of vncsrever -list. | |
docker run jupyter-remote-desktop-proxy bash -c "vncserver -help || vncserver -list > /dev/null" | |
- name: Test vncserver with netcat | |
run: | | |
container_id=$(docker run -d -p 5901:5901 --security-opt seccomp=unconfined jupyter-remote-desktop-proxy vncserver -xstartup /opt/install/jupyter_remote_desktop_proxy/share/xstartup -verbose -localhost -fg -geometry 1680x1050 -SecurityTypes None) | |
sleep 3 | |
echo "::group::Testing vncserver with netcat" | |
nc -w 1 localhost 5901 2>&1 | tee -a output.txt | |
echo "::endgroup::" | |
echo "::group::vncserver logs" | |
docker exec $container_id bash -c "cat ~/.vnc/*.log" | |
echo "::endgroup::" | |
docker stop $container_id > /dev/null | |
cat output.txt | grep --quiet RFB | |
- name: Test websockify'ed vncserver with websocat | |
run: | | |
container_id=$(docker run -d -p 5901:5901 --security-opt seccomp=unconfined jupyter-remote-desktop-proxy websockify --verbose --log-file=/tmp/websockify.log --heartbeat=30 5901 -- vncserver -xstartup /opt/install/jupyter_remote_desktop_proxy/share/xstartup -verbose -localhost -fg -geometry 1680x1050 -SecurityTypes None) | |
sleep 3 | |
echo "::group::Testing websockify'ed vncserver with websocat" | |
websocat -v --no-async-stdio --binary --one-message --exit-on-eof 'ws://localhost:5901/' 2>&1 | tee -a output.txt | |
echo "::endgroup::" | |
echo "::group::websockify logs" | |
docker exec $container_id bash -c "cat /tmp/websockify.log" | |
echo "::endgroup::" | |
echo "::group::vncserver logs" | |
docker exec $container_id bash -c "cat ~/.vnc/*.log" | |
echo "::endgroup::" | |
docker stop $container_id > /dev/null | |
cat output.txt | grep --quiet RFB | |
- name: Run basic tests and print logs | |
run: | | |
container_id=$(docker run -d -p 8888:8888 --security-opt seccomp=unconfined -e JUPYTER_TOKEN=secret jupyter-remote-desktop-proxy) | |
sleep 3 | |
TEST_OK=true | |
echo "::group::Testing /desktop/ to return rendered index.html template" | |
curl --silent --fail 'http://localhost:8888/desktop/?token=secret' | grep --quiet 'Jupyter Remote Desktop Proxy' && echo "Passed" || { echo "Failed" && TEST_OK=false; } | |
echo "::endgroup::" | |
echo "::group::Testing /desktop/ to provide pre-built viewer.js" | |
curl --silent --fail 'http://localhost:8888/desktop/static/dist/viewer.js?token=secret' > /dev/null && echo "Passed" || { echo "Failed" && TEST_OK=false; } | |
echo "::endgroup::" | |
echo "::group::Testing /desktop-websockify/ to return a vncserver typical response, accepting one initial test failure" | |
websocat --no-async-stdio --binary --one-message --exit-on-eof 'ws://localhost:8888/desktop-websockify/?token=secret' | grep --quiet RFB && echo "Passed initial websocket test" || { \ | |
echo "Failed initial websocket test" && sleep 3 && websocat -vv --no-async-stdio --binary --one-message --exit-on-eof 'ws://localhost:8888/desktop-websockify/?token=secret' | tee /dev/tty | grep --quiet RFB && echo "Pass second websocket test" || { \ | |
echo "Failed second websocket test" && sleep 3 && websocat --no-async-stdio --binary --one-message --exit-on-eof 'ws://localhost:8888/desktop-websockify/?token=secret' | grep --quiet RFB && echo "Pass second websocket test" || { echo "Failed third websocket test" && TEST_OK=false; } \ | |
} \ | |
} | |
echo "::endgroup::" | |
echo "::group::Installing websocat in container" | |
docker exec --user root $container_id bash -c ' | |
wget -q https://github.com/vi/websocat/releases/download/v1.12.0/websocat.x86_64-unknown-linux-musl \ | |
-O /usr/local/bin/websocat | |
chmod +x /usr/local/bin/websocat | |
websocat --help=long | |
' | |
echo "::endgroup::" | |
echo "::group::Testing /desktop-websockify/ to return a vncserver typical response from within the container" | |
docker exec $container_id bash -c ' | |
websocat -vv --no-async-stdio --binary --one-message --exit-on-eof 'ws://localhost:5901' | |
' | |
echo "::endgroup::" | |
echo "::group::jupyter_server logs" | |
docker logs $container_id | |
echo "::endgroup::" | |
echo "::group::vncserver logs" | |
docker exec $container_id bash -c "cat ~/.vnc/*.log" | |
echo "::endgroup::" | |
echo "::group::websockify logs" | |
docker exec $container_id bash -c "cat /tmp/websockify-*.log" | |
echo "::endgroup::" | |
echo "::group::Testing container's ability to terminate via SIGTERM" | |
timeout 5 docker stop $container_id > /dev/null && echo "Passed" || { echo "Failed" && TEST_OK=false; } | |
echo "::endgroup::" | |
if [ "$TEST_OK" == "false" ]; then | |
echo "One or more tests failed!" | |
exit 1 | |
fi | |
# TODO: Check VNC desktop works, e.g. by comparing Playwright screenshots | |
# https://playwright.dev/docs/test-snapshots |