@@ -81,11 +81,25 @@ mount
8181mount -o remount,exec,dev /builds
8282section_end mount
8383
84+ section_start check_cgroup_v1 " Checking for cgroup v1 availability"
85+ grep cgroup$ /proc/filesystems
86+ if [ $? -eq 0 ]; then
87+ cgroupv1=1
88+ else
89+ echo " Skipping tests that rely on cgroup v1"
90+ cgroupv1=0
91+ fi
92+ section_end check_cgroup_v1
93+
8494section_start judgehost " Configure judgehost"
8595cd /opt/domjudge/judgehost/
8696sudo cp /opt/domjudge/judgehost/etc/sudoers-domjudge /etc/sudoers.d/
8797sudo chmod 400 /etc/sudoers.d/sudoers-domjudge
88- sudo bin/create_cgroups
98+ if [ $cgroupv1 -ne 0 ]; then
99+ # We allow this to go wrong as some gitlab runners do not have the
100+ # swapaccount kernel option set.
101+ sudo bin/create_cgroups || cgroupv1=0
102+ fi
89103
90104if [ ! -d ${DIR} /chroot/domjudge/ ]; then
91105 cd ${DIR} /misc-tools
@@ -128,8 +142,10 @@ set -e
128142if [ $PIN_JUDGEDAEMON -eq 1 ]; then
129143 PINNING=" -n 0"
130144fi
131- sudo -u domjudge bin/judgedaemon $PINNING | & tee /tmp/judgedaemon.log &
132- sleep 5
145+ if [ $cgroupv1 -ne 0 ]; then
146+ sudo -u domjudge bin/judgedaemon $PINNING | & tee /tmp/judgedaemon.log &
147+ sleep 5
148+ fi
133149
134150section_end more_setup
135151
@@ -154,9 +170,7 @@ for i in hello_kattis different guess; do
154170done
155171section_end submitting
156172
157- section_start judging " Waiting until all submissions are judged"
158- # wait for and check results
159- NUMSUBS=$( curl --fail http://admin:$ADMINPASS @localhost/domjudge/api/contests/1/submissions | python3 -mjson.tool | grep -c ' "id":' )
173+ section_start curlcookie " Preparing cookie jar for curl"
160174export COOKIEJAR
161175COOKIEJAR=$( mktemp --tmpdir)
162176export CURLOPTS=" --fail -sq -m 30 -b $COOKIEJAR "
@@ -170,56 +184,64 @@ curl $CURLOPTS -c $COOKIEJAR -F "_csrf_token=$CSRFTOKEN" -F "_username=admin" -F
170184curl $CURLOPTS -F " sendto=" -F " problem=1-" -F " bodytext=Testing" -F " submit=Send" \
171185 " http://localhost/domjudge/jury/clarifications/send" -o /dev/null
172186
173- # Don't spam the log.
174- set +x
187+ section_end curlcookie
175188
176- while /bin/true; do
177- sleep 30s
178- curl $CURLOPTS " http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" -o /dev/null
189+ if [ $cgroupv1 -ne 0 ]; then
190+ section_start judging " Waiting until all submissions are judged"
191+ # wait for and check results
192+ NUMSUBS=$( curl --fail http://admin:$ADMINPASS @localhost/domjudge/api/contests/1/submissions | python3 -mjson.tool | grep -c ' "id":' )
179193
180- # Check if we are done, i.e. everything is judged or something got disabled by internal error...
181- if tail /tmp/judgedaemon.log | grep -q " No submissions in queue" ; then
182- break
183- fi
184- # ... or something has crashed.
185- if ! pgrep -f judgedaemon; then
186- break
187- fi
188- done
194+ # Don't spam the log.
195+ set +x
189196
190- NUMNOTVERIFIED=$( curl $CURLOPTS " http://localhost/domjudge/jury/judging-verifier" | grep " submissions checked" | sed -r ' s/^.* ([0-9]+) submissions checked.*$/\1/' )
191- NUMVERIFIED=$( curl $CURLOPTS " http://localhost/domjudge/jury/judging-verifier" | grep " submissions not checked" | sed -r ' s/^.* ([0-9]+) submissions not checked.*$/\1/' )
192- NUMNOMAGIC=$( curl $CURLOPTS " http://localhost/domjudge/jury/judging-verifier" | grep " without magic string" | sed -r ' s/^.* ([0-9]+) without magic string.*$/\1/' )
193- section_end judging
194-
195- # We expect
196- # - two submissions with ambiguous outcome,
197- # - no submissions without magic string,
198- # - and all submissions to be judged.
199- if [ $NUMNOTVERIFIED -ne 2 ] || [ $NUMNOMAGIC -ne 0 ] || [ $NUMSUBS -gt $(( NUMVERIFIED+ NUMNOTVERIFIED)) ]; then
200- section_start error " Short error description"
201- # We error out below anyway, so no need to fail earlier than that.
202- set +e
203- echo " verified subs: $NUMVERIFIED , unverified subs: $NUMNOTVERIFIED , total subs: $NUMSUBS "
204- echo " (expected 2 submissions to be unverified, but all to be processed)"
205- echo " Of these $NUMNOMAGIC do not have the EXPECTED_RESULTS string (should be 0)."
206- curl $CURLOPTS " http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" | w3m -dump -T text/html
207- section_end error
208-
209- section_start logfiles " All the more or less useful logfiles"
210- for i in /opt/domjudge/judgehost/judgings/* /* /* /* /* /compile.out; do
211- echo $i ;
212- head -n 100 $i ;
213- dir=$( dirname $i )
214- if [ -r $dir /testcase001/system.out ]; then
215- head $dir /testcase001/system.out
216- head $dir /testcase001/runguard.err
217- head $dir /testcase001/program.err
218- head $dir /testcase001/program.meta
197+ while /bin/true; do
198+ sleep 30s
199+ curl $CURLOPTS " http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" -o /dev/null
200+
201+ # Check if we are done, i.e. everything is judged or something got disabled by internal error...
202+ if tail /tmp/judgedaemon.log | grep -q " No submissions in queue" ; then
203+ break
204+ fi
205+ # ... or something has crashed.
206+ if ! pgrep -f judgedaemon; then
207+ break
219208 fi
220- echo ;
221209 done
222- exit 1;
210+
211+ NUMNOTVERIFIED=$( curl $CURLOPTS " http://localhost/domjudge/jury/judging-verifier" | grep " submissions checked" | sed -r ' s/^.* ([0-9]+) submissions checked.*$/\1/' )
212+ NUMVERIFIED=$( curl $CURLOPTS " http://localhost/domjudge/jury/judging-verifier" | grep " submissions not checked" | sed -r ' s/^.* ([0-9]+) submissions not checked.*$/\1/' )
213+ NUMNOMAGIC=$( curl $CURLOPTS " http://localhost/domjudge/jury/judging-verifier" | grep " without magic string" | sed -r ' s/^.* ([0-9]+) without magic string.*$/\1/' )
214+ section_end judging
215+
216+ # We expect
217+ # - two submissions with ambiguous outcome,
218+ # - no submissions without magic string,
219+ # - and all submissions to be judged.
220+ if [ $NUMNOTVERIFIED -ne 2 ] || [ $NUMNOMAGIC -ne 0 ] || [ $NUMSUBS -gt $(( NUMVERIFIED+ NUMNOTVERIFIED)) ]; then
221+ section_start error " Short error description"
222+ # We error out below anyway, so no need to fail earlier than that.
223+ set +e
224+ echo " verified subs: $NUMVERIFIED , unverified subs: $NUMNOTVERIFIED , total subs: $NUMSUBS "
225+ echo " (expected 2 submissions to be unverified, but all to be processed)"
226+ echo " Of these $NUMNOMAGIC do not have the EXPECTED_RESULTS string (should be 0)."
227+ curl $CURLOPTS " http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" | w3m -dump -T text/html
228+ section_end error
229+
230+ section_start logfiles " All the more or less useful logfiles"
231+ for i in /opt/domjudge/judgehost/judgings/* /* /* /* /* /compile.out; do
232+ echo $i ;
233+ head -n 100 $i ;
234+ dir=$( dirname $i )
235+ if [ -r $dir /testcase001/system.out ]; then
236+ head $dir /testcase001/system.out
237+ head $dir /testcase001/runguard.err
238+ head $dir /testcase001/program.err
239+ head $dir /testcase001/program.meta
240+ fi
241+ echo ;
242+ done
243+ exit 1;
244+ fi
223245fi
224246
225247section_start api_check " Performing API checks"
@@ -239,7 +261,13 @@ if cat /opt/domjudge/domserver/webapp/var/log/prod.log | egrep '(CRITICAL|ERROR)
239261fi
240262
241263# Check the Contest API:
242- $CHECK_API -n -C -e -a ' strict=1' http://admin:$ADMINPASS @localhost/domjudge/api
264+ if [ $cgroupv1 -ne 0 ]; then
265+ $CHECK_API -n -C -e -a ' strict=1' http://admin:$ADMINPASS @localhost/domjudge/api
266+ else
267+ # With cgroup v1 not being available we don't judge, so we cannot do
268+ # consistency checks, so running the above command without -C.
269+ $CHECK_API -n -e -a ' strict=1' http://admin:$ADMINPASS @localhost/domjudge/api
270+ fi
243271section_end api_check | & tee " $GITLABARTIFACTS /check_api.log"
244272
245273section_start validate_feed " Validate the eventfeed against API (ignoring failures)"
0 commit comments