Change in osmo-ci[master]: repo-install-test: add test_conflict

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

osmith gerrit-no-reply at lists.osmocom.org
Wed Jan 20 13:32:30 UTC 2021


osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/22335 )


Change subject: repo-install-test: add test_conflict
......................................................................

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
---
M scripts/repo-install-test.sh
M scripts/repo-install-test/run-inside-docker.sh
2 files changed, 107 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/35/22335/1

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 @@
 
 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 @@
 		--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 @@
 		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 @@
 }
 
 # $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 @@
 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 @@
 	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 @@
 	set -x
 
 	case "$test" in
+		test_conflict)
+			test_conflict_${DISTRO}
+			;;
 		install_repo_packages)
 			install_repo_packages_${DISTRO}
 			;;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/22335
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: Icf2a3a1d1de2ff42b1dc9aadf2075e5e1ff40291
Gerrit-Change-Number: 22335
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210120/111b69f3/attachment.htm>


More information about the gerrit-log mailing list