Commit 8b6d6ee7 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Testing production servers: created option, test selection system

Only those tests that have the `@suitable.prod_server` mark will
be run in this mode.

Currently validated with the `push_basic` test.

--HG--
branch : stable
parent 71afa012e004
......@@ -44,6 +44,11 @@ def pytest_addoption(parser):
parser.addoption('--heptapod-omnibus', action="store_true",
help="Test a Heptapod Omnibus by running the tests "
"as root on the same system ")
parser.addoption('--heptapod-prod-server', action='store_true',
help="Run only those tests that are suitable "
"for a production installation, with precreated "
"users instead of taking with the root account. "
"Implies --heptapod-remote and requires more parameters.")
parser.addoption('--heptapod-remote', action='store_true',
help="Test a remote server. This means that no "
"direct command nor file system access is possible "
......@@ -53,7 +58,7 @@ def pytest_addoption(parser):
help="Have all Mercurial projects created as 'native' "
"(HGitaly backed)")
parser.addoption('--heptapod-repositories-root',
help="Root of the group/repository hierarchy. "
help="Root directory of the repository storage. "
"This is mandatory for source installs and ignored "
"in Docker mode.")
parser.addoption('--heptapod-gdk-root',
......@@ -120,6 +125,10 @@ def pytest_configure(config):
"hg_native: mark test as running only if "
"session is in hg-native mode"
)
config.addinivalue_line("markers",
"prod_server: mark test as suitable "
"on production servers."
)
def pytest_collection_modifyitems(config, items):
......@@ -133,9 +142,12 @@ def pytest_collection_modifyitems(config, items):
reason="needs to manage Heptapod services")
skip_hg_git = pytest.mark.skip(reason="needs non hg-native mode")
skip_hg_native = pytest.mark.skip(reason="needs hg-native mode")
skip_prod_server = pytest.mark.skip(
reason="not meant for production servers ")
no_reverse_call = not(config.getoption('heptapod_reverse_call_host'))
remote = config.getoption('heptapod_remote')
prod_server = config.getoption('heptapod_prod_server')
remote = config.getoption('heptapod_remote') or prod_server
source_install = config.getoption('heptapod_source_install')
gdk = config.getoption('heptapod_gdk')
omnibus = config.getoption('heptapod_omnibus')
......@@ -155,6 +167,8 @@ def pytest_collection_modifyitems(config, items):
item.add_marker(skip_hg_git)
if "hg_native" in item.keywords and not hg_native:
item.add_marker(skip_hg_native)
if prod_server and "prod_server" not in item.keywords:
item.add_marker(skip_prod_server)
heptapod_instance = None
......@@ -210,6 +224,9 @@ def heptapod(pytestconfig):
**common)
elif pytestconfig.getoption('heptapod_remote'):
heptapod = Heptapod(**common)
elif pytestconfig.getoption('prod_server'):
# TODO will maybe become a sub class (or not)
heptapod = Heptapod(**common)
elif pytestconfig.getoption('heptapod_omnibus'):
heptapod = OmnibusHeptapod(**common)
else:
......
......@@ -7,6 +7,7 @@ import requests
from .utils import (
assert_webdriver_not_error,
needs,
suitable,
)
from .utils.reverse_calls import HttpListener
from .utils.hg import LocalRepo
......@@ -32,6 +33,7 @@ def prepare_simple_repo(proj, repo_path):
return repo
@suitable.prod_server
def test_push_basic(test_project, tmpdir):
"""
Push two changesets, one being a draft, confirm their arrival and phases
......
......@@ -5,3 +5,4 @@ docker = pytest.mark.docker
reverse_call = pytest.mark.reverse_call
services = pytest.mark.services
hg_git = pytest.mark.hg_git
prod_server = pytest.mark.prod_server
"""Mark tests that can run in specific, restricted contexts."""
import pytest
prod_server = pytest.mark.prod_server
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment