Skip to content

Commit

Permalink
reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Mar 29, 2024
1 parent 57fe7db commit e101239
Showing 1 changed file with 16 additions and 96 deletions.
112 changes: 16 additions & 96 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,73 +20,6 @@ defaults:
shell: script --quiet --return --log-out /dev/null --command "bash -e {0}"

jobs:
dummy:
runs-on: ubuntu-22.04
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: "pull"
run: |
docker pull quay.io/consideratio/test:turbo
- name: "1"
if: always()
run: |
container_id=$(docker run -d -p 5901:5901 quay.io/consideratio/test:turbo vncserver -xstartup /opt/install/jupyter_remote_desktop_proxy/share/xstartup -verbose -fg -geometry 1680x1050 -SecurityTypes None -rfbport 5901)
sleep 1
timeout --preserve-status 1 nc -v localhost 5901 2>&1 | \
grep --quiet RFB && echo "Passed test" || { echo "Failed test" && TEST_OK=false; }
docker stop $container_id > /dev/null
if [ "$TEST_OK" == "false" ]; then
echo "One or more tests failed!"
exit 1
fi
- name: "2"
if: always()
run: |
container_id=$(docker run -d -p 5901:5901 quay.io/consideratio/test:turbo websockify --verbose --log-file=/tmp/websockify.log --heartbeat=30 5901 -- vncserver -xstartup /opt/install/jupyter_remote_desktop_proxy/share/xstartup -verbose -fg -geometry 1680x1050 -SecurityTypes None -rfbport 5901)
sleep 1
websocat --binary --one-message --exit-on-eof "ws://localhost:5901/" 2>&1 | \
grep --quiet RFB && echo "Passed test" || { echo "Failed test" && TEST_OK=false; }
docker stop $container_id > /dev/null
if [ "$TEST_OK" == "false" ]; then
echo "One or more tests failed!"
exit 1
fi
- name: "3"
if: always()
run: |
container_id=$(docker run -d -p 8888:8888 -e JUPYTER_TOKEN=secret quay.io/consideratio/test:turbo)
sleep 3
curl --silent --fail 'http://localhost:8888/desktop/?token=secret' | grep --quiet 'Jupyter Remote Desktop Proxy' && echo "Passed get index.html test" || { echo "Failed" && TEST_OK=false; }
curl --silent --fail 'http://localhost:8888/desktop/static/dist/viewer.js?token=secret' > /dev/null && echo "Passed get viewer.js test" || { echo "Failed" && TEST_OK=false; }
websocat --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 1 && websocat --binary --one-message --exit-on-eof 'ws://localhost:8888/desktop-websockify/?token=secret' | grep --quiet RFB && echo "Passed second websocket test" || { echo "Failed second websocket test" && TEST_OK=false; } \
}
timeout 5 docker stop $container_id > /dev/null && echo "Passed SIGTERM test" || { echo "Failed" && TEST_OK=false; }
if [ "$TEST_OK" == "false" ]; then
echo "One or more tests failed!"
exit 1
fi
container:
runs-on: ubuntu-22.04
timeout-minutes: 10
Expand All @@ -100,31 +33,36 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install test requirement (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 .
docker build --build-arg vncserver=${{ matrix.vncserver }} -t test .
- name: (inside container) websockify --help
run: |
docker run jupyter-remote-desktop-proxy websockify --help
docker run test 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"
docker run test bash -c "vncserver -help || vncserver -list > /dev/null"
- name: Test vncserver
if: always()
run: |
container_id=$(docker run -d -it -p 5901:5901 jupyter-remote-desktop-proxy vncserver -xstartup /opt/install/jupyter_remote_desktop_proxy/share/xstartup -verbose -fg -geometry 1680x1050 -SecurityTypes None -rfbport 5901)
container_id=$(docker run -d -it -p 5901:5901 test vncserver -xstartup /opt/install/jupyter_remote_desktop_proxy/share/xstartup -verbose -fg -geometry 1680x1050 -SecurityTypes None -rfbport 5901)
sleep 1
echo "::group::Testing vncserver with netcat"
timeout --preserve-status 1 nc -v localhost 5901 2>&1 | \
grep --quiet RFB && echo "Passed test" || { echo "Failed test" && TEST_OK=false; }
echo "::endgroup::"
echo "::group::vncserver logs"
docker exec $container_id bash -c 'cat ~/.vnc/*.log'
Expand All @@ -136,23 +74,14 @@ jobs:
exit 1
fi
- name: Install test requirement (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: Test websockify'ed vncserver
if: always()
run: |
container_id=$(docker run -d -it -p 5901:5901 upyter-remote-desktop-proxy websockify --verbose --log-file=/tmp/websockify.log --heartbeat=30 5901 -- vncserver -xstartup /opt/install/jupyter_remote_desktop_proxy/share/xstartup -verbose -fg -geometry 1680x1050 -SecurityTypes None -rfbport 5901)
container_id=$(docker run -d -it -p 5901:5901 test websockify --verbose --log-file=/tmp/websockify.log --heartbeat=30 5901 -- vncserver -xstartup /opt/install/jupyter_remote_desktop_proxy/share/xstartup -verbose -fg -geometry 1680x1050 -SecurityTypes None -rfbport 5901)
sleep 1
echo "::group::Testing websockify'ed vncserver with websocat"
websocat --binary --one-message --exit-on-eof "ws://localhost:5901/" 2>&1 | \
grep --quiet RFB && echo "Passed test" || { echo "Failed test" && TEST_OK=false; }
echo "::endgroup::"
echo "::group::websockify logs"
docker exec $container_id bash -c "cat /tmp/websockify.log"
Expand All @@ -171,27 +100,18 @@ jobs:
- name: Test project's proxy to websockify'ed vncserver
if: always()
run: |
container_id=$(docker run -d -it -p 8888:8888 -e JUPYTER_TOKEN=secret jupyter-remote-desktop-proxy)
container_id=$(docker run -d -it -p 8888:8888 -e JUPYTER_TOKEN=secret test)
sleep 3
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 get index.html test" || { echo "Failed" && TEST_OK=false; }
echo "::endgroup::"
curl --silent --fail 'http://localhost:8888/desktop/?token=secret' | grep --quiet 'Jupyter Remote Desktop Proxy' && echo "Passed get index.html test" || { echo "Failed get index.html test" && TEST_OK=false; }
curl --silent --fail 'http://localhost:8888/desktop/static/dist/viewer.js?token=secret' > /dev/null && echo "Passed get viewer.js test" || { echo "Failed get viewer.js test" && TEST_OK=false; }
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 get viewer.js test" || { echo "Failed" && TEST_OK=false; }
echo "::endgroup::"
echo "::group::Testing /desktop-websockify/ to return a vncserver typical response, accepting one initial test failure"
websocat --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 1 && websocat --binary --one-message --exit-on-eof 'ws://localhost:8888/desktop-websockify/?token=secret' | grep --quiet RFB && echo "Passed second websocket test" || { echo "Failed second websocket test" && TEST_OK=false; } \
}
echo "::endgroup::"
echo "::group::Testing container's ability to terminate on SIGTERM"
timeout 5 docker stop $container_id > /dev/null && echo "Passed SIGTERM test" || { echo "Failed" && TEST_OK=false; }
echo "::endgroup::"
timeout 5 docker stop $container_id > /dev/null && echo "Passed SIGTERM test" || { echo "Failed SIGTERM test" && TEST_OK=false; }
echo "::group::jupyter_server logs"
docker logs $container_id
Expand Down

0 comments on commit e101239

Please sign in to comment.