diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2627b8a5..884de91a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -36,15 +36,54 @@ jobs: - name: "1" if: always() run: | - bash +o pipefail 1.sh + 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: | - bash +o pipefail 2.sh + 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: | - bash +o pipefail 3.sh + 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 + diff --git a/1.sh b/1.sh index 419e0244..d72e6091 100644 --- a/1.sh +++ b/1.sh @@ -2,7 +2,7 @@ container_id=$(docker run -d -p 5901:5901 quay.io/consideratio/test:turbo vncser sleep 1 timeout --preserve-status 1 nc -v localhost 5901 2>&1 | \ - grep --quiet RFB && echo "Passed test" || { echo "Failed test" && TEST_OK=false; } + grep --quiet RFB && echo "Passed test" || { echo "Failed test" && TEST_OK=false; } docker stop $container_id > /dev/null if [ "$TEST_OK" == "false" ]; then diff --git a/2.sh b/2.sh index 0e9f7937..3f6da4ed 100644 --- a/2.sh +++ b/2.sh @@ -2,7 +2,7 @@ container_id=$(docker run -d -p 5901:5901 quay.io/consideratio/test:turbo websoc 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; } + grep --quiet RFB && echo "Passed test" || { echo "Failed test" && TEST_OK=false; } docker stop $container_id > /dev/null if [ "$TEST_OK" == "false" ]; then diff --git a/3.sh b/3.sh index 9a9def5c..d2b56b1c 100644 --- a/3.sh +++ b/3.sh @@ -5,9 +5,9 @@ curl --silent --fail 'http://localhost:8888/desktop/?token=secret' | grep --quie 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; } \ - } + 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; }