Files
docker-stacks/tests/run_tests.py
2025-02-21 17:46:43 +00:00

63 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import argparse
import logging
import plumbum
from tests.hierarchy.images_hierarchy import get_test_dirs
python3 = plumbum.local["python3"]
LOGGER = logging.getLogger(__name__)
def test_image(
*,
registry: str,
owner: str,
short_image_name: str,
) -> None:
LOGGER.info(f"Testing image: {short_image_name}")
test_dirs = get_test_dirs(short_image_name)
LOGGER.info(f"Test dirs to be run: {test_dirs}")
with plumbum.local.env(TEST_IMAGE=f"{registry}/{owner}/{short_image_name}"):
(
python3[
"-m",
"pytest",
"--numprocesses",
"auto",
"-m",
"not info",
test_dirs,
]
& plumbum.FG
)
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument(
"--registry",
required=True,
choices=["docker.io", "quay.io"],
help="Image registry",
)
arg_parser.add_argument(
"--owner",
required=True,
help="Owner of the image",
)
arg_parser.add_argument(
"--short-image-name",
required=True,
help="Short image name",
)
args = arg_parser.parse_args()
test_image(**vars(args))