mirror of
https://github.com/dynup/kpatch
synced 2025-04-26 21:17:57 +00:00
Integration tests with vagrant
This commit adds scripts/make targets to run integration tests on fedora/ubuntu/centos through vagrant. Signed-off-by: Artem Savkov <asavkov@redhat.com>
This commit is contained in:
parent
30e943defd
commit
f43b061bb4
9
Makefile
9
Makefile
@ -13,6 +13,7 @@ CLEAN_DIRS += clean-$(UNITTEST_DIR)
|
|||||||
.PHONY: all install uninstall clean check unit
|
.PHONY: all install uninstall clean check unit
|
||||||
.PHONY: $(SUBDIRS) $(BUILD_DIRS) $(INSTALL_DIRS) $(CLEAN_DIRS)
|
.PHONY: $(SUBDIRS) $(BUILD_DIRS) $(INSTALL_DIRS) $(CLEAN_DIRS)
|
||||||
.PHONY: integration integration-slow integration-quick
|
.PHONY: integration integration-slow integration-quick
|
||||||
|
.PHONY: vagrant-integration-slow vagrant-integration-quick vagrant-integration
|
||||||
|
|
||||||
|
|
||||||
all: $(BUILD_DIRS)
|
all: $(BUILD_DIRS)
|
||||||
@ -42,5 +43,13 @@ integration-slow: $(INTEGRATION_DIR)/Makefile build-kpatch-build build-kpatch bu
|
|||||||
integration-quick: $(INTEGRATION_DIR)/Makefile build-kpatch-build build-kpatch build-kmod
|
integration-quick: $(INTEGRATION_DIR)/Makefile build-kpatch-build build-kpatch build-kmod
|
||||||
$(MAKE) -C $(INTEGRATION_DIR) quick
|
$(MAKE) -C $(INTEGRATION_DIR) quick
|
||||||
|
|
||||||
|
vagrant-integration: vagrant-integration-quick
|
||||||
|
|
||||||
|
vagrant-integration-slow:
|
||||||
|
$(MAKE) -C $(INTEGRATION_DIR) vagrant-slow
|
||||||
|
|
||||||
|
vagrant-integration-quick:
|
||||||
|
$(MAKE) -C $(INTEGRATION_DIR) vagrant-quick
|
||||||
|
|
||||||
check:
|
check:
|
||||||
shellcheck kpatch/kpatch kpatch-build/kpatch-build kpatch-build/kpatch-gcc
|
shellcheck kpatch/kpatch kpatch-build/kpatch-build kpatch-build/kpatch-gcc
|
||||||
|
@ -18,6 +18,14 @@ quick: clean
|
|||||||
cached:
|
cached:
|
||||||
./kpatch-test -d $(PATCH_DIR) --cached $(PATCHES)
|
./kpatch-test -d $(PATCH_DIR) --cached $(PATCHES)
|
||||||
|
|
||||||
|
vagrant: vagrant_quick
|
||||||
|
|
||||||
|
vagrant-quick:
|
||||||
|
./test-vagrant
|
||||||
|
|
||||||
|
vagrant-slow:
|
||||||
|
./test-vagrant --slow
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.ko *.log COMBINED.patch
|
rm -f *.ko *.log COMBINED.patch
|
||||||
|
|
||||||
|
@ -248,3 +248,53 @@ kpatch_write_vagrantfile()
|
|||||||
|
|
||||||
echo 'end' >>Vagrantfile
|
echo 'end' >>Vagrantfile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kpatch_integration_tests_vagrant_distro()
|
||||||
|
{
|
||||||
|
local target_distro=${1}
|
||||||
|
local test_script=${2}
|
||||||
|
local slowtest=${3}
|
||||||
|
|
||||||
|
local testdir
|
||||||
|
local workdir
|
||||||
|
local logdir
|
||||||
|
|
||||||
|
testdir="$(pwd)"
|
||||||
|
workdir="${target_distro}.vagrant"
|
||||||
|
rm -rf "${workdir}"
|
||||||
|
mkdir -p "${workdir}"
|
||||||
|
cd "${workdir}" || exit 1
|
||||||
|
|
||||||
|
kpatch_write_vagrantfile "${target_distro}"
|
||||||
|
|
||||||
|
vagrant up || { vagrant destroy -f; exit 1; }
|
||||||
|
|
||||||
|
local test_cmd="bash /vagrant/runtest.sh"
|
||||||
|
if [ "${slowtest}" == "1" ]; then
|
||||||
|
test_cmd="${test_cmd} --slow"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp "${test_script}" ./runtest.sh
|
||||||
|
vagrant ssh -c "${test_cmd}"
|
||||||
|
local rc=$?
|
||||||
|
|
||||||
|
if [ $rc -eq 0 ]; then
|
||||||
|
echo "${target_distro} PASS"
|
||||||
|
else
|
||||||
|
echo "${target_distro} FAIL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
logdir="${testdir}/${target_distro}_log"
|
||||||
|
rm -rf "${logdir}"
|
||||||
|
mkdir -p "${logdir}"
|
||||||
|
cp logs/* "${logdir}"
|
||||||
|
|
||||||
|
vagrant destroy -f
|
||||||
|
|
||||||
|
cd "${testdir}" || exit 1
|
||||||
|
if [ $rc -eq 0 ]; then
|
||||||
|
rm -rf "${workdir}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return "${rc}"
|
||||||
|
}
|
||||||
|
42
test/integration/test-vagrant
Executable file
42
test/integration/test-vagrant
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPTDIR=$(readlink -f "$(dirname "$(type -p "${0}")")")
|
||||||
|
ROOTDIR=$(readlink -f "${SCRIPTDIR}/../..")
|
||||||
|
SLOWTEST=0
|
||||||
|
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
source "${ROOTDIR}/test/integration/lib.sh"
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
echo "usage: $(basename "${0}") [options]" >&2
|
||||||
|
echo "-h, --help This message" >&2
|
||||||
|
echo "-s, --slow Run all of the tests" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
options="$(getopt -o hs -l "help,slow" -- "$@")" || "getopt failed"
|
||||||
|
|
||||||
|
eval set -- "${options}"
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-s|--slow)
|
||||||
|
SLOWTEST=1
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
declare -a distros=("fedora27" "ubuntu1604" "centos7")
|
||||||
|
|
||||||
|
ret=0
|
||||||
|
for distro in "${distros[@]}"; do
|
||||||
|
kpatch_integration_tests_vagrant_distro "${distro}" "${ROOTDIR}/test/integration/vm-integration-run" "${SLOWTEST}"
|
||||||
|
rc=$?
|
||||||
|
ret=$((ret + rc))
|
||||||
|
done
|
||||||
|
exit ${ret}
|
52
test/integration/vm-integration-run
Executable file
52
test/integration/vm-integration-run
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
KPATCH_SLOW=0
|
||||||
|
LOGDIR="/vagrant/logs"
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
echo "usage: $(basename "${0}") [options]" >&2
|
||||||
|
echo "-h, --help This message" >&2
|
||||||
|
echo "-s, --slow Run all of the tests" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
options="$(getopt -o s -l "slow" -- "$@")" || "getopt failed"
|
||||||
|
|
||||||
|
eval set -- "${options}"
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-s|--slow)
|
||||||
|
KPATCH_SLOW=1
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
git clone https://github.com/dynup/kpatch.git || exit 1
|
||||||
|
|
||||||
|
cd kpatch || exit 1
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
source test/integration/lib.sh
|
||||||
|
|
||||||
|
kpatch_dependencies
|
||||||
|
kpatch_separate_disk_cache /dev/vdb /mnt/build
|
||||||
|
kpatch_set_ccache_max_size 10G
|
||||||
|
|
||||||
|
if [ ${KPATCH_SLOW} -eq 1 ]; then
|
||||||
|
make integration-slow 2>&1
|
||||||
|
else
|
||||||
|
make integration-quick 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rc=${PIPESTATUS[0]}
|
||||||
|
rm -rf "${LOGDIR}"
|
||||||
|
mkdir -p "${LOGDIR}"
|
||||||
|
cp ./test/integration/*.log "${LOGDIR}"
|
||||||
|
|
||||||
|
exit "${rc}"
|
Loading…
Reference in New Issue
Block a user