aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2021-01-19 09:22:50 +0100
committerOliver Smith <osmith@sysmocom.de>2021-01-20 14:28:25 +0100
commit2c8767a5c75593e75522f4daa5f87560887cfd87 (patch)
treee00eeab1ed549189a9a2637df19bc431994e173b
parent14c04c4296e05d902b8d239de87302f278ed3a66 (diff)
repo-install-test: add test_conflict
Install one Osmocom package from one package feed and attempt to install a second package from a different feed. Verify that the package manager exits with error and mentions the conflict in its output. Related: OS#4733 Change-Id: Icf2a3a1d1de2ff42b1dc9aadf2075e5e1ff40291
-rwxr-xr-xscripts/repo-install-test.sh21
-rwxr-xr-xscripts/repo-install-test/run-inside-docker.sh86
2 files changed, 107 insertions, 0 deletions
diff --git a/scripts/repo-install-test.sh b/scripts/repo-install-test.sh
index 71e55d7..7585509 100755
--- a/scripts/repo-install-test.sh
+++ b/scripts/repo-install-test.sh
@@ -3,6 +3,7 @@
# * INTERACTIVE: set to 1 to keep an interactive shell open after the script ran (for debugging)
# * FEED: binary package feed (e.g. "latest", "nightly")
# * PROJ: OBS project namespace (e.g. "network:osmocom:latest")
+# * PROJ_CONFLICT: Conflicting OBS project namespace (e.g. "network:osmocom:nightly")
# * KEEP_CACHE: set to 1 to keep downloaded binary packages (for development)
# * TESTS: which tests to run (all by default, see below for possible values)
. "$(dirname "$0")/common.sh"
@@ -23,12 +24,31 @@ CONTAINER="$DISTRO-repo-install-test-$FEED"
if [ -z "$TESTS" ]; then
TESTS="
+ test_conflict
install_repo_packages
test_binaries
services_check
"
fi
+if [ -z "$PROJ_CONFLICT" ]; then
+ case "$FEED" in
+ latest)
+ PROJ_CONFLICT="network:osmocom:nightly"
+ ;;
+ nightly)
+ PROJ_CONFLICT="network:osmocom:latest"
+ if [ "$DISTRO" = "centos8" ]; then
+ # Doesn't have packages built for "latest" yet
+ PROJ_CONFLICT="network:osmocom:next"
+ fi
+ ;;
+ next)
+ PROJ_CONFLICT="network:osmocom:nightly"
+ ;;
+ esac
+fi
+
# Try to run "systemctl status" 10 times, kill the container on failure
check_if_systemd_is_running() {
for i in $(seq 1 10); do
@@ -66,6 +86,7 @@ docker run --rm \
--name "$CONTAINER" \
-e FEED="$FEED" \
-e PROJ="$PROJ" \
+ -e PROJ_CONFLICT="$PROJ_CONFLICT" \
-e DISTRO="$DISTRO" \
-e TESTS="$TESTS" \
-e container=docker \
diff --git a/scripts/repo-install-test/run-inside-docker.sh b/scripts/repo-install-test/run-inside-docker.sh
index 79dd3cf..f7d1449 100755
--- a/scripts/repo-install-test/run-inside-docker.sh
+++ b/scripts/repo-install-test/run-inside-docker.sh
@@ -2,6 +2,7 @@
# Environment variables:
# * FEED: binary package feed (e.g. "latest", "nightly")
# * PROJ: OBS project namespace (e.g. "network:osmocom:latest")
+# * PROJ_CONFLICT: Conflicting OBS project namespace (e.g. "network:osmocom:nightly")
# * KEEP_CACHE: set to 1 to keep downloaded binary packages (for development)
# * DISTRO: linux distribution name (e.g. "debian", "centos")
# * TESTS: which tests to run (see repo-install-test.sh)
@@ -59,6 +60,12 @@ check_env() {
echo "ERROR: missing environment variable \$PROJ!"
exit 1
fi
+ if [ -n "$PROJ_CONFLICT" ]; then
+ echo "Checking conflicting project: $PROJ_CONFLICT"
+ else
+ echo "ERROR: missing environment variable \$PROJ_CONFLICT!"
+ exit 1
+ fi
if [ -n "$DISTRO" ]; then
echo "Linux distribution: $DISTRO"
else
@@ -92,6 +99,12 @@ configure_osmocom_repo_debian() {
}
# $1: OBS project (e.g. "network:osmocom:nightly")
+configure_osmocom_repo_debian_remove() {
+ local proj="$1"
+ rm "/etc/apt/sources.list.d/$proj.list"
+}
+
+# $1: OBS project (e.g. "network:osmocom:nightly")
configure_osmocom_repo_centos8() {
local proj="$1"
local baseurl="https://download.opensuse.org/repositories/$(proj_with_slashes "$proj")/CentOS_8"
@@ -110,6 +123,12 @@ enabled=1
EOF
}
+# $1: OBS project (e.g. "network:osmocom:nightly")
+configure_osmocom_repo_centos8_remove() {
+ local proj="$1"
+ rm "/etc/yum.repos.d/$proj.repo"
+}
+
configure_keep_cache_debian() {
if [ -z "$KEEP_CACHE" ]; then
return
@@ -130,6 +149,70 @@ configure_keep_cache_centos8() {
echo "keepcache=1" >> /etc/dnf/dnf.conf
}
+# $1: file
+# $2-n: patterns to look for in file with grep
+find_patterns_or_exit() {
+ local file="$1"
+ local pattern
+ shift
+
+ for pattern in "$@"; do
+ if grep -q "$pattern" "$file"; then
+ continue
+ fi
+
+ echo "ERROR: could not find pattern '$pattern' in file '$file'!"
+ exit 1
+ done
+}
+
+test_conflict_debian() {
+ apt-get -y install libosmocore
+
+ configure_osmocom_repo_debian_remove "$PROJ"
+ configure_osmocom_repo_debian "$PROJ_CONFLICT"
+
+ (apt-get -y install osmo-mgw 2>&1 && touch /tmp/fail) | tee /tmp/out
+
+ if [ -e /tmp/fail ]; then
+ echo "ERROR: unexpected exit 0!"
+ exit 1
+ fi
+
+ find_patterns_or_exit \
+ /tmp/out \
+ "requested an impossible situation" \
+ "^The following packages have unmet dependencies:" \
+ "Depends: osmocom-" \
+ "but it is not going to be installed"
+
+ configure_osmocom_repo_debian_remove "$PROJ_CONFLICT"
+ configure_osmocom_repo_debian "$PROJ"
+}
+
+test_conflict_centos8() {
+ dnf -y install libosmocore-devel
+
+ configure_osmocom_repo_centos8_remove "$PROJ"
+ configure_osmocom_repo_centos8 "$PROJ_CONFLICT"
+
+ (dnf -y install osmo-mgw 2>&1 && touch /tmp/fail) | tee /tmp/out
+
+ if [ -e /tmp/fail ]; then
+ echo "ERROR: unexpected exit 0!"
+ exit 1
+ fi
+
+ find_patterns_or_exit \
+ /tmp/out \
+ "^Error:" \
+ "but none of the providers can be installed" \
+ "conflicts with osmocom-"
+
+ configure_osmocom_repo_centos8_remove "$PROJ_CONFLICT"
+ configure_osmocom_repo_centos8 "$PROJ"
+}
+
# Filter $PWD/osmocom_packages_all.txt through a blacklist_$DISTRO.txt and store the result in
# $PWD/osmocom_packages.txt.
filter_packages_txt() {
@@ -259,6 +342,9 @@ for test in $TESTS; do
set -x
case "$test" in
+ test_conflict)
+ test_conflict_${DISTRO}
+ ;;
install_repo_packages)
install_repo_packages_${DISTRO}
;;