Skip to content

Commit 526ba4f

Browse files
committed
Add cgroupv2 support.
Fixes #1072. Also move our integration tests from broken gitlab to working github actions.
1 parent b3cac2c commit 526ba4f

File tree

7 files changed

+320
-389
lines changed

7 files changed

+320
-389
lines changed

.github/jobs/baseinstall.sh

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,25 @@ section_end
2424

2525
section_start "Install domserver"
2626
make configure
27-
./configure \
28-
--with-baseurl='https://localhost/domjudge/' \
29-
--with-domjudge-user=root \
30-
--enable-doc-build=no \
31-
--enable-judgehost-build=no | tee "$ARTIFACTS"/configure.txt
32-
33-
make domserver
34-
make install-domserver
27+
if [ "$version" = "all" ]; then
28+
# Note that we use http instead of https here as python requests doesn't
29+
# like our self-signed cert. We should fix this separately.
30+
./configure \
31+
--with-baseurl='http://localhost/domjudge/' \
32+
--with-domjudge-user=domjudge \
33+
--with-judgehost-chrootdir=/chroot/domjudge | tee "$ARTIFACTS"/configure.txt
34+
make build-scripts domserver judgehost docs
35+
make install-domserver install-judgehost install-docs
36+
else
37+
./configure \
38+
--with-baseurl='https://localhost/domjudge/' \
39+
--with-domjudge-user=root \
40+
--enable-doc-build=no \
41+
--enable-judgehost-build=no | tee "$ARTIFACTS"/configure.txt
42+
make domserver
43+
make install-domserver
44+
fi
45+
3546
section_end
3647

3748
section_start "SQL settings"
@@ -116,6 +127,10 @@ elif [ "$version" = "balloon" ]; then
116127
elif [ "$version" = "admin" ]; then
117128
# Add admin to admin user
118129
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 1);" domjudge
130+
elif [ "$version" = "all" ]; then
131+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 1);" domjudge
132+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 3);" domjudge
133+
mysql_root "UPDATE user SET teamid = 1 WHERE userid = 1;" domjudge
119134
fi
120135
section_end
121136

.github/workflows/integration.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Run integration tests
2+
on:
3+
push:
4+
branches-ignore:
5+
- main
6+
- '[0-9]+.[0-9]+'
7+
- gh-readonly-queue/main/*
8+
- gh-readonly-queue/main/[0-9]+.[0-9]+
9+
pull_request:
10+
branches:
11+
- main
12+
- '[0-9]+.[0-9]+'
13+
14+
jobs:
15+
integration:
16+
runs-on: ubuntu-24.04
17+
container:
18+
image: domjudge/gitlabci:24.04
19+
options: --privileged --cgroupns=host --init
20+
services:
21+
sqlserver:
22+
image: mariadb
23+
ports:
24+
- 3306:3306
25+
env:
26+
MYSQL_ROOT_PASSWORD: root
27+
MYSQL_USER: domjudge
28+
MYSQL_PASSWORD: domjudge
29+
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: info
33+
run: cat /proc/cmdline && echo && cat /proc/mounts && echo && ls -al /sys/fs/cgroup && echo && uname -a && echo && stat -fc %T /sys/fs/cgroup && echo && cat /proc/self/cgroup && cat /proc/cpuinfo
34+
- name: pstree
35+
run: pstree -p
36+
- name: Install DOMjudge
37+
run: .github/jobs/baseinstall.sh all
38+
- name: Set up chroot
39+
run: sudo misc-tools/dj_make_chroot -a amd64
40+
- name: Check nginx
41+
run: curl -v https://localhost/domjudge/
42+
- name: Testing submit client
43+
working-directory: submit
44+
run: make check-full
45+
- name: Configure judgehost
46+
run: sudo cp /opt/domjudge/judgehost/etc/sudoers-domjudge /etc/sudoers.d/ && sudo chmod 400 /etc/sudoers.d/sudoers-domjudge && cat /opt/domjudge/judgehost/etc/sudoers-domjudge
47+
- name: Create user
48+
run: sudo userdel -f -r domjudge-run-0 ; sudo useradd -d /nonexistent -g nogroup -s /bin/false -u 2222 domjudge-run-0
49+
- name: Start judging
50+
run: sudo -u domjudge sh -c 'cd /opt/domjudge/judgehost/ && nohup bin/judgedaemon -n 0 &'
51+
- name: Import Kattis example problems
52+
run: |
53+
cd /tmp
54+
git clone --depth=1 https://github.com/Kattis/problemtools.git
55+
cd problemtools/examples
56+
mv hello hello_kattis
57+
# Remove 2 submissions that will not pass validation. The first is because it is
58+
# a Python 2 submission. The latter has a judgement type we do not understand.
59+
rm different/submissions/accepted/different_py2.py different/submissions/slow_accepted/different_slow.py
60+
for i in hello_kattis different guess; do
61+
(
62+
cd "$i"
63+
zip -r "../${i}.zip" -- *
64+
)
65+
curl --fail -X POST -n -N -F zip=@${i}.zip http://localhost/domjudge/api/contests/demo/problems
66+
done
67+
- name: Monitor judgehost log and stop once all submissions are judged
68+
run: |
69+
tail -f /opt/domjudge/judgehost/log/judge*-0.log | while read line; do
70+
echo "$line"
71+
grep "No submissions in queue" /opt/domjudge/judgehost/log/judge*-0.log && break
72+
done
73+
- name: dump the db
74+
run: mysqldump -uroot -proot domjudge > /tmp/db.sql
75+
- name: Upload artifact for debugging
76+
uses: actions/upload-artifact@v3
77+
with:
78+
name: DB-dump
79+
path: /tmp/db.sql
80+
- name: Verifying submissions
81+
shell: bash
82+
run: |
83+
set -x
84+
export CURLOPTS="--fail -sq -m 30 -b /tmp/cookiejar"
85+
# Make an initial request which will get us a session id, and grab the csrf token from it
86+
CSRFTOKEN=$(curl $CURLOPTS -c /tmp/cookiejar "http://localhost/domjudge/login" | sed -n 's/.*_csrf_token.*value="\(.*\)".*/\1/p')
87+
# Make a second request with our session + csrf token to actually log in
88+
curl $CURLOPTS -c /tmp/cookiejar -F "_csrf_token=$CSRFTOKEN" -F "_username=admin" -F "_password=password" "http://localhost/domjudge/login"
89+
# Send a general clarification to later test if we see the event.
90+
curl $CURLOPTS -F "sendto=" -F "problem=1-" -F "bodytext=Testing" -F "submit=Send" \
91+
"http://localhost/domjudge/jury/clarifications/send" -o /dev/null
92+
curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" -o /dev/null
93+
NUMNOTVERIFIED=$(curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier" | grep "submissions checked" | sed -r 's/^.* ([0-9]+) submissions checked.*$/\1/')
94+
NUMVERIFIED=$( curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier" | grep "submissions not checked" | sed -r 's/^.* ([0-9]+) submissions not checked.*$/\1/')
95+
NUMNOMAGIC=$( curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier" | grep "without magic string" | sed -r 's/^.* ([0-9]+) without magic string.*$/\1/')
96+
NUMSUBS=$(curl $CURLOPTS http://localhost/domjudge/api/contests/demo/submissions | python3 -mjson.tool | grep -c '"id":')
97+
# We expect
98+
# - two submissions with ambiguous outcome,
99+
# - one submissions submitted through the submit client, and thus the magic string ignored,
100+
# - and all submissions to be judged.
101+
if [ $NUMNOTVERIFIED -ne 2 ] || [ $NUMNOMAGIC -ne 1 ] || [ $NUMSUBS -gt $((NUMVERIFIED+NUMNOTVERIFIED)) ]; then
102+
echo "verified subs: $NUMVERIFIED, unverified subs: $NUMNOTVERIFIED, total subs: $NUMSUBS"
103+
echo "(expected 2 submissions to be unverified, but all to be processed)"
104+
echo "Of these $NUMNOMAGIC do not have the EXPECTED_RESULTS string (should be 1)."
105+
curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" | w3m -dump -T text/html
106+
exit 1
107+
fi
108+
- name: Finalize contest so that awards appear in the feed
109+
shell: bash
110+
run: |
111+
set -x
112+
export CURLOPTS="--fail -m 30 -b $COOKIEJAR"
113+
curl $CURLOPTS http://localhost/domjudge/jury/contests/1/freeze/doNow || true
114+
curl $CURLOPTS http://localhost/domjudge/jury/contests/1/end/doNow || true
115+
curl $CURLOPTS -X POST -d 'finalize_contest[b]=0&finalize_contest[finalizecomment]=gitlab&finalize_contest[finalize]=' http://localhost/domjudge/jury/contests/1/finalize
116+
- name: Verify no errors in prod.log
117+
shell: bash
118+
run: |
119+
if cat /opt/domjudge/domserver/webapp/var/log/prod.log | egrep '(CRITICAL|ERROR):'; then
120+
exit 1
121+
fi
122+
- name: Download and perform API check
123+
shell: bash
124+
run: |
125+
cd $HOME
126+
curl -o yajsv https://github.com/neilpa/yajsv/releases/download/v1.4.1/yajsv.linux.amd64
127+
chmod a+x yajsv
128+
echo -e "\033[0m"
129+
git clone https://github.com/icpc/ccs-specs.git
130+
export CCS_SPECS_PINNED_SHA1='a68aff54c4e60fc2bff2fc5c36c119bffa4d30f1'
131+
( cd ccs-specs && git reset --hard $CCS_SPECS_PINNED_SHA1 )
132+
export CHECK_API="${HOME}/ccs-specs/check-api.sh -j ${HOME}/yajsv"
133+
$CHECK_API -n -C -e -a 'strict=1' http://admin:password@localhost/domjudge/api

.github/workflows/runpipe.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run runpipe tests
1+
name: Run runpipe and runguard tests
22
on:
33
push:
44
branches-ignore:
@@ -13,11 +13,14 @@ on:
1313

1414
jobs:
1515
runpipe:
16-
runs-on: ubuntu-latest
16+
runs-on: ubuntu-24.04
1717
container:
1818
image: domjudge/gitlabci:24.04
19+
options: --privileged --cgroupns=host --init
1920
steps:
2021
- uses: actions/checkout@v4
22+
- name: info
23+
run: cat /proc/cmdline && echo && cat /proc/mounts && echo && ls -al /sys/fs/cgroup && echo && uname -a && echo && stat -fc %T /sys/fs/cgroup && echo && cat /proc/self/cgroup
2124
- name: Create the configure file
2225
run: make configure
2326
- name: Do the default configure
@@ -27,4 +30,14 @@ jobs:
2730
- name: Run the actual runpipe tests
2831
working-directory: judge/runpipe_test
2932
run: make test
33+
- name: Add user/group
34+
run: sudo addgroup domjudge-run-0 && sudo usermod -g domjudge-run-0 domjudge-run-0
35+
- name: Create dir
36+
run: mkdir -p /opt/domjudge/judgehost/tmp/
37+
- name: Run the actual runguard tests
38+
working-directory: judge/runguard_test
39+
env:
40+
judgehost_tmpdir: /tmp
41+
judgehost_judgedir: /tmp
42+
run: make test
3043

.gitlab-ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
include:
22
- '/gitlab/ci/unit.yml'
3-
- '/gitlab/ci/integration.yml'
43
- '/gitlab/ci/template.yml'
54
- '/gitlab/ci/misc.yml'
65

76
stages:
87
- test
9-
- integration
108
- chroot_checks
119
- unit
1210
- style

gitlab/ci/integration.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)