test/packaging: Introduce separate test suite for packaging

Move the RPM builds away from autopackage.sh into a dedicated test
suite - this will allow the actual packaging tests to be run in a
separate instance.

Signed-off-by: Michal Berger <michal.berger@intel.com>
Change-Id: I23a824db7aa3a5e469bea9b2536a83ae0a5c8e04
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14937
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
This commit is contained in:
Michal Berger 2022-10-12 14:10:10 +02:00 committed by Tomasz Zawadzki
parent 8ecd4994fb
commit e802c16570
3 changed files with 104 additions and 78 deletions

View File

@ -14,83 +14,6 @@ rootdir=$(readlink -f $(dirname $0))
testdir=$rootdir # to get the storage space for tests testdir=$rootdir # to get the storage space for tests
source "$rootdir/test/common/autotest_common.sh" source "$rootdir/test/common/autotest_common.sh"
function build_rpms() (
local version rpms
# Make sure linker will not attempt to look under DPDK's repo dir to get the libs
unset -v LD_LIBRARY_PATH
install_uninstall_rpms() {
rpms=("${1:-$builddir/rpm/}/x86_64/"*.rpm)
sudo rpm -i "${rpms[@]}"
# Check if we can find one of the apps in the PATH now and verify if it doesn't miss
# any libs.
LIST_LIBS=yes "$rootdir/rpmbuild/rpm-deps.sh" "${SPDK_APP[@]##*/}"
rm "${rpms[@]}"
rpms=("${rpms[@]##*/}") rpms=("${rpms[@]%.rpm}")
sudo rpm -e "${rpms[@]}"
}
build_rpm() {
# Separate run to see the final .spec in use
GEN_SPEC=yes BUILDDIR=$builddir MAKEFLAGS="$MAKEFLAGS" SPDK_VERSION="$version" DEPS=no "$rootdir/rpmbuild/rpm.sh" "$@"
# Actual build
BUILDDIR=$builddir MAKEFLAGS="$MAKEFLAGS" SPDK_VERSION="$version" DEPS=no "$rootdir/rpmbuild/rpm.sh" "$@" || return $?
install_uninstall_rpms
}
build_rpm_with_rpmed_dpdk() {
local es=0
sudo dnf install -y dpdk-devel
build_rpm --with-shared --with-dpdk || es=$?
if ((es == 11)); then
echo "ERROR: Failed to resolve required build dependencies. Please review the build log." >&2
fi
return "$es"
}
build_rpm_from_gen_spec() {
GEN_SPEC=yes \
USE_DEFAULT_DIRS=yes \
MAKEFLAGS="$MAKEFLAGS" \
SPDK_VERSION="$version" \
DEPS=no \
"$rootdir/rpmbuild/rpm.sh" --with-shared > "$builddir/gen-spdk.spec"
# Default locations should be in use.
sourcedir=$(rpm --eval "%{_sourcedir}") rpmdir=$(rpm --eval "%{_rpmdir}")
mkdir -p "$sourcedir" "$rpmdir"
# Prepare the source at the default location - default %prep step requires
# extra dir inside the source package hence the dance with symlinking to
# the repo (after the extraction source should be under spdk-$version/) -
# make sure symlinking is done outside of the repo to avoid nasty loops.
ln -s "$rootdir" "/tmp/spdk-$version"
tar -czhf "$sourcedir/spdk-$version.tar.gz" -C /tmp "spdk-$version"
# See rpm.sh for details on the PYTHONPATH HACK
PYTHONPATH="$(python3 -c "import sys; print('%s' % ':'.join(sys.path)[1:])")" \
rpmbuild -ba "$builddir/gen-spdk.spec"
install_uninstall_rpms "$rpmdir"
}
version="test_shared"
builddir=$SPDK_TEST_STORAGE/test-rpm
run_test "build_shared_rpm" build_rpm --with-shared
if [[ $RUN_NIGHTLY -eq 1 ]]; then
run_test "build_shared_rpm_with_rpmed_dpdk" build_rpm_with_rpmed_dpdk
run_test "build_rpm_from_gen_spec" build_rpm_from_gen_spec
if [[ -n $SPDK_TEST_NATIVE_DPDK ]]; then
version="test_shared_native_dpdk"
run_test "build_shared_native_dpdk_rpm" build_rpm --with-shared --with-dpdk="$SPDK_RUN_EXTERNAL_DPDK"
fi
fi
)
out=$PWD out=$PWD
MAKEFLAGS=${MAKEFLAGS:--j16} MAKEFLAGS=${MAKEFLAGS:--j16}
@ -107,7 +30,7 @@ fi
timing_exit porcelain_check timing_exit porcelain_check
if [[ $SPDK_TEST_RELEASE_BUILD -eq 1 ]]; then if [[ $SPDK_TEST_RELEASE_BUILD -eq 1 ]]; then
run_test "build_rpms" build_rpms run_test "packaging" test/packaging/packaging.sh
$MAKE clean $MAKE clean
fi fi

7
test/packaging/packaging.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
testdir=$(readlink -f "$(dirname "$0")")
rootdir=$(readlink -f "$testdir/../../")
source "$rootdir/test/common/autotest_common.sh"
run_test "rpm_packaging" "$testdir/rpm/rpm.sh"

96
test/packaging/rpm/rpm.sh Executable file
View File

@ -0,0 +1,96 @@
#!/usr/bin/env bash
testdir=$(readlink -f "$(dirname "$0")")
rootdir=$(readlink -f "$testdir/../../../")
source "$rootdir/test/common/autotest_common.sh"
builddir=$SPDK_TEST_STORAGE/test-rpm
# Make sure linker will not attempt to look under DPDK's repo dir to get the libs
unset -v LD_LIBRARY_PATH
# Export some common settings
MAKEFLAGS="-j $(nproc)"
BUILDDIR=$builddir
DEPS=no
export MAKEFLAGS BUILDDIR DEPS
install_uninstall_rpms() {
local rpms
rpms=("${1:-$builddir/rpm/}/x86_64/"*.rpm)
sudo rpm -i "${rpms[@]}"
# Check if we can find one of the apps in the PATH now and verify if it doesn't miss
# any libs.
LIST_LIBS=yes "$rootdir/rpmbuild/rpm-deps.sh" "${SPDK_APP[@]##*/}"
rm "${rpms[@]}"
rpms=("${rpms[@]##*/}") rpms=("${rpms[@]%.rpm}")
sudo rpm -e "${rpms[@]}"
}
build_rpm() {
# Separate run to see the final .spec in use
GEN_SPEC=yes "$rootdir/rpmbuild/rpm.sh" "$@"
# Actual build
"$rootdir/rpmbuild/rpm.sh" "$@" || return $?
install_uninstall_rpms
}
build_shared_rpm() {
build_rpm --with-shared
}
build_rpm_with_rpmed_dpdk() {
local es=0
sudo dnf install -y dpdk-devel
build_rpm --with-shared --with-dpdk || es=$?
if ((es == 11)); then
echo "ERROR: Failed to resolve required build dependencies. Please review the build log." >&2
fi
return "$es"
}
build_rpm_from_gen_spec() {
local version=test_gen_spec
local sourcedir rpmdir
GEN_SPEC=yes \
USE_DEFAULT_DIRS=yes \
SPDK_VERSION="$version" \
"$rootdir/rpmbuild/rpm.sh" --with-shared > "$builddir/gen-spdk.spec"
# Default locations should be in use.
sourcedir=$(rpm --eval "%{_sourcedir}") rpmdir=$(rpm --eval "%{_rpmdir}")
mkdir -p "$sourcedir" "$rpmdir"
# Prepare the source at the default location - default %prep step requires
# extra dir inside the source package hence the dance with symlinking to
# the repo (after the extraction source should be under spdk-$version/) -
# make sure symlinking is done outside of the repo to avoid nasty loops.
ln -s "$rootdir" "/tmp/spdk-$version"
tar -czhf "$sourcedir/spdk-$version.tar.gz" -C /tmp "spdk-$version"
# See rpm.sh for details on the PYTHONPATH HACK
PYTHONPATH="$(python3 -c "import sys; print('%s' % ':'.join(sys.path)[1:])")" \
rpmbuild -ba "$builddir/gen-spdk.spec"
install_uninstall_rpms "$rpmdir"
}
build_shared_native_dpdk_rpm() {
build_rpm --with-shared --with-dpdk="$SPDK_RUN_EXTERNAL_DPDK"
}
run_test "build_shared_rpm" build_shared_rpm
if ((RUN_NIGHTLY == 1)); then
run_test "build_shared_rpm_with_rpmed_dpdk" build_rpm_with_rpmed_dpdk
run_test "build_rpm_from_gen_spec" build_rpm_from_gen_spec
if [[ -n $SPDK_TEST_NATIVE_DPDK ]]; then
run_test "build_shared_native_dpdk_rpm" build_shared_native_dpdk_rpm
fi
fi
rm -rf "$builddir"