mirror of
https://github.com/containers/podman.git
synced 2025-09-21 11:45:26 +08:00
Merge pull request #13406 from jwhonce/wip/docker-py
Move all python tests to pytest
This commit is contained in:
16
Makefile
16
Makefile
@ -542,7 +542,7 @@ validate.completions:
|
|||||||
run-docker-py-tests:
|
run-docker-py-tests:
|
||||||
touch test/__init__.py
|
touch test/__init__.py
|
||||||
env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf pytest --disable-warnings test/python/docker/
|
env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf pytest --disable-warnings test/python/docker/
|
||||||
-rm test/__init__.py
|
rm -f test/__init__.py
|
||||||
|
|
||||||
.PHONY: localunit
|
.PHONY: localunit
|
||||||
localunit: test/goecho/goecho test/version/version
|
localunit: test/goecho/goecho test/version/version
|
||||||
@ -623,9 +623,15 @@ remotesystem:
|
|||||||
|
|
||||||
.PHONY: localapiv2
|
.PHONY: localapiv2
|
||||||
localapiv2:
|
localapiv2:
|
||||||
env PODMAN=./bin/podman ./test/apiv2/test-apiv2
|
# Order is important running python tests first causes the bash tests to fail, see 12-imagesMore
|
||||||
env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf PODMAN=./bin/podman ${PYTHON} -m unittest discover -v ./test/apiv2/python
|
# FIXME order of tests should not matter
|
||||||
env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf PODMAN=./bin/podman ${PYTHON} -m unittest discover -v ./test/python/docker
|
env PODMAN=./bin/podman stdbuf -o0 -e0 ./test/apiv2/test-apiv2
|
||||||
|
env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf PODMAN=./bin/podman \
|
||||||
|
pytest --disable-warnings ./test/apiv2/python
|
||||||
|
touch test/__init__.py
|
||||||
|
env CONTAINERS_CONF=$(CURDIR)/test/apiv2/containers.conf PODMAN=./bin/podman \
|
||||||
|
pytest --disable-warnings ./test/python/docker
|
||||||
|
rm -f test/__init__.py
|
||||||
|
|
||||||
.PHONY: remoteapiv2
|
.PHONY: remoteapiv2
|
||||||
remoteapiv2:
|
remoteapiv2:
|
||||||
@ -949,5 +955,5 @@ clean: clean-binaries ## Clean all make artifacts
|
|||||||
libpod/pod_easyjson.go \
|
libpod/pod_easyjson.go \
|
||||||
.install.goimports \
|
.install.goimports \
|
||||||
docs/build \
|
docs/build \
|
||||||
venv
|
.venv
|
||||||
make -C docs clean
|
make -C docs clean
|
||||||
|
@ -55,11 +55,8 @@ function _run_unit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _run_apiv2() {
|
function _run_apiv2() {
|
||||||
local m="Testing of API was performed using the **PODMAN*** client"
|
source .venv/requests/bin/activate
|
||||||
warn "$m"
|
make localapiv2 |& logformatter
|
||||||
if ! make localapiv2 |& logformatter; then
|
|
||||||
die "$m"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _run_compose() {
|
function _run_compose() {
|
||||||
@ -100,12 +97,8 @@ function _run_bindings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _run_docker-py() {
|
function _run_docker-py() {
|
||||||
m="Testing of API was performed using the **DOCKER** client"
|
source .venv/docker-py/bin/activate
|
||||||
warn "$m"
|
make run-docker-py-tests
|
||||||
source venv/bin/activate
|
|
||||||
if ! make run-docker-py-tests; then
|
|
||||||
die "$m"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _run_endpoint() {
|
function _run_endpoint() {
|
||||||
|
@ -265,14 +265,21 @@ case "$TEST_FLAVOR" in
|
|||||||
|
|
||||||
msg "Installing previously downloaded/cached packages"
|
msg "Installing previously downloaded/cached packages"
|
||||||
dnf install -y $PACKAGE_DOWNLOAD_DIR/python3*.rpm
|
dnf install -y $PACKAGE_DOWNLOAD_DIR/python3*.rpm
|
||||||
virtualenv venv
|
virtualenv .venv/docker-py
|
||||||
source venv/bin/activate
|
source .venv/docker-py/bin/activate
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install --requirement $GOSRC/test/python/requirements.txt
|
pip install --requirement $GOSRC/test/python/requirements.txt
|
||||||
;;
|
;;
|
||||||
build) make clean ;;
|
build) make clean ;;
|
||||||
unit) ;;
|
unit) ;;
|
||||||
apiv2) ;& # use next item
|
apiv2)
|
||||||
|
msg "Installing previously downloaded/cached packages"
|
||||||
|
dnf install -y $PACKAGE_DOWNLOAD_DIR/python3*.rpm
|
||||||
|
virtualenv .venv/requests
|
||||||
|
source .venv/requests/bin/activate
|
||||||
|
pip install --upgrade pip
|
||||||
|
pip install --requirement $GOSRC/test/apiv2/python/requirements.txt
|
||||||
|
;& # continue with next item
|
||||||
compose)
|
compose)
|
||||||
rpm -ivh $PACKAGE_DOWNLOAD_DIR/podman-docker*
|
rpm -ivh $PACKAGE_DOWNLOAD_DIR/podman-docker*
|
||||||
;& # continue with next item
|
;& # continue with next item
|
||||||
|
@ -26,7 +26,8 @@ t GET libpod/images/$IMAGE/json 200 \
|
|||||||
.RepoTags[1]=localhost:5000/myrepo:mytag
|
.RepoTags[1]=localhost:5000/myrepo:mytag
|
||||||
|
|
||||||
# Run registry container
|
# Run registry container
|
||||||
podman run -d --name registry -p 5000:5000 quay.io/libpod/registry:2.6 /entrypoint.sh /etc/docker/registry/config.yml
|
# FIXME this fails if python tests have been run first...
|
||||||
|
podman run -d --name registry -p 5000:5000 quay.io/libpod/registry:2.7 /entrypoint.sh /etc/docker/registry/config.yml
|
||||||
wait_for_port localhost 5000
|
wait_for_port localhost 5000
|
||||||
|
|
||||||
# Push to local registry and check output
|
# Push to local registry and check output
|
||||||
@ -58,7 +59,7 @@ t DELETE libpod/containers/registry?force=true 200
|
|||||||
# Remove images
|
# Remove images
|
||||||
t DELETE libpod/images/$IMAGE 200 \
|
t DELETE libpod/images/$IMAGE 200 \
|
||||||
.ExitCode=0
|
.ExitCode=0
|
||||||
t DELETE libpod/images/quay.io/libpod/registry:2.6 200 \
|
t DELETE libpod/images/quay.io/libpod/registry:2.7 200 \
|
||||||
.ExitCode=0
|
.ExitCode=0
|
||||||
|
|
||||||
if [ -z "${GOT_DIGEST}" ] ; then
|
if [ -z "${GOT_DIGEST}" ] ; then
|
||||||
|
8
test/apiv2/python/conftest.py
Normal file
8
test/apiv2/python/conftest.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
"""
|
||||||
|
Configure pytest
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_report_header(config):
|
||||||
|
"""Add header to report."""
|
||||||
|
return "python client -- requests library"
|
5
test/apiv2/python/requirements.txt
Normal file
5
test/apiv2/python/requirements.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
requests-mock~=1.9.3
|
||||||
|
requests~=2.20.0
|
||||||
|
setuptools~=50.3.2
|
||||||
|
python-dateutil~=2.8.1
|
||||||
|
PyYAML~=5.4.1
|
@ -368,7 +368,7 @@ function start_service() {
|
|||||||
die "Cannot start service on non-localhost ($HOST)"
|
die "Cannot start service on non-localhost ($HOST)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $WORKDIR
|
echo "rootdir: "$WORKDIR
|
||||||
# Some tests use shortnames; force registry override to work around
|
# Some tests use shortnames; force registry override to work around
|
||||||
# docker.io throttling.
|
# docker.io throttling.
|
||||||
# FIXME esm revisit pulling expected images re: shortnames caused tests to fail
|
# FIXME esm revisit pulling expected images re: shortnames caused tests to fail
|
||||||
@ -376,7 +376,7 @@ function start_service() {
|
|||||||
$PODMAN_BIN \
|
$PODMAN_BIN \
|
||||||
--root $WORKDIR/server_root --syslog=true \
|
--root $WORKDIR/server_root --syslog=true \
|
||||||
system service \
|
system service \
|
||||||
--time 15 \
|
--time 0 \
|
||||||
tcp:127.0.0.1:$PORT \
|
tcp:127.0.0.1:$PORT \
|
||||||
&> $WORKDIR/server.log &
|
&> $WORKDIR/server.log &
|
||||||
service_pid=$!
|
service_pid=$!
|
||||||
@ -443,7 +443,7 @@ function start_registry() {
|
|||||||
-e REGISTRY_HTTP_TLS_KEY=/auth/domain.key \
|
-e REGISTRY_HTTP_TLS_KEY=/auth/domain.key \
|
||||||
${REGISTRY_IMAGE}
|
${REGISTRY_IMAGE}
|
||||||
|
|
||||||
wait_for_port localhost $REGISTRY_PORT
|
wait_for_port localhost $REGISTRY_PORT 10
|
||||||
}
|
}
|
||||||
|
|
||||||
function stop_registry() {
|
function stop_registry() {
|
||||||
@ -492,13 +492,16 @@ function wait_for_port() {
|
|||||||
local port=$2 # Numeric port
|
local port=$2 # Numeric port
|
||||||
local _timeout=${3:-5} # Optional; default to 5 seconds
|
local _timeout=${3:-5} # Optional; default to 5 seconds
|
||||||
|
|
||||||
|
local path=/dev/tcp/$host/$port
|
||||||
|
|
||||||
# Wait
|
# Wait
|
||||||
while [ $_timeout -gt 0 ]; do
|
local i=$_timeout
|
||||||
|
while [ $i -gt 0 ]; do
|
||||||
{ exec 3<> /dev/tcp/$host/$port; } &>/dev/null && return
|
{ exec 3<> /dev/tcp/$host/$port; } &>/dev/null && return
|
||||||
sleep 1
|
sleep 1
|
||||||
_timeout=$(( $_timeout - 1 ))
|
i=$(( $i - 1 ))
|
||||||
done
|
done
|
||||||
die "Timed out waiting for service"
|
die "Timed out (${_timeout}s) waiting for service ($path)"
|
||||||
}
|
}
|
||||||
|
|
||||||
############
|
############
|
||||||
@ -543,6 +546,9 @@ done
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# BEGIN entry handler (subtest invoker)
|
# BEGIN entry handler (subtest invoker)
|
||||||
|
|
||||||
|
echo '============================= test session starts =============================='
|
||||||
|
echo "podman client -- $(curl --version)"
|
||||||
|
|
||||||
# Identify the tests to run. If called with args, use those as globs.
|
# Identify the tests to run. If called with args, use those as globs.
|
||||||
tests_to_run=()
|
tests_to_run=()
|
||||||
if [ -n "$*" ]; then
|
if [ -n "$*" ]; then
|
||||||
@ -558,6 +564,7 @@ if [ -n "$*" ]; then
|
|||||||
else
|
else
|
||||||
tests_to_run=($TESTS_DIR/*.at)
|
tests_to_run=($TESTS_DIR/*.at)
|
||||||
fi
|
fi
|
||||||
|
echo -e "collected ${#tests_to_run[@]} items\n"
|
||||||
|
|
||||||
start_service
|
start_service
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user