tests: Adds support for Windows cri-integration tests

Currently, the cri-integration tests do not work on Windows due to various reasons.
One of the reasons is because all the tests are using Linux-specific images.
Previous commits refactored the image pulling / usage in the cri-integration tests,
making it easier to update, and easier to configure a custom registry to pull images
with Windows support.

For Windows runs, custom registries can be created, which will also contain Windows
images, and the cri-integration tests can be configured to use those registries by
specifying the "--repo-list" argument, a YAML file which will contain an alternative
mapping of the default registries. This is similar to how E2E tests are handled for
Windows runs in Kubernetes.

Some of the tests are Skipped, as they do not pass yet on Windows.

Windows does not collect inodes used stats, thus, the tests that were expecting non-zero
inodes stats were failing.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
This commit is contained in:
Claudiu Belu
2021-02-16 12:45:45 +00:00
parent fe5d3496a4
commit 09a0c9471b
21 changed files with 153 additions and 81 deletions

View File

@@ -33,7 +33,7 @@ mkdir -p ${REPORT_DIR}
test_setup ${REPORT_DIR}
# Run integration test.
sudo PATH=${PATH} bin/cri-integration.test --test.run="${FOCUS}" --test.v \
${sudo} bin/cri-integration.test --test.run="${FOCUS}" --test.v \
--cri-endpoint=${CONTAINERD_SOCK} \
--cri-root=${CRI_ROOT} \
--runtime-handler=${RUNTIME} \

View File

@@ -16,6 +16,11 @@
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/../..
IS_WINDOWS=0
if [ -v "OS" ] && [ "${OS}" == "Windows_NT" ]; then
IS_WINDOWS=1
fi
# RESTART_WAIT_PERIOD is the period to wait before restarting containerd.
RESTART_WAIT_PERIOD=${RESTART_WAIT_PERIOD:-10}
# CONTAINERD_FLAGS contains all containerd flags.
@@ -52,17 +57,35 @@ CONTAINERD_ROOT=${CONTAINERD_ROOT:-"/var/lib/containerd${CONTAINERD_TEST_SUFFIX}
# The containerd state directory.
CONTAINERD_STATE=${CONTAINERD_STATE:-"/run/containerd${CONTAINERD_TEST_SUFFIX}"}
# The containerd socket address.
CONTAINERD_SOCK=${CONTAINERD_SOCK:-unix://${CONTAINERD_STATE}/containerd.sock}
if [ $IS_WINDOWS -eq 0 ]; then
CONTAINERD_SOCK=${CONTAINERD_SOCK:-unix://${CONTAINERD_STATE}/containerd.sock}
TRIMMED_CONTAINERD_SOCK="${CONTAINERD_SOCK#unix://}"
else
CONTAINERD_SOCK=${CONTAINERD_SOCK:-npipe://./pipe/${CONTAINERD_STATE}/containerd}
TRIMMED_CONTAINERD_SOCK="${CONTAINERD_SOCK#npipe:}"
fi
# The containerd binary name.
CONTAINERD_BIN=${CONTAINERD_BIN:-"containerd"} # don't need a suffix now
EXE_SUFFIX=""
if [ $IS_WINDOWS -eq 1 ]; then
EXE_SUFFIX=".exe"
fi
CONTAINERD_BIN=${CONTAINERD_BIN:-"containerd"}${EXE_SUFFIX}
if [ -f "${CONTAINERD_CONFIG_FILE}" ]; then
CONTAINERD_FLAGS+="--config ${CONTAINERD_CONFIG_FILE} "
fi
CONTAINERD_FLAGS+="--address ${CONTAINERD_SOCK#"unix://"} \
CONTAINERD_FLAGS+="--address ${TRIMMED_CONTAINERD_SOCK} \
--state ${CONTAINERD_STATE} \
--root ${CONTAINERD_ROOT}"
containerd_groupid=
kill_containerd_cmd=
# NOTE: We don't have the sudo command on Windows.
sudo=""
if [ $(id -u) -ne 0 ] && command -v sudo &> /dev/null; then
sudo="sudo PATH=${PATH}"
fi
# test_setup starts containerd.
test_setup() {
@@ -75,11 +98,17 @@ test_setup() {
set -m
# Create containerd in a different process group
# so that we can easily clean them up.
keepalive "sudo PATH=${PATH} bin/containerd ${CONTAINERD_FLAGS}" \
keepalive "${sudo} bin/containerd ${CONTAINERD_FLAGS}" \
${RESTART_WAIT_PERIOD} &> ${report_dir}/containerd.log &
pid=$!
set +m
containerd_groupid=$(ps -o pgid= -p ${pid})
if [ $IS_WINDOWS -eq 1 ]; then
kill_containerd_cmd="${sudo} kill ${pid}"
else
kill_containerd_cmd="${sudo} pkill -g $(ps -o pgid= -p ${pid})"
fi
# Wait for containerd to be running by using the containerd client ctr to check the version
# of the containerd server. Wait an increasing amount of time after each of five attempts
local -r crictl_path=$(which crictl)
@@ -87,14 +116,14 @@ test_setup() {
echo "crictl is not in PATH"
exit 1
fi
readiness_check "sudo bin/ctr --address ${CONTAINERD_SOCK#"unix://"} version"
readiness_check "sudo ${crictl_path} --runtime-endpoint=${CONTAINERD_SOCK} info"
readiness_check "${sudo} bin/ctr --address ${TRIMMED_CONTAINERD_SOCK} version"
readiness_check "${sudo} ${crictl_path} --runtime-endpoint=${CONTAINERD_SOCK} info"
}
# test_teardown kills containerd.
test_teardown() {
if [ -n "${containerd_groupid}" ]; then
sudo pkill -g ${containerd_groupid}
if [ -n "${kill_containerd_cmd}" ]; then
${kill_containerd_cmd}
fi
}