Skip to content
Snippets Groups Projects
Commit 0f333cae authored by Martin Mareš's avatar Martin Mareš
Browse files

Merge remote-tracking branch 'upstream/master'

parents 31e935e3 f0d969b4
No related branches found
No related tags found
No related merge requests found
......@@ -19,11 +19,11 @@ jobs:
- name: Build docker image
run: |
docker-compose -f docker-compose.test.yml build cms_test
docker compose -p cms -f docker-compose.test.yml build testcms
- name: Run tests
run: |
docker-compose -f docker-compose.test.yml run --rm cms_test
docker compose -p cms -f docker-compose.test.yml run --rm testcms
- uses: codecov/codecov-action@v3
with:
......
{
"recommendations": [
// Auto-format Python code with Ruff linter
"charliermarsh.ruff",
// To apply settings from .editorconfig file
"editorconfig.editorconfig",
// Python intellisense support
"ms-python.python",
"ms-python.vscode-pylance"
// Python language server and type checker
"ms-python.vscode-pylance",
]
}
{
"python.analysis.typeCheckingMode": "basic"
"python.analysis.typeCheckingMode": "basic",
"files.insertFinalNewline": true,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modifications",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features",
},
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features",
},
"[css]": {
"editor.defaultFormatter": "vscode.css-language-features",
},
"[html]": {
// Doesn't work properly with template files, for example with things
// like {{ url("page") }} becoming {{ url(" page") }}
"editor.formatOnSave": false,
},
}
......@@ -49,7 +49,7 @@ RUN sudo python3 setup.py install
RUN sudo python3 prerequisites.py --yes --cmsuser=cmsuser install
RUN sudo sed 's|/cmsuser:your_password_here@localhost:5432/cmsdb"|/postgres@cms_test_db:5432/cmsdbfortesting"|' ./config/cms.conf.sample \
RUN sudo sed 's|/cmsuser:your_password_here@localhost:5432/cmsdb"|/postgres@testdb:5432/cmsdbfortesting"|' ./config/cms.conf.sample \
| sudo tee /usr/local/etc/cms-testdb.conf
ENV LANG C.UTF-8
......
......@@ -78,6 +78,7 @@ class Service:
def __init__(self, shard=0):
signal.signal(signal.SIGINT, lambda unused_x, unused_y: self.exit())
signal.signal(signal.SIGTERM, lambda unused_x, unused_y: self.exit())
self.name = self.__class__.__name__
self.shard = shard
......
This diff is collapsed.
This diff is collapsed.
......@@ -196,7 +196,7 @@ $(document).ready(function () {
</li>
{% if actual_phase == 0 or participation.unrestricted %}{# FIXME maybe >= 0? #}
{% if testing_enabled %}
<li{% if page == "testing" %} class="active"{% endif %}>
<li{% if page == "test_interface" %} class="active"{% endif %}>
<a href="{{ contest_url("testing") }}">{% trans %}Testing{% endtrans %}</a>
</li>
{% endif %}
......
......@@ -24,6 +24,7 @@ import os
import pprint
import re
import shutil
import signal
import time
from datetime import datetime
......@@ -622,6 +623,10 @@ def main():
certfile=config.https_certfile, keyfile=config.https_keyfile)
servers.append(https_server)
def sigterm_handler(*_):
raise KeyboardInterrupt
signal.signal(signal.SIGTERM, sigterm_handler)
try:
gevent.joinall(list(gevent.spawn(s.serve_forever) for s in servers))
except KeyboardInterrupt:
......
#include <stdio.h>
#include <stdlib.h>
int main() {
int *big;
int main() {
int i;
big = malloc(128 * 1024 * 1024);
// If we don't do this cycle, the compiler is smart enough not to
......
version: "3.3"
services:
cms_test_db:
container_name: cms_test_db
testdb:
image: postgres
environment:
POSTGRES_HOST_AUTH_METHOD: trust
cms_test:
container_name: cms_test
testcms:
build: .
depends_on:
- "cms_test_db"
- "testdb"
environment:
CMS_CONFIG: /usr/local/etc/cms-testdb.conf
# Could be removed in the future, see:
......@@ -22,14 +20,14 @@ services:
- "./codecov:/home/cmsuser/cms/codecov"
privileged: true
command: >
wait-for-it cms_test_db:5432 -- sh -c "
dropdb --host=cms_test_db --username=postgres cmsdbfortesting ;
createdb --host=cms_test_db --username=postgres cmsdbfortesting ;
wait-for-it testdb:5432 -- sh -c "
dropdb --host=testdb --username=postgres cmsdbfortesting ;
createdb --host=testdb --username=postgres cmsdbfortesting ;
cmsInitDB ;
sudo chown cmsuser:cmsuser ./codecov ;
pytest --cov . --cov-report xml:codecov/unittests.xml ;
dropdb --host=cms_test_db --username=postgres cmsdbfortesting ;
createdb --host=cms_test_db --username=postgres cmsdbfortesting ;
dropdb --host=testdb --username=postgres cmsdbfortesting ;
createdb --host=testdb --username=postgres cmsdbfortesting ;
cmsInitDB ;
cmsRunFunctionalTests -v --coverage codecov/functionaltests.xml ;
"
......@@ -6,29 +6,53 @@ easily get an instance of CMS running locally with all the necessary
dependencies. We also provide a :gh_blob:`docker-compose.test.yml` files that
uses said docker image to run the tests.
Make sure that you have a recent version of Docker installed, as well as Docker
Compose.
.. _docker-image_running-tests:
Running tests
=============
First you need to build the image:
First you need to build the docker image, then you use it to run the tests.
.. note::
The ``-p`` flag is used as a namespace for the containers that will be
created. When you're running tests on a separate branch, it can be useful to
include the branch name there, to avoid any conflict. (You can also omit the
flag and specify the name via the ``COMPOSE_PROJECT_NAME`` environment
variable.)
If you are not part of the ``docker`` group, then you need to run every
docker command with ``sudo``.
To build the image:
.. sourcecode:: bash
docker compose -p cms -f docker-compose.test.yml build testcms
To run the tests:
.. sourcecode:: bash
sudo docker-compose -f docker-compose.test.yml build cms_test
docker compose -p cms -f docker-compose.test.yml run --rm testcms
Then you can run the tests:
Another option is to add the ``--build`` flag to the ``run`` command, to perform
a new build before running the tests:
.. sourcecode:: bash
sudo docker-compose -f docker-compose.test.yml run --rm cms_test
docker compose -p cms -f docker-compose.test.yml run --build --rm testcms
This command will create a ``cms_test_db`` container for the database which
**will not** be automatically deleted, and a ``cms_test`` container for CMS
which will be automatically deleted (because of the ``--rm`` flag) upon exiting.
This command will create (assuming you used ``-p cms``) a ``cms-testdb-1``
container for the database which **will not** be automatically deleted, and a
``cms-testcms-run-<random_string>`` container for CMS which will be
automatically deleted (because of the ``--rm`` flag) upon exiting.
To delete the ``cms_test_db`` container after testing you can run:
To delete the ``cms-testdb-1`` container after testing you can run:
.. sourcecode:: bash
sudo docker rm -f cms_test_db
docker rm -f cms-testdb-1
......@@ -7,10 +7,9 @@ netifaces>=0.10,<0.11 # https://bitbucket.org/al45tair/netifaces/src/
pycryptodomex>=3.6,<3.7 # https://github.com/Legrandin/pycryptodome/blob/master/Changelog.rst
psutil>=5.5,<5.6 # https://github.com/giampaolo/psutil/blob/master/HISTORY.rst
requests>=2.22,<2.23 # https://pypi.python.org/pypi/requests
# Slightly higher version for Python 3.8 support
gevent>=1.5,<1.6 # http://www.gevent.org/changelog.html
# Limit greenlet version for binary compatibility with gevent 1.5 wheels
greenlet<0.4.17
gevent==20.12.0 # http://www.gevent.org/changelog.html
# Limit greenlet version for binary compatibility with gevent 20.12 wheels
greenlet==1.0.0
werkzeug>=0.16,<0.17 # https://github.com/pallets/werkzeug/blob/master/CHANGES
patool>=1.12,<1.13 # https://github.com/wummel/patool/blob/master/doc/changelog.txt
bcrypt>=3.1,<3.2 # https://github.com/pyca/bcrypt/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment