Commit 6c34c220 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Native Mercurial: splitting in full and hgitaly1 mode

With the full native mode being controlled by feature flags,
it makes sense to provide facilities in these functional tests
to use either the HGitaly1 or the fully native mode.

This is done by changing the `--heptapod-hg-native` command-line
argument from an activation flag to an option with two values:
`hgitaly1` and `full`.

Later on, we'll introduce new CI jobs for the fully native mode.
parent a9aeccd510ac
......@@ -69,9 +69,7 @@ docker-inside:
.hg-native:
variables:
# avoid any trouble with boolean interpretation but that means that
# only this exact spelling will work
HEPTAPOD_HG_NATIVE: "yes"
HEPTAPOD_HG_NATIVE: hgitaly1
docker-remote-0:
variables:
......@@ -109,7 +107,7 @@ docker-native-inside:
# so we need to duplicate
services:
- name: selenium/standalone-chrome
alias: selenium-for-native-inside
alias: selenium-for-native-inside-hgitaly1
docker-native-remote-0:
variables:
......@@ -118,9 +116,9 @@ docker-native-remote-0:
# unfortunately variables are not expanded in service aliases
# so we need to duplicate
- name: $HEPTAPOD_BASE_IMAGE:$TARGET_HEPTAPOD_IMAGE
alias: heptapod-native-0
alias: heptapod-native-hgitaly1-0
- name: selenium/standalone-chrome
alias: selenium-native-0
alias: selenium-native-hgitaly1-0
extends:
- .docker-remote
- .rules:test-heptapod
......@@ -133,9 +131,9 @@ docker-native-remote-1:
# unfortunately variables are not expanded in service aliases
# so we need to duplicate
- name: $HEPTAPOD_BASE_IMAGE:$TARGET_HEPTAPOD_IMAGE
alias: heptapod-native-1
alias: heptapod-native-hgitaly1-1
- name: selenium/standalone-chrome
alias: selenium-native-1
alias: selenium-native-hgitaly1-1
extends:
- .docker-remote
- .rules:test-heptapod
......
......@@ -2,10 +2,9 @@
set -e
if [ "$HEPTAPOD_HG_NATIVE" = "yes" ]; then
COMMON_FLAGS="${COMMONFLAGS} --heptapod-hg-native"
HEPTAPOD_SERVICE=heptapod-native
SELENIUM_SERVICE=selenium-native
if [ -n "$HEPTAPOD_HG_NATIVE" ]; then
HEPTAPOD_SERVICE=heptapod-native-${HEPTAPOD_HG_NATIVE}
SELENIUM_SERVICE=selenium-native-${HEPTAPOD_HG_NATIVE}
else
HEPTAPOD_SERVICE=heptapod
SELENIUM_SERVICE=selenium
......@@ -23,8 +22,8 @@ COMMON_FLAGS="-v \
--heptapod-remote \
--heptapod-webdriver-remote-url http://${SELENIUM_SERVICE}-${PYTEST_SHARD_ID}:4444/wd/hub"
if [ "$HEPTAPOD_HG_NATIVE" = "yes" ]; then
COMMON_FLAGS="${COMMON_FLAGS} --heptapod-hg-native"
if [ -n "$HEPTAPOD_HG_NATIVE" ]; then
COMMON_FLAGS="${COMMON_FLAGS} --heptapod-hg-native=${HEPTAPOD_HG_NATIVE}"
fi
if tox -- $COMMON_FLAGS --heptapod-wait-after-first-response 180; then
......
......@@ -7,17 +7,16 @@ set -e
# that the wrapper script does is really too much clutter for the job log).
/assets/wrapper >/dev/null 2>&1 &
if [ "$HEPTAPOD_HG_NATIVE" = "yes" ]; then
COMMON_FLAGS="${COMMON_FLAGS} --heptapod-hg-native"
SELENIUM_SERVICE=selenium-for-native-inside
else
SELENIUM_SERVICE=selenium-for-inside
fi
# find the (unique) container IP address
# TODO make a separate script for readability and adaptability
HEPTAPOD_SERVICE_IP=$(ip -j -4 address show scope global | /opt/gitlab/embedded/bin/python3 -c 'import json, sys; print(json.load(sys.stdin)[0]["addr_info"][0]["local"])')
if [ -n "$HEPTAPOD_HG_NATIVE" ]; then
SELENIUM_SERVICE=selenium-for-native-inside-${HEPTAPOD_HG_NATIVE}
else
SELENIUM_SERVICE=selenium-for-inside
fi
COMMON_FLAGS="-v \
--heptapod-url http://$HEPTAPOD_SERVICE_IP \
--heptapod-ssh-port 22 \
......@@ -28,6 +27,10 @@ COMMON_FLAGS="-v \
--heptapod-webdriver-remote-url http://${SELENIUM_SERVICE}:4444/wd/hub \
--heptapod-omnibus"
if [ -n "$HEPTAPOD_HG_NATIVE" ]; then
COMMON_FLAGS="${COMMON_FLAGS} --heptapod-hg-native=${HEPTAPOD_HG_NATIVE}"
fi
chown -R git:git .
GIT_HOME=`ls -d ~git` # for explicit guaranteed forwarding
chown git:git $GIT_HOME
......
......@@ -76,7 +76,7 @@ def pytest_addoption(parser):
"direct command nor file system access is possible "
"leading to skipping some tests and some teardown "
"reliability actions.")
parser.addoption('--heptapod-hg-native', action='store_true',
parser.addoption('--heptapod-hg-native', choices=('full', 'hgitaly1'),
help="Have all Mercurial projects created as 'native' "
"(HGitaly backed)")
parser.addoption('--heptapod-repositories-root',
......
......@@ -89,7 +89,7 @@ class Heptapod:
"""
def __init__(self, url, ssh_user, ssh_port,
hg_native=False,
hg_native=None,
clever_cloud_sso=False,
reverse_call_host=None,
wait_after_first_response=0,
......@@ -300,9 +300,16 @@ class Heptapod:
# Mercurial native projects (vcs_types='hg') arent allowed by
# default
if self.hg_native and 'hg' not in self.settings.get('vcs_types', ()):
native = self.hg_native
if native and 'hg' not in self.settings.get('vcs_types', ()):
self.set_vcs_types_settings(['hg', 'git', 'hg_git'])
logger.info("Preparing feature flags.")
feature_flags = {}
if native is not None:
feature_flags['hg_fully_native'] = native == 'full'
self.set_feature_flags(feature_flags)
logger.info("Preparing basic user.")
User.ensure(self, 'test_basic',
fullname='Bäsîc Test',
......@@ -338,6 +345,30 @@ class Heptapod:
assert resp.status_code == 200
self.settings = resp.json()
def set_feature_flags(self, flags):
"""Make sure that GitLab feature flags are as specified
This controls instance-wide value of the feature flags. Any value
subsequently set for a specific actor (Project, User etc) will
be ignored.
:param flags: `dict` mapping flag names to the wished boolean value.
Uses the dedicated API:
https://docs.gitlab.com/ce/api/features.html#set-or-create-a-feature
"""
headers = self.root_token_headers
for flag, value in flags.items():
resp = requests.post('/'.join((self.api_url,
'features',
flag)),
headers=headers,
# True doesn't seem to do anything, so
# let's go the percentage way.
data=dict(value=100 if value else 0)
)
assert resp.status_code < 400
def api_request(self, method, user=None, subpath='', **kwargs):
"""Perform a simple API HTTP request
......
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