Skip to content

Commit b138542

Browse files
test: take testutils and the compose files from mender-testkit
Drops the mender_server submodule. testutils, the Server facade and mender-server's compose files now come from the mender-testkit package, which vendors all three from a pinned mender-server commit. conftest materialises the compose tree to tests/mender_server, the path the submodule occupied, so tests/compose/*.yml keep working unchanged -- both the include: paths and the project_directory that makes the relative bind mounts resolve. Gitignored; regenerated per run. GATEWAY_HOSTNAME is set by the package's pytest plugin, which loads before any conftest, so the ordering dance around that import goes away. CI no longer fetches submodules. Depends on mender-testkit being installable; python-requirements.in still needs it added once it is published. Ticket: QA-1702 Signed-off-by: Rewan Rashid <rewan.rashid@northern.tech>
1 parent 74e92d2 commit b138542

27 files changed

Lines changed: 76 additions & 78 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ venv
3434
# direnv Python virtualenv setup
3535
*.direnv
3636
*.envrc
37+
38+
# Materialised from the mender-testkit package by tests/conftest.py
39+
tests/mender_server/

.gitlab-ci-default-pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include:
77
file: '.gitlab-ci-check-python3-format.yml'
88

99
variables:
10-
LICENSE_HEADERS_IGNORE_FILES_REGEXP: '\./(extra/gitdm|tests/mender_server).*'
10+
LICENSE_HEADERS_IGNORE_FILES_REGEXP: '\./extra/gitdm.*'
1111

1212
test:extra-tools:
1313
image: "python:3"

.gitlab-ci-full-integration-template.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ test:integration:$CI_NODE_INDEX:
1616
# default budget.
1717
timeout: 2h
1818
variables:
19-
# The backend composition comes from the mender-server submodule at
20-
# tests/mender_server; without this the compose files are simply absent and
21-
# every environment fails to start.
22-
GIT_SUBMODULE_STRATEGY: recursive
23-
GIT_SUBMODULE_DEPTH: 1
19+
# No submodules needed: the backend composition arrives with the
20+
# mender-testkit package, which conftest materialises before any test runs.
21+
GIT_SUBMODULE_STRATEGY: none
2422
before_script:
2523
# These two variables would be set by GitLab CI "parallel" feature, and are used by our Pytest
2624
# plugin to split the tests among the CI jobs. They get substituted by the generator.
@@ -35,14 +33,10 @@ test:integration:$CI_NODE_INDEX:
3533
- apk add py3-virtualenv screen
3634
- python -m virtualenv /.venv
3735
- source /.venv/bin/activate
38-
# Integration keeps its own testutils, so its own requirements file is the
39-
# right one -- nothing here imports from the mender_server submodule, which
40-
# is used for its compose files only.
36+
# mender-testkit brings testutils, the Server facade and mender-server's
37+
# compose files; this file carries everything else.
4138
- pip3 install -r ./tests/requirements-python/python-requirements.txt
4239
- pip3 install pyyaml
43-
# Fail early and loudly if the submodule did not come through.
44-
- test -f ./tests/mender_server/docker-compose.yml
45-
|| { echo "mender_server submodule missing"; exit 1; }
4640
# Gitlab CI tends to set these DOCKER_ variables internally.
4741
# dind also creates the unix socket at /var/run/docker.sock
4842
- unset DOCKER_HOST DOCKER_TLS_VERIFY DOCKER_CERT_PATH

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
[submodule "extra/gitdm/gitdm"]
22
path = extra/gitdm/gitdm
33
url = git://git.lwn.net/gitdm.git
4-
[submodule "tests/mender_server"]
5-
path = tests/mender_server
6-
url = https://github.com/mendersoftware/mender-server.git

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ exclude = '''
2323
| build
2424
| dist
2525
| extra/gitdm
26-
| tests/mender_server
2726
)/
2827
)
2928
'''

tests/MenderAPI/authentication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from . import get_container_manager
2222
from .requests_helpers import requests_retry
2323

24-
from testutils.infra.cli import CliUseradm, CliTenantadm
24+
from mender_testkit.testutils.infra.cli import CliUseradm, CliTenantadm
2525

2626

2727
class Authentication:

tests/MenderAPI/deviceconnect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from testutils.util import websockets
16-
from testutils.api import deviceconnect
15+
from mender_testkit.testutils.util import websockets
16+
from mender_testkit.testutils.api import deviceconnect
1717
from . import api_version
1818
from . import get_container_manager
1919

tests/MenderAPI/requests_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from requests.adapters import HTTPAdapter
1717
from requests.packages.urllib3.util.retry import Retry
1818

19-
from testutils.api.client import GATEWAY_HOSTNAME
19+
from mender_testkit.testutils.api.client import GATEWAY_HOSTNAME
2020

2121

2222
# Will retry on server errors (5xx)

tests/common_setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
from .MenderAPI import authentication, auth, devauth, reset_mender_api, DeviceAuthV2
2222

23-
from testutils.common import User, new_tenant_client
24-
from testutils.infra.cli import CliTenantadm
25-
from testutils.infra.device import MenderDevice, MenderDeviceGroup
23+
from mender_testkit.testutils.common import User, new_tenant_client
24+
from mender_testkit.testutils.infra.cli import CliTenantadm
25+
from mender_testkit.testutils.infra.device import MenderDevice, MenderDeviceGroup
2626
from .container_manager import factory
2727

2828
container_factory = factory.get_factory()

tests/conftest.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,28 @@
2323

2424
import multiprocessing
2525

26-
# testutils comes from the mender-server submodule -- this repo no longer keeps a
27-
# fork of it. Both of these have to happen before the first testutils import
28-
# below: the path so it resolves at all, and the hostname because
29-
# testutils.api.client reads it into a module-level constant at import time.
30-
#
31-
# Traefik's routers match on Host as well as path, and the tests address the
32-
# ingress by container IP, so every request has to carry this. Upstream defaults
33-
# it to "traefik", which is the name its own deployments answer to.
34-
sys.path.insert(
35-
0,
36-
os.path.join(
37-
os.path.dirname(os.path.abspath(__file__)), "mender_server", "backend", "tests"
38-
),
39-
)
40-
os.environ.setdefault("GATEWAY_HOSTNAME", "docker.mender.io")
41-
4226
import filelock
4327
import pytest
4428
from filelock import FileLock
45-
from testutils.infra.container_manager.base import BaseContainerManagerNamespace
46-
from testutils.infra.device import MenderDevice, MenderDeviceGroup
29+
from mender_testkit.compose import compose_dir
30+
from mender_testkit.testutils.infra.container_manager.base import (
31+
BaseContainerManagerNamespace,
32+
)
33+
from mender_testkit.testutils.infra.device import MenderDevice, MenderDeviceGroup
4734

4835
from . import log
4936
from .tests.mendertesting import MenderTesting
5037

5138
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
5239
RELEASE_TOOL = os.path.join(THIS_DIR, "..", "extra", "release_tool.py")
5340

41+
# mender-server's compose files now come from the mender-testkit package rather
42+
# than a submodule. They are written to the path the submodule used to occupy, so
43+
# that the include: directives in tests/compose/*.yml -- and the project_directory
44+
# they set, which is what makes the relative bind mounts resolve -- keep working
45+
# unchanged. Gitignored; regenerated on every run.
46+
compose_dir(dest=os.path.join(THIS_DIR, "mender_server"))
47+
5448
logging.getLogger("requests").setLevel(logging.CRITICAL)
5549
logging.getLogger("paramiko").setLevel(logging.CRITICAL)
5650
logging.getLogger("urllib3").setLevel(logging.CRITICAL)
@@ -62,7 +56,7 @@
6256

6357
machine_name = None
6458

65-
collect_ignore = ["mender_server"]
59+
collect_ignore = ["mender_server"] # the materialised compose tree, not test code
6660

6761

6862
def pytest_addoption(parser):

0 commit comments

Comments
 (0)