Skip to content

Commit be4ba0c

Browse files
authored
Make it easier to run the StressTest script. (#1332)
1 parent 1842ff1 commit be4ba0c

File tree

5 files changed

+69
-7
lines changed

5 files changed

+69
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ log/
1515
.vagrant/
1616
codecov/
1717
.dev/
18+
test_logs/

_cms-stresstest-internal.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
dropdb --host=testdb --username=postgres cmsdbfortesting
4+
createdb --host=testdb --username=postgres cmsdbfortesting
5+
cmsInitDB
6+
7+
git clone https://github.com/cms-dev/con_test.git
8+
cd con_test
9+
10+
# These don't play well with the StressTest script
11+
for i in communication communicationtwoways outputonly outputonlycomparator; do
12+
sed -i "/$i/d" contest.yaml
13+
done
14+
15+
# Take the solution.c, solution.py, etc, files from each task, and rename them
16+
# to taskname.c, taskname.py, etc. This is needed because the StressTest script
17+
# needs the solution name to match the submission format (task name).
18+
mkdir -p stress_sols
19+
for i in batch batch_comparator batch_file batchgrader batchwithoutgen; do
20+
for j in $(ls -d $i/sol/*); do
21+
ext=${j##*.}
22+
cp $j stress_sols/${i%/}.$ext
23+
done
24+
done
25+
26+
cmsImportUser --all
27+
cmsImportContest --import-tasks .
28+
29+
cd ..
30+
31+
# Start ResourceService
32+
cmsResourceService -a 1 &
33+
sleep 5
34+
35+
python3 cmstestsuite/StressTest.py --contest-id 1 --submissions-path stress_sols/

cms-stresstest.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
set -x
3+
4+
GIT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
5+
6+
docker compose -p $GIT_BRANCH_NAME -f docker-compose.test.yml run --build --rm stresstestcms

docker-compose.test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,13 @@ services:
1919
privileged: true
2020
cgroup: host
2121
command: wait-for-it testdb:5432 -- ./_cms-test-internal.sh
22+
23+
stresstestcms:
24+
build: .
25+
depends_on:
26+
- "testdb"
27+
environment:
28+
CMS_CONFIG: /usr/local/etc/cms-testdb.conf
29+
privileged: true
30+
cgroup: host
31+
command: wait-for-it testdb:5432 -- ./_cms-stresstest-internal.sh

docs/Docker image.rst

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,25 @@ dependencies. We also provide:
77

88
* :gh_blob:`cms-test.sh`: This file uses :gh_blob:`docker-compose.test.yml` to
99
spawn a volatile database (not persisted on disk) as well as a CMS instance
10-
that automatically runs all tests.
10+
that automatically runs all unit tests and functional tests.
11+
12+
* :gh_blob:`cms-stresstest.sh`: Similar to `cms_test.sh` but runs the stress
13+
tests instead of the unit tests. The stress test consists of: creating a
14+
database, populating it with some sample tasks, and then simulating some
15+
users logging in via ContestWebServer and repeatedly performing actions
16+
such as download task statements and submitting solutions.
1117

1218
* :gh_blob:`cms-dev.sh`: This file uses :gh_blob:`docker-compose.dev.yml` to
13-
spawn a database (persisted in the local ``.dev/postgres-data`` folder
14-
within the repository) as well as a CMS instance that only runs `bash`,
15-
leaving you with a shell from where you can start cms services and servers.
16-
The DB port and CMS server ports are also automatically forwarded on the
17-
host machine (respectively to ``15432`` for the database, and ``8888-8890``
18-
for CMS).
19+
spawn a database (**persisted** in the local ``.dev/postgres-data`` folder
20+
within the repository) as well as a CMS container that only runs `bash`,
21+
leaving you with a shell from where you can start cms services. Changes
22+
made in the repository are also reflected directly inside the container
23+
(the source code is mounted as a docker volume). The DB port and CMS server
24+
ports are also automatically forwarded on the host machine (respectively to
25+
``15432`` for the database, and ``8888-8890`` for CMS), which allows you to
26+
access the CMS web server from your host machine, but that also means you
27+
can only use `./cms-dev.sh` for one git branch at a time, as the ports are
28+
already in use.
1929

2030
Make sure that you have a recent version of Docker installed, as well as Docker
2131
Compose.

0 commit comments

Comments
 (0)