#!/usr/bin/env bash
set -e
INTEG_TEST_IMAGE=${INTEG_TEST_IMAGE:-"quay.io/kubevirt/builder:2306271234-e00d9fcf9"}
PODMAN_SOCKET=${PODMAN_SOCKET:-"/run/podman/podman.sock"}
detect_podman_socket() {
if curl --unix-socket "${PODMAN_SOCKET}" http://d/v3.0.0/libpod/info >/dev/null 2>&1; then
echo "${PODMAN_SOCKET}"
fi
}
if [ "${CONTAINER_CLIENT}" = "podman" ]; then
_cri_bin="podman --remote --url=unix://$(detect_podman_socket)"
elif [ "${CONTAINER_CLIENT}" = "docker" ]; then
_cri_bin=docker
else
_cri_socket=$(detect_podman_socket)
if [ -n "$_cri_socket" ]; then
_cri_bin="podman --remote --url=unix://$_cri_socket"
echo >&2 "selecting podman as container runtime"
elif docker ps >/dev/null 2>&1; then
_cri_bin=docker
echo >&2 "selecting docker as container runtime"
else
echo >&2 "no working container runtime found. Neither docker nor podman seems to work."
exit 1
fi
fi
gocachemount="-v ${HOME}/.cache/go-build:/root/.cache/go-build"
test -t 1 && USE_TTY="-it"
_cli="${_cri_bin} run --privileged --rm ${USE_TTY} ${gocachemount} -v ./:/workspace:Z -w /workspace ${INTEG_TEST_IMAGE}"
$_cli go test -v \
/workspace/pkg/network/driver/nmstate/... \
--run-integration-tests \
${NULL}