-
Notifications
You must be signed in to change notification settings - Fork 107
218 lines (176 loc) · 9.4 KB
/
test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# 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:
defaults:
run:
# GitHub Actions run without a TTY device. This is a workaround to have one,
# as required for our tests, based on
# https://github.com/actions/runner/issues/241#issuecomment-842566950.
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
strategy:
fail-fast: false
matrix:
include:
- vncserver: tigervnc
- vncserver: turbovnc
steps:
- uses: actions/checkout@v4
- 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
if: always()
run: |
container_id=$(docker run -d -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)
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'
echo "::endgroup::"
docker stop $container_id > /dev/null
if [ "$TEST_OK" == "false" ]; then
echo "One or more tests failed!"
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 -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)
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"
echo "::endgroup::"
echo "::group::vncserver logs"
docker exec $container_id bash -c 'cat ~/.vnc/*.log'
echo "::endgroup::"
docker stop $container_id > /dev/null
if [ "$TEST_OK" == "false" ]; then
echo "One or more tests failed!"
exit 1
fi
- name: Test project's proxy to websockify'ed vncserver
if: always()
run: |
container_id=$(docker run -d -p 8888:8888 -e JUPYTER_TOKEN=secret jupyter-remote-desktop-proxy)
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::"
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::"
echo "::group::jupyter_server logs"
docker logs $container_id
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::"
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