From 387d023f4c5c7d43f0b68698ab669a71104a0f80 Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Mar 23 2021 16:32:17 +0000 Subject: [PATCH 1/3] Fix tox-docker and describe using it with podman --- diff --git a/README.md b/README.md index 744b3fb..48f855a 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,14 @@ Should you, for some reason avoid docker, you could run the following command (w $ NO_CAN_HAS_POSTGRES=sadly pytest +To use tox-docker with podman without requiring root, you can use a local user +socket:: + + $ systemctl --user start podman.socket + $ curl --unix-socket /run/user/$UID/podman/podman.sock http://localhost/_ping + $ export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock + $ tox -e py39 + ## Deployment If you're trying to deploy ResultsDB, you might find some helpful instructions diff --git a/requirements.txt b/requirements.txt index 64a0848..a983ecb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,5 +23,5 @@ pytest >= 2.4.2 pytest-cov >= 1.6 # s2i requirements -psycopg2 +psycopg2-binary gunicorn diff --git a/tox.ini b/tox.ini index 5610ae9..67cf2d5 100644 --- a/tox.ini +++ b/tox.ini @@ -21,18 +21,24 @@ envlist = py27,py3{6,7,8,9} requires = tox-docker [testenv] -docker = postgres:latest -dockerenv = - POSTGRES_USER=resultsdb - POSTGRES_DB=resultsdb - POSTGRES_PASWORD=resultsdb +docker = resultsdb-postgres deps = -rrequirements.txt commands = python -m pytest {posargs} # setup.py has from utils import... -setenv = PYTHONPATH = {toxinidir} +setenv = + PYTHONPATH = {toxinidir} + POSTGRES_5432_TCP = 15432 # needs hawkey, koji sitepackages = False # tests read HOME passenv = HOME NO_CAN_HAS_POSTGRES + +[docker:resultsdb-postgres] +image = postgres:12.6 +environment = + POSTGRES_USER=resultsdb + POSTGRES_DB=resultsdb + POSTGRES_PASSWORD=resultsdb +ports = 15432:5432/tcp From 856e85163b225daa73efdcefd3bb91399c848243 Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Mar 26 2021 13:10:24 +0000 Subject: [PATCH 2/3] Fix compatibility with Python 2.7 --- diff --git a/requirements.txt b/requirements.txt index a983ecb..c6a7ade 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,6 +18,10 @@ iso8601 >= 0.1.10 six >= 1.9.0 SQLAlchemy >= 0.9.8 +# Package 'rsa' requires a different Python: 2.7.18 not in '>=3.5, <4' +# (rsa is dependncy of flask-oidc) +rsa < 4.7; python_version < "3" + # Test suite requirements pytest >= 2.4.2 pytest-cov >= 1.6 diff --git a/resultsdb/config.py b/resultsdb/config.py index 43d49cd..1f69d94 100644 --- a/resultsdb/config.py +++ b/resultsdb/config.py @@ -18,6 +18,9 @@ # Josef Skladanka # Ralph Bean +# For Python 2.7 compatibility +from __future__ import print_function + import os import sys From d4fb7dd85053d57ad5eceeb0fd49bc1923ac913b Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Mar 26 2021 13:11:59 +0000 Subject: [PATCH 3/3] Fix cleaning up DB in tests --- diff --git a/testing/functest_api_v20.py b/testing/functest_api_v20.py index 4605d25..cf4b0af 100644 --- a/testing/functest_api_v20.py +++ b/testing/functest_api_v20.py @@ -1021,7 +1021,7 @@ class TestFuncApiV20(): assert data.get('message') == 'Health check OK' def test_healthcheck_fail(self): - resultsdb.db.session.execute('DROP TABLE result') + resultsdb.db.session.execute('DROP TABLE result CASCADE') r = self.app.get('/api/v2.0/healthcheck') assert r.status_code == 503