From 4d0abf2e58334fa06704abb9e7f00f1d6a0ce72e Mon Sep 17 00:00:00 2001 From: Ritesh Raj Sarraf Date: Wed, 27 Mar 2024 18:59:16 +0530 Subject: [PATCH] Invoke tests with verbose logging Invoke apt update initially Because the github runner image could be without any metadata indices --- tests/apt-offline-tests-github.sh | 108 ++++++++++++-------------- tests/apt-offline-tests.sh | 121 ++++++++++++------------------ 2 files changed, 93 insertions(+), 136 deletions(-) diff --git a/tests/apt-offline-tests-github.sh b/tests/apt-offline-tests-github.sh index 8536a1a..8c16144 100755 --- a/tests/apt-offline-tests-github.sh +++ b/tests/apt-offline-tests-github.sh @@ -13,6 +13,12 @@ BUNDLE_FILE="$DIR/bundle-file.zip" THREADS=5 APT_OFFLINE="./apt-offline " +run() +{ + echo "Executing command: $1" + $1 +} + set_features () { if [ ! -z $1 ]; then URI=$1 @@ -21,41 +27,31 @@ set_features () { # Needs root APT_OFFLINE="sudo $APT_OFFLINE" - echo "Executing command 'set $URI --simulate '" - $APT_OFFLINE set $URI --simulate --update --upgrade + run "sudo apt update" - echo "Executing command 'set $URI --update'" - $APT_OFFLINE set $URI --update + run "$APT_OFFLINE set $URI --simulate --update --upgrade" - echo "Executing command 'set $URI --upgrade'" - $APT_OFFLINE set $URI --upgrade + run "$APT_OFFLINE set $URI --update" - echo "Executing command 'set $URI --update --upgrade'" - $APT_OFFLINE set $URI --update --upgrade + run "$APT_OFFLINE set $URI --upgrade" - echo "Executing command 'set $URI --update --upgrade --upgrade-type upgrade'" - $APT_OFFLINE set $URI --update --upgrade --upgrade-type upgrade + run "$APT_OFFLINE set $URI --update --upgrade" - echo "Executing command 'set $URI --update --upgrade --upgrade-type upgrade --release $RELEASE'" - $APT_OFFLINE set $URI --update --upgrade --upgrade-type upgrade --release $RELEASE + run "$APT_OFFLINE set $URI --update --upgrade --upgrade-type upgrade" - echo "Executing command 'set $URI --install-packages $DISLIKED_PACKAGES'" - $APT_OFFLINE set $URI --install-packages $DISLIKED_PACKAGES + run "$APT_OFFLINE set $URI --update --upgrade --upgrade-type upgrade --release $RELEASE" - echo "Executing command 'set $URI --install-packages $DISLIKED_PACKAGES --release $RELEASE'" - $APT_OFFLINE set $URI --install-packages $DISLIKED_PACKAGES --release $RELEASE + run "$APT_OFFLINE set $URI --install-packages $DISLIKED_PACKAGES" - echo "Executing command 'set $URI --install-src-packages $DISLIKED_SRC_PACKAGES'" - $APT_OFFLINE set $URI --install-src-packages $DISLIKED_SRC_PACKAGES + run "$APT_OFFLINE set $URI --install-packages $DISLIKED_PACKAGES --release $RELEASE" - echo "Executing command 'set $URI --install-src-packages $DISLIKED_SRC_PACKAGES --release $RELEASE'" - $APT_OFFLINE set $URI --install-src-packages $DISLIKED_SRC_PACKAGES --release $RELEASE + run "$APT_OFFLINE set $URI --install-src-packages $DISLIKED_SRC_PACKAGES" - echo "Executing command 'set $URI --src-build-dep --install-src-packages $DISLIKED_SRC_PACKAGES'" - $APT_OFFLINE set $URI --src-build-dep --install-src-packages $DISLIKED_SRC_PACKAGES + run "$APT_OFFLINE set $URI --install-src-packages $DISLIKED_SRC_PACKAGES --release $RELEASE" - echo "Executing command 'set $URI --src-build-dep --install-src-packages $DISLIKED_SRC_PACKAGES --release $RELEASE'" - $APT_OFFLINE set $URI --src-build-dep --install-src-packages $DISLIKED_SRC_PACKAGES --release $RELEASE + run "$APT_OFFLINE set $URI --src-build-dep --install-src-packages $DISLIKED_SRC_PACKAGES" + + run "$APT_OFFLINE set $URI --src-build-dep --install-src-packages $DISLIKED_SRC_PACKAGES --release $RELEASE" } @@ -63,31 +59,27 @@ get_features () { if [ ! -z $1 ]; then URI=$1 fi - echo "Executing command 'get $URI '" - $APT_OFFLINE get $URI --quiet --bundle $BUNDLE_FILE + + run "sudo apt update" + + run "$APT_OFFLINE get $URI --quiet --bundle $BUNDLE_FILE" rm -f $BUNDLE_FILE - echo "Executing command 'get $URI --threads $THREADS'" - $APT_OFFLINE get $URI --quiet --threads $THREADS --bundle $BUNDLE_FILE + run "$APT_OFFLINE get $URI --quiet --threads $THREADS --bundle $BUNDLE_FILE" rm -f $BUNDLE_FILE - echo "Executing command 'get $URI --threads $THREADS --socket-timeout 30'" - $APT_OFFLINE get $URI --quiet --threads $THREADS --socket-timeout 30 --bundle $BUNDLE_FILE --bug-reports + run "$APT_OFFLINE get $URI --quiet --threads $THREADS --socket-timeout 30 --bundle $BUNDLE_FILE --bug-reports" - echo "Executing command 'get $URI --threads $THREADS -d $DOWNLOAD_DIR'" - $APT_OFFLINE get $URI --quiet --threads $THREADS -d $DOWNLOAD_DIR + run "$APT_OFFLINE get $URI --quiet --threads $THREADS -d $DOWNLOAD_DIR" rm -rf $DOWNLOAD_DIR - echo "Executing command 'get $URI --threads $THREADS -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR'" - $APT_OFFLINE get $URI --quiet --threads $THREADS -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR + run "$APT_OFFLINE get $URI --quiet --threads $THREADS -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR" rm -rf $DOWNLOAD_DIR - echo "Executing command 'get $URI --no-checksum -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR'" - $APT_OFFLINE get $URI --quiet --no-checksum -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR + run "$APT_OFFLINE get $URI --quiet --no-checksum -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR" rm -rf $DOWNLOAD_DIR - echo "Executing command 'get $URI --bug-reports --threads $THREADS -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR'" - $APT_OFFLINE get $URI --quiet --threads $THREADS --bug-reports -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR + run "$APT_OFFLINE get $URI --quiet --threads $THREADS --bug-reports -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR" } @@ -100,17 +92,15 @@ install_features () { # Needs root APT_OFFLINE="sudo $APT_OFFLINE" - echo "Executing command 'install $DOWNLOAD_DIR --skip-bug-reports'" - $APT_OFFLINE install $DOWNLOAD_DIR --skip-bug-reports + run "sudo apt update" + + run "$APT_OFFLINE install $DOWNLOAD_DIR --skip-bug-reports" - echo "Executing command 'install $DOWNLOAD_DIR --skip-bug-reports --allow-unauthenticated'" - $APT_OFFLINE install $DOWNLOAD_DIR --skip-bug-reports --allow-unauthenticated + run "$APT_OFFLINE install $DOWNLOAD_DIR --skip-bug-reports --allow-unauthenticated" - echo "Executing command 'install $BUNDLE_FILE --skip-bug-reports'" - $APT_OFFLINE install $BUNDLE_FILE --skip-bug-reports + run "$APT_OFFLINE install $BUNDLE_FILE --skip-bug-reports" - echo "Executing command 'install $BUNDLE_FILE --skip-bug-reports --allow-unauthenticated'" - $APT_OFFLINE install $BUNDLE_FILE --skip-bug-reports --allow-unauthenticated + run "$APT_OFFLINE install $BUNDLE_FILE --skip-bug-reports --allow-unauthenticated" } install_features_prompt () { @@ -122,29 +112,23 @@ install_features_prompt () { # Needs root APT_OFFLINE="sudo $APT_OFFLINE" - echo "Executing command 'install $DOWNLOAD_DIR '" - $APT_OFFLINE install $DOWNLOAD_DIR + run "sudo apt update" + + run "$APT_OFFLINE install $DOWNLOAD_DIR" - echo "Executing command 'install $DOWNLOAD_DIR --simulate'" - $APT_OFFLINE install $DOWNLOAD_DIR --simulate + run "$APT_OFFLINE install $DOWNLOAD_DIR --simulate" - echo "Executing command 'install $DOWNLOAD_DIR'" - $APT_OFFLINE install $DOWNLOAD_DIR --simulate + run "$APT_OFFLINE install $DOWNLOAD_DIR --simulate" - echo "Executing command 'install $DOWNLOAD_DIR --allow-unauthenticated'" - $APT_OFFLINE install $DOWNLOAD_DIR --simulate --allow-unauthenticated + run "$APT_OFFLINE install $DOWNLOAD_DIR --simulate --allow-unauthenticated" - echo "Executing command 'install $BUNDLE_FILE '" - $APT_OFFLINE install $BUNDLE_FILE + run "$APT_OFFLINE install $BUNDLE_FILE" - echo "Executing command 'install $BUNDLE_FILE --simulate'" - $APT_OFFLINE install $BUNDLE_FILE --simulate + run "$APT_OFFLINE install $BUNDLE_FILE --simulate" - echo "Executing command 'install $BUNDLE_FILE'" - $APT_OFFLINE install $BUNDLE_FILE --simulate + run "$APT_OFFLINE install $BUNDLE_FILE --simulate" - echo "Executing command 'install $BUNDLE_FILE --allow-unauthenticated'" - $APT_OFFLINE install $BUNDLE_FILE --simulate --allow-unauthenticated + run "$APT_OFFLINE install $BUNDLE_FILE --simulate --allow-unauthenticated" } all_features () { diff --git a/tests/apt-offline-tests.sh b/tests/apt-offline-tests.sh index 92f2d98..c8c3f65 100755 --- a/tests/apt-offline-tests.sh +++ b/tests/apt-offline-tests.sh @@ -12,48 +12,42 @@ BUNDLE_FILE="$DIR/bundle-file.zip" THREADS=5 APT_OFFLINE="./apt-offline " +run() +{ + echo "Executing command: $1" + $1 +} + set_features () { if [ ! -z $1 ]; then URI=$1 fi - echo "Executing command 'set $URI'" - $APT_OFFLINE set $URI - echo "Executing command 'set $URI --simulate '" - $APT_OFFLINE set $URI --simulate + run "$APT_OFFLINE set $URI" + + run "$APT_OFFLINE set $URI --simulate" - echo "Executing command 'set $URI --update'" - $APT_OFFLINE set $URI --update + run "$APT_OFFLINE set $URI --update" - echo "Executing command 'set $URI --upgrade'" - $APT_OFFLINE set $URI --upgrade + run "$APT_OFFLINE set $URI --upgrade" - echo "Executing command 'set $URI --update --upgrade'" - $APT_OFFLINE set $URI --update --upgrade + run "$APT_OFFLINE set $URI --update --upgrade" - echo "Executing command 'set $URI --update --upgrade --upgrade-type upgrade'" - $APT_OFFLINE set $URI --update --upgrade --upgrade-type upgrade + run "$APT_OFFLINE set $URI --update --upgrade --upgrade-type upgrade" - echo "Executing command 'set $URI --update --upgrade --upgrade-type upgrade --release $RELEASE'" - $APT_OFFLINE set $URI --update --upgrade --upgrade-type upgrade --release $RELEASE + run "$APT_OFFLINE set $URI --update --upgrade --upgrade-type upgrade --release $RELEASE" - echo "Executing command 'set $URI --install-packages $DISLIKED_PACKAGES'" - $APT_OFFLINE set $URI --install-packages $DISLIKED_PACKAGES + run "$APT_OFFLINE set $URI --install-packages $DISLIKED_PACKAGES" - echo "Executing command 'set $URI --install-packages $DISLIKED_PACKAGES --release $RELEASE'" - $APT_OFFLINE set $URI --install-packages $DISLIKED_PACKAGES --release $RELEASE + run "$APT_OFFLINE set $URI --install-packages $DISLIKED_PACKAGES --release $RELEASE" - echo "Executing command 'set $URI --install-src-packages $DISLIKED_PACKAGES'" - $APT_OFFLINE set $URI --install-src-packages $DISLIKED_PACKAGES + run "$APT_OFFLINE set $URI --install-src-packages $DISLIKED_PACKAGES" - echo "Executing command 'set $URI --install-src-packages $DISLIKED_PACKAGES --release $RELEASE'" - $APT_OFFLINE set $URI --install-src-packages $DISLIKED_PACKAGES --release $RELEASE + run "$APT_OFFLINE set $URI --install-src-packages $DISLIKED_PACKAGES --release $RELEASE" - echo "Executing command 'set $URI --src-build-dep --install-src-packages $DISLIKED_PACKAGES'" - $APT_OFFLINE set $URI --src-build-dep --install-src-packages $DISLIKED_PACKAGES + run "$APT_OFFLINE set $URI --src-build-dep --install-src-packages $DISLIKED_PACKAGES" - echo "Executing command 'set $URI --src-build-dep --install-src-packages $DISLIKED_PACKAGES --release $RELEASE'" - $APT_OFFLINE set $URI --src-build-dep --install-src-packages $DISLIKED_PACKAGES --release $RELEASE + run "$APT_OFFLINE set $URI --src-build-dep --install-src-packages $DISLIKED_PACKAGES --release $RELEASE" } @@ -61,29 +55,22 @@ get_features () { if [ ! -z $1 ]; then URI=$1 fi - echo "Executing command 'get $URI '" - $APT_OFFLINE get $URI - echo "Executing command 'get $URI --threads $THREADS'" - $APT_OFFLINE get $URI --threads $THREADS + run "$APT_OFFLINE get $URI" - echo "Executing command 'get $URI --threads $THREADS --socket-timeout 30'" - $APT_OFFLINE get $URI --threads $THREADS --socket-timeout 30 + run "$APT_OFFLINE get $URI --threads $THREADS" - echo "Executing command 'get $URI --threads $THREADS -d $DOWNLOAD_DIR'" - $APT_OFFLINE get $URI --threads $THREADS -d $DOWNLOAD_DIR + run "$APT_OFFLINE get $URI --threads $THREADS --socket-timeout 30" - echo "Executing command 'get $URI --threads $THREADS -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR'" - $APT_OFFLINE get $URI --threads $THREADS -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR + run "$APT_OFFLINE get $URI --threads $THREADS -d $DOWNLOAD_DIR" - echo "Executing command 'get $URI --no-checksum -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR'" - $APT_OFFLINE get $URI --no-checksum -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR + run "$APT_OFFLINE get $URI --threads $THREADS -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR" - echo "Executing command 'get $URI --bug-reports --threads $THREADS -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR'" - $APT_OFFLINE get $URI --threads $THREADS --bug-reports -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR + run "$APT_OFFLINE get $URI --no-checksum -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR" - echo "Executing command 'get $URI --bug-reports --threads $THREADS --bundle $BUNDLE_FILE -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR'" - $APT_OFFLINE get $URI --threads $THREADS --bug-reports -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR --bundle $BUNDLE_FILE + run "$APT_OFFLINE get $URI --threads $THREADS --bug-reports -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR" + + run "$APT_OFFLINE get $URI --threads $THREADS --bug-reports -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR --bundle $BUNDLE_FILE" } @@ -92,29 +79,22 @@ install_features () { DOWNLOAD_DIR=$1 BUNDLE_FILE=$1 fi - echo "Executing command 'install $DOWNLOAD_DIR --skip-bug-reports'" - $APT_OFFLINE install $DOWNLOAD_DIR --skip-bug-reports - echo "Executing command 'install $DOWNLOAD_DIR --simulate --skip-bug-reports'" - $APT_OFFLINE install $DOWNLOAD_DIR --simulate --skip-bug-reports + run "$APT_OFFLINE install $DOWNLOAD_DIR --skip-bug-reports" + + run "$APT_OFFLINE install $DOWNLOAD_DIR --simulate --skip-bug-reports" - echo "Executing command 'install $DOWNLOAD_DIR --skip-bug-reports'" - $APT_OFFLINE install $DOWNLOAD_DIR --simulate --skip-bug-reports + run "$APT_OFFLINE install $DOWNLOAD_DIR --simulate --skip-bug-reports" - echo "Executing command 'install $DOWNLOAD_DIR --skip-bug-reports --allow-unauthenticated'" - $APT_OFFLINE install $DOWNLOAD_DIR --simulate --skip-bug-reports --allow-unauthenticated + run "$APT_OFFLINE install $DOWNLOAD_DIR --simulate --skip-bug-reports --allow-unauthenticated" - echo "Executing command 'install $BUNDLE_FILE --skip-bug-reports'" - $APT_OFFLINE install $BUNDLE_FILE --skip-bug-reports + run "$APT_OFFLINE install $BUNDLE_FILE --skip-bug-reports" - echo "Executing command 'install $BUNDLE_FILE --simulate --skip-bug-reports'" - $APT_OFFLINE install $BUNDLE_FILE --simulate --skip-bug-reports + run "$APT_OFFLINE install $BUNDLE_FILE --simulate --skip-bug-reports" - echo "Executing command 'install $BUNDLE_FILE --skip-bug-reports'" - $APT_OFFLINE install $BUNDLE_FILE --simulate --skip-bug-reports + run "$APT_OFFLINE install $BUNDLE_FILE --simulate --skip-bug-reports" - echo "Executing command 'install $BUNDLE_FILE --skip-bug-reports --allow-unauthenticated'" - $APT_OFFLINE install $BUNDLE_FILE --simulate --skip-bug-reports --allow-unauthenticated + run "$APT_OFFLINE install $BUNDLE_FILE --simulate --skip-bug-reports --allow-unauthenticated" } install_features_prompt () { @@ -122,29 +102,22 @@ install_features_prompt () { DOWNLOAD_DIR=$1 BUNDLE_FILE=$1 fi - echo "Executing command 'install $DOWNLOAD_DIR '" - $APT_OFFLINE install $DOWNLOAD_DIR - echo "Executing command 'install $DOWNLOAD_DIR --simulate'" - $APT_OFFLINE install $DOWNLOAD_DIR --simulate + run "$APT_OFFLINE install $DOWNLOAD_DIR" + + run "$APT_OFFLINE install $DOWNLOAD_DIR --simulate" - echo "Executing command 'install $DOWNLOAD_DIR'" - $APT_OFFLINE install $DOWNLOAD_DIR --simulate + run "$APT_OFFLINE install $DOWNLOAD_DIR --simulate" - echo "Executing command 'install $DOWNLOAD_DIR --allow-unauthenticated'" - $APT_OFFLINE install $DOWNLOAD_DIR --simulate --allow-unauthenticated + run "$APT_OFFLINE install $DOWNLOAD_DIR --simulate --allow-unauthenticated" - echo "Executing command 'install $BUNDLE_FILE '" - $APT_OFFLINE install $BUNDLE_FILE + run "$APT_OFFLINE install $BUNDLE_FILE" - echo "Executing command 'install $BUNDLE_FILE --simulate'" - $APT_OFFLINE install $BUNDLE_FILE --simulate + run "$APT_OFFLINE install $BUNDLE_FILE --simulate" - echo "Executing command 'install $BUNDLE_FILE'" - $APT_OFFLINE install $BUNDLE_FILE --simulate + run "$APT_OFFLINE install $BUNDLE_FILE --simulate" - echo "Executing command 'install $BUNDLE_FILE --allow-unauthenticated'" - $APT_OFFLINE install $BUNDLE_FILE --simulate --allow-unauthenticated + run "$APT_OFFLINE install $BUNDLE_FILE --simulate --allow-unauthenticated" } all_features () {