Skip to content
Snippets Groups Projects
Commit 024370a05311 authored by Georges Racinet's avatar Georges Racinet
Browse files

Gitaly comparison tests: discovery of Gitaly installation

The ultimate goal being to be able to compare HGitaly responses
to Gitaly responses, this defines concepts to describe
Gitaly installations and adds a discovery system.

A Gitaly installation is at this point a directory with
all the compiled executables and a `ruby` subdirectory for
the gitaly-ruby side.

The CI will run on a base image with an existing installation,
which will be specified by passing the `GITALY_INSTALL_DIR`
environment variable, interpreted by these tests as a strong
promise, and triggering the coverage of `tests_with_gitaly`
in the `run-all-tests` script.

Otherwise, the tests are able to detect the common case where
HGitaly is part of a HDK workspace and use the standard location
for the Gitaly checkout (after minimal checking).
parent 7731f6bf120f
No related branches found
No related tags found
1 merge request!27Gitaly comparison tests
......@@ -46,7 +46,7 @@
# need to install/update something.
- pip3 install -r test-requirements.txt
- pip3 freeze
- flake8 --exclude stub hgitaly hgext3rd
- flake8 --exclude stub hgitaly hgext3rd tests_with_gitaly
- ./run-all-tests
tests-current:
......
#!/bin/sh
set -e
COV_PKG_OPTIONS="--cov hgext3rd --cov hgitaly"
if test -n "$GITALY_INSTALL_DIR"; then
COV_PKG_OPTIONS="$COV_PKG_OPTIONS --cov tests_with_gitaly"
fi
......@@ -2,3 +8,3 @@
set -ue
set -u
......@@ -4,2 +10,6 @@
pytest --doctest-modules --cov hgext3rd --cov hgitaly --cov-config=.coveragerc --cov-fail-under 100 -v $@
pytest --doctest-modules \
$COV_PKG_OPTIONS \
--cov-config=.coveragerc \
--cov-fail-under 100 \
-v $@
# Copyright 2020 Georges Racinet <georges.racinet@octobus.net>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
#
# SPDX-License-Identifier: GPL-2.0-or-later
import os
from pathlib import Path
import hgitaly
import logging
import subprocess
logger = logging.getLogger(__name__)
def gitaly_install_dir(): # pragma no cover
"""Return an absolute Path object for the Gitaly source checkout to use.
The Gitaly sources must have been built.
This first version assumes we are in HDK context or that
the ``GITALY_INSTALL_DIR`` environment variable is set (typically in CI).
"""
from_env = os.environ.get("GITALY_INSTALL_DIR")
if from_env is not None:
return Path(from_env).resolve()
hgitaly_clone = Path(hgitaly.__file__).resolve().parent.parent
hdk = hgitaly_clone.parent
install_dir = hdk / 'gitaly'
if install_dir.is_dir():
gitaly = (install_dir / 'gitaly')
if gitaly.is_file():
# startup costs about 0.15s. That's a lot, but it will
# make sure our skip is correct and it is useful to log the
# version number
version = subprocess.check_output((str(gitaly),
'-version')).decode()
assert 'Gitaly' in version
logger.info("Found %s at %s. Will lauch comparison tests "
"of HGitaly with Gitaly", version, gitaly)
return install_dir
GITALY_INSTALL_DIR = gitaly_install_dir()
def gitaly_not_installed():
return GITALY_INSTALL_DIR is None
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment