Commit 91e2b27c authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Testing production servers: group CLI option

Up to now, project creations were occurring in the group
owner personal namespace. With this change, they happen
in the target group, if specified.

branch : stable
parent 54a2aeb10a91
......@@ -60,6 +60,10 @@ def pytest_addoption(parser):
"testing will happen. "
"Provided as colon separated fields, such as "
group.addoption('--heptapod-prod-group-id', type=int,
help="prod servers only: numeric id for the group "
"where most projects and subgroups are to be created. "
"Some tests may still use personal namespaces.")
parser.addoption('--heptapod-remote', action='store_true',
help="Test a remote server. This means that no "
"direct command nor file system access is possible "
......@@ -228,6 +232,8 @@ def heptapod(pytestconfig):
heptapod = ProductionHeptapod(
elif pytestconfig.getoption('heptapod_source_install'):
......@@ -267,6 +273,8 @@ def heptapod(pytestconfig):
def project_fixture(heptapod, name_prefix, owner=None, group=None, **opts):
if owner is None:
owner = heptapod.default_user_name
if group is None:
group = heptapod.default_group
name = '%s_%s' % (name_prefix, str(time.time()).replace('.', '_'))
with Project.api_create(heptapod, owner, name,
group=group, **opts) as proj:
......@@ -14,6 +14,7 @@ import tempfile
import time
from urllib.parse import urlparse
from import Group
from tests.utils.user import User
from tests.utils import docker
from tests.utils import session
......@@ -70,6 +71,9 @@ class Heptapod:
default_user_name = 'root'
"""Default user for project, group creation etc."""
default_group = None
"""Group instance where to create projects in by default."""
def __init__(self, url, ssh_user, ssh_port,
......@@ -487,7 +491,8 @@ class ProductionHeptapod(Heptapod):
and personal namespaces of a couple of users.
def __init__(self, group_owner_credentials, **kw):
def __init__(self, group_owner_credentials, default_group_id,
super(ProductionHeptapod, self).__init__(**kw)
user_id, name, pwd = group_owner_credentials.split(':', 2)
user_id = int(user_id)
......@@ -505,6 +510,7 @@ class ProductionHeptapod(Heptapod):
user.password = pwd
self.group_owner = user
self.default_group_id = default_group_id
def prepare(self, root_password):
"""Prepare the group owner.
......@@ -528,6 +534,12 @@ class ProductionHeptapod(Heptapod):
self.load_ssh_keys(key_name_mapping={ 'root',
def init_default_group(self):
gid = self.default_group_id
self.default_group = Group.api_retrieve(
self, gid,
def remove_ssh_keys(self):
for user in (self.group_owner, ):
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