summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2024-07-08 12:57:18 +0000
committerDavid Kalnischkies <david@kalnischkies.de>2024-07-08 14:12:37 +0000
commit99ec5c955b0e8583bfd93400803caa992bcc1189 (patch)
treeb775406444829f022a2837fc0ea1fccbcf9c07bd /test
parent31100f35b97663a3d180bd57b616dcc5cb425795 (diff)
Parse snapshot option for apt show/list
The option is supported by the command (as this is done by a bit more low level code), but the command line parsing did not expect them to be used for the apt show & list command, so that it would report error. As such, a workaround for this issue is to use: -o APT::Snapshot=BANANA instead of e.g. -S BANANA Closes: #1075819
Diffstat (limited to 'test')
-rwxr-xr-xtest/integration/test-snapshot19
-rwxr-xr-xtest/integration/test-snapshot-upgrades156
2 files changed, 168 insertions, 7 deletions
diff --git a/test/integration/test-snapshot b/test/integration/test-snapshot
index 26ef5a721..31a02cac0 100755
--- a/test/integration/test-snapshot
+++ b/test/integration/test-snapshot
@@ -66,7 +66,7 @@ testsuccessequal "'http://localhost:${APTHTTPPORT}/dists/stable/InRelease' local
'http://localhost:${APTHTTPPORT}/dists/stable/main/binary-all/Packages.xz' localhost:${APTHTTPPORT}_dists_stable_main_binary-all_Packages 0
'http://localhost:${APTHTTPPORT}/dists/stable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris
-for option in -S --snapshot; do
+for option in '-S' '-S ' '--snapshot ' '--snapshot=' '-o APT::Snapshot='; do
testsuccessequal "'https://snapshot.debian.org/archive/debian/BANANA/dists/stable/InRelease' snapshot.debian.org_archive_debian_BANANA_dists_stable_InRelease 0
'https://snapshot.debian.org/archive/debian/BANANA/dists/stable/main/source/Sources.xz' snapshot.debian.org_archive_debian_BANANA_dists_stable_main_source_Sources 0
'https://snapshot.debian.org/archive/debian/BANANA/dists/stable/main/binary-amd64/Packages.xz' snapshot.debian.org_archive_debian_BANANA_dists_stable_main_binary-amd64_Packages 0
@@ -76,7 +76,7 @@ testsuccessequal "'https://snapshot.debian.org/archive/debian/BANANA/dists/stabl
'http://localhost:${APTHTTPPORT}/dists/stable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_stable_main_source_Sources 0
'http://localhost:${APTHTTPPORT}/dists/stable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_stable_main_binary-amd64_Packages 0
'http://localhost:${APTHTTPPORT}/dists/stable/main/binary-all/Packages.xz' localhost:${APTHTTPPORT}_dists_stable_main_binary-all_Packages 0
-'http://localhost:${APTHTTPPORT}/dists/stable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris $option BANANA
+'http://localhost:${APTHTTPPORT}/dists/stable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris ${option}BANANA
done
@@ -93,6 +93,12 @@ Get:6 http://localhost:${APTHTTPPORT}/snapshot/BANANA stable/main Translation-en
Reading package lists..." \
aptget update -o Acquire::Snapshots::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/snapshot/@SNAPSHOTID@/" -SBANANA
+for option in '-S' '-S ' '--snapshot ' '--snapshot=' '-o APT::Snapshot='; do
+ testsuccessequal 'Listing...' apt list --upgradable -o Acquire::Snapshots::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/snapshot/@SNAPSHOTID@/" ${option}BANANA
+ testsuccessequal 'Listing...
+awesome/stable 42 amd64' apt list awesome -o Acquire::Snapshots::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/snapshot/@SNAPSHOTID@/" ${option}BANANA
+done
+
msgmsg "Cache constructed without snapshot"
testsuccessequal "Package files:
500 http://localhost:${APTHTTPPORT} stable/main all Packages
@@ -102,7 +108,7 @@ testsuccessequal "Package files:
release o=Debian,a=stable,n=stable,l=Testcases,c=main,b=amd64
origin localhost
Pinned packages:" \
- aptcache policy -o Acquire::Snapshots::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/snapshot/@SNAPSHOTID@/"
+ aptcache policy -o Acquire::Snapshots::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/snapshot/@SNAPSHOTID@/"
testsuccessequal "'http://localhost:${APTHTTPPORT}/pool/awesome_42_amd64.deb' awesome_42_amd64.deb $(stat -c %s aptarchive/pool/awesome_42_amd64.deb) " \
aptget install --print-uris -qq awesome
@@ -121,7 +127,6 @@ Pinned packages:" \
testsuccessequal "'http://localhost:${APTHTTPPORT}/snapshot/BANANA/pool/awesome_42_amd64.deb' awesome_42_amd64.deb $(stat -c %s aptarchive/pool/awesome_42_amd64.deb) " \
aptget install --print-uris -qq awesome -o Acquire::Snapshots::URI::Label::Testcases="http://localhost:${APTHTTPPORT}/snapshot/@SNAPSHOTID@/" -SBANANA
-
msgmsg "Origin: Ubuntu"
releasechanger 'Origin' 'Ubuntu'
testsuccessequal "'https://snapshot.ubuntu.com/ubuntu/BANANA/dists/stable/InRelease' snapshot.ubuntu.com_ubuntu_BANANA_dists_stable_InRelease 0
@@ -133,7 +138,7 @@ testsuccessequal "'https://snapshot.ubuntu.com/ubuntu/BANANA/dists/stable/InRele
'http://localhost:${APTHTTPPORT}/dists/stable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_stable_main_source_Sources 0
'http://localhost:${APTHTTPPORT}/dists/stable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_stable_main_binary-amd64_Packages 0
'http://localhost:${APTHTTPPORT}/dists/stable/main/binary-all/Packages.xz' localhost:${APTHTTPPORT}_dists_stable_main_binary-all_Packages 0
-'http://localhost:${APTHTTPPORT}/dists/stable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris $option BANANA
+'http://localhost:${APTHTTPPORT}/dists/stable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris -S BANANA
msgmsg "Label: Debian"
releasechanger 'Label' 'Debian'
@@ -146,7 +151,7 @@ testsuccessequal "'https://snapshot.ubuntu.com/ubuntu/BANANA/dists/stable/InRele
'http://localhost:${APTHTTPPORT}/dists/stable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_stable_main_source_Sources 0
'http://localhost:${APTHTTPPORT}/dists/stable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_stable_main_binary-amd64_Packages 0
'http://localhost:${APTHTTPPORT}/dists/stable/main/binary-all/Packages.xz' localhost:${APTHTTPPORT}_dists_stable_main_binary-all_Packages 0
-'http://localhost:${APTHTTPPORT}/dists/stable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris $option BANANA
+'http://localhost:${APTHTTPPORT}/dists/stable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris -S BANANA
testsuccessequal "'http://localhost:${APTHTTPPORT}/dists/stable/InRelease' localhost:${APTHTTPPORT}_dists_stable_InRelease 0
'http://localhost:${APTHTTPPORT}/snapshot/BANANA/dists/stable/InRelease' localhost:${APTHTTPPORT}_snapshot_BANANA_dists_stable_InRelease 0
@@ -171,7 +176,7 @@ testsuccessequal "'https://example.org/snapshots//BANANA/dists/stable/InRelease'
'http://localhost:${APTHTTPPORT}/dists/stable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_stable_main_source_Sources 0
'http://localhost:${APTHTTPPORT}/dists/stable/main/binary-amd64/Packages.xz' localhost:${APTHTTPPORT}_dists_stable_main_binary-amd64_Packages 0
'http://localhost:${APTHTTPPORT}/dists/stable/main/binary-all/Packages.xz' localhost:${APTHTTPPORT}_dists_stable_main_binary-all_Packages 0
-'http://localhost:${APTHTTPPORT}/dists/stable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris $option BANANA -o Acquire::Snapshots::URI::Host::localhost="https://example.org/snapshots/@PATH@/@SNAPSHOTID@/"
+'http://localhost:${APTHTTPPORT}/dists/stable/main/i18n/Translation-en.xz' localhost:${APTHTTPPORT}_dists_stable_main_i18n_Translation-en 0 " aptget update --print-uris -S BANANA -o Acquire::Snapshots::URI::Host::localhost="https://example.org/snapshots/@PATH@/@SNAPSHOTID@/"
msgmsg "Snapshots: set in the InRelease file"
sed -i '/^Origin: / a\
diff --git a/test/integration/test-snapshot-upgrades b/test/integration/test-snapshot-upgrades
new file mode 100755
index 000000000..d5e8006b7
--- /dev/null
+++ b/test/integration/test-snapshot-upgrades
@@ -0,0 +1,156 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+
+setupenvironment
+configarchitecture 'amd64'
+
+for T in T1 T2; do
+ mkdir "aptarchive/${T}"
+ ln -s ../../incoming "aptarchive/${T}/pool"
+done
+
+buildsimplenativepackage 'awesome' 'amd64' '2' 'stable' 'Depends: libfoo (>= 2)'
+buildsimplenativepackage 'libfoo' 'amd64' '2' 'stable'
+setupaptarchive --no-update
+mv aptarchive/dists aptarchive/T1
+rm incoming/stable.main.pkglist incoming/stable.main.srclist
+
+buildsimplenativepackage 'awesome' 'amd64' '3' 'stable' 'Depends: libfoo (>= 2)'
+setupaptarchive --no-update
+mv aptarchive/dists aptarchive/T2
+rm incoming/stable.main.pkglist incoming/stable.main.srclist
+
+buildsimplenativepackage 'libfoo' 'amd64' '42' 'stable'
+buildsimplenativepackage 'awesome' 'amd64' '42' 'stable'
+setupaptarchive --no-update
+
+changetowebserver
+sed -i 's/http:/[snapshot=enable] http:/' rootdir/etc/apt/sources.list.d/*
+echo "Acquire::Snapshots::URI::Host::localhost \"http://localhost:${APTHTTPPORT}/@SNAPSHOTID@/\";" > rootdir/etc/apt/apt.conf.d/snapshot.conf
+testsuccess aptget update --snapshot T1
+testsuccess aptget update --snapshot T2 --no-list-cleanup
+
+insertinstalledpackage 'awesome' 'amd64' '1' 'Depends: libfoo (>= 1)'
+insertinstalledpackage 'libfoo' 'amd64' '1'
+
+msgmsg 'Snapshotting policy'
+testsuccessequal "libfoo:
+ Installed: 1
+ Candidate: 42
+ Version table:
+ 42 500
+ 500 http://localhost:${APTHTTPPORT} stable/main amd64 Packages
+ *** 1 100
+ 100 ${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status
+awesome:
+ Installed: 1
+ Candidate: 42
+ Version table:
+ 42 500
+ 500 http://localhost:${APTHTTPPORT} stable/main amd64 Packages
+ *** 1 100
+ 100 ${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status" apt policy libfoo awesome
+testsuccessequal "libfoo:
+ Installed: 1
+ Candidate: 2
+ Version table:
+ 2 500
+ 500 http://localhost:${APTHTTPPORT}/T1 stable/main amd64 Packages
+ *** 1 100
+ 100 ${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status
+awesome:
+ Installed: 1
+ Candidate: 2
+ Version table:
+ 2 500
+ 500 http://localhost:${APTHTTPPORT}/T1 stable/main amd64 Packages
+ *** 1 100
+ 100 ${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status" apt policy libfoo awesome -S T1
+testsuccessequal "libfoo:
+ Installed: 1
+ Candidate: 1
+ Version table:
+ *** 1 100
+ 100 ${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status
+awesome:
+ Installed: 1
+ Candidate: 3
+ Version table:
+ 3 500
+ 500 http://localhost:${APTHTTPPORT}/T2 stable/main amd64 Packages
+ *** 1 100
+ 100 ${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status" apt policy libfoo awesome -S T2
+
+
+msgmsg 'Snapshotting show'
+testsuccessequalgrep() {
+ local CMP="$1"
+ local GREP="$2"
+ shift 2
+ testsuccess "$@"
+ mv rootdir/tmp/testsuccess.output base.output
+ testsuccessequal "$CMP" grep "$GREP" base.output
+}
+testsuccessequalgrep 'Version: 42
+Version: 1
+Version: 42
+Version: 1' '^Version: ' aptcache show libfoo awesome
+testsuccessequalgrep 'Version: 2
+Version: 1
+Version: 2
+Version: 1' '^Version: ' aptcache show libfoo awesome -S T1
+testsuccessequalgrep 'Version: 1
+Version: 3
+Version: 1' '^Version: ' aptcache show libfoo awesome -S T2
+
+
+msgmsg 'Snapshotting list'
+testsuccessequal 'Listing...
+awesome/stable 42 amd64 [upgradable from: 1]
+libfoo/stable 42 amd64 [upgradable from: 1]' apt list --upgradeable
+testsuccessequal 'Listing...
+awesome/stable 2 amd64 [upgradable from: 1]
+libfoo/stable 2 amd64 [upgradable from: 1]' apt list --upgradeable -S T1
+testsuccessequal "Listing...
+awesome/stable 3 amd64 [upgradable from: 1]
+N: There is 1 additional version. Please use the '-a' switch to see it" apt list --upgradeable -S T2
+
+
+msgmsg 'Snapshotting upgrade'
+testsuccessequal 'Reading package lists...
+Building dependency tree...
+Calculating upgrade...
+The following packages will be upgraded:
+ awesome libfoo
+2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+Inst awesome [1] (42 stable [amd64])
+Inst libfoo [1] (42 stable [amd64])
+Conf awesome (42 stable [amd64])
+Conf libfoo (42 stable [amd64])' apt upgrade -s
+testsuccessequal 'Reading package lists...
+Building dependency tree...
+Calculating upgrade...
+The following packages will be upgraded:
+ awesome libfoo
+2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+Inst libfoo [1] (2 stable [amd64])
+Inst awesome [1] (2 stable [amd64])
+Conf libfoo (2 stable [amd64])
+Conf awesome (2 stable [amd64])' apt upgrade -s -S T1
+testsuccessequal 'Reading package lists...
+Building dependency tree...
+Calculating upgrade...
+The following packages have been kept back:
+ awesome
+0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.' apt upgrade -s -S T2
+
+msgmsg 'Snapshotting real installs'
+testsuccessequalgrep 'Version: 1' '^Version: ' apt show libfoo/now
+testsuccess apt install libfoo -S T1 -y
+testsuccessequalgrep 'Version: 2' '^Version: ' apt show libfoo/now
+testsuccessequalgrep 'Version: 1' '^Version: ' apt show awesome/now
+testsuccess apt upgrade -S T2 -y
+testsuccessequalgrep 'Version: 3' '^Version: ' apt show awesome/now