Skip to content

Commit

Permalink
tests: Add tests for Endless compat files
Browse files Browse the repository at this point in the history
Various tests to makes sure that handling of the compat .sig and .sizes2
files works correctly on client and server sides. A repo containing only
compat files simulating an old Endless commit is included.

[endlessm/eos-shell#5083]
https://phabricator.endlessm.com/T11513

Rebase 2016.9: Squashed all the following commits together:
  tests: Add test for creating compat signature file
  tests: Check if compat sig file included in pull
  tests: Check pull behavior from old repo
  tests: Check if compat files are deleted with prune
  tests: Check GPG verification when only compat file available
  tests: Move compat-repo dist outside of conditional
  tests: Make compat-repo writable in tests directory
Rebase 2017.7 (T16919): Squash in feature test fixes which were
  previously separate patches; fix the SKIP emission to use correct
  TAP output
Rebase 2018.4 (T17367, T22022): Squash in reduction of tests for removed
  compat object handling features
  • Loading branch information
dbnicholson committed Mar 17, 2021
1 parent 7610f0c commit e727966
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Makefile-tests.am
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ _installed_or_uninstalled_test_scripts = \
tests/test-delta-ed25519.sh \
tests/test-xattrs.sh \
tests/test-auto-summary.sh \
tests/test-compat-files.sh \
tests/test-prune.sh \
tests/test-concurrency.py \
tests/test-refs.sh \
Expand Down Expand Up @@ -414,6 +415,16 @@ EXTRA_DIST += \
tests/libtest.sh \
$(NULL)

# Compat repo tests
EXTRA_DIST += tests/compat-repo
if ENABLE_INSTALLED_TESTS
install-compat-repo-hook:
mkdir -p $(DESTDIR)$(installed_testdir)
cp -r $(srcdir)/tests/compat-repo $(DESTDIR)$(installed_testdir)
mkdir -p $(DESTDIR)$(installed_testdir)/compat-repo/tmp
INSTALL_DATA_HOOKS += install-compat-repo-hook
endif

tests/libreaddir-rand.so: Makefile
mkdir -p tests/
$(AM_V_GEN) ln -fns ../.libs/libreaddir-rand.so tests/
Expand Down
3 changes: 3 additions & 0 deletions tests/compat-repo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[core]
repo_version=1
mode=archive-z2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions tests/compat-repo/refs/heads/main
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
109dc1626d2d50bcb1863abd6121d6ec934deae478f52d276b1fa4131b0055ee
1 change: 1 addition & 0 deletions tests/compat-repo/refs/summary
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
109dc1626d2d50bcb1863abd6121d6ec934deae478f52d276b1fa4131b0055ee main
111 changes: 111 additions & 0 deletions tests/test-compat-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/bash
#
# Copyright (C) 2015 Dan Nicholson <nicholson@endlessm.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

set -euo pipefail

. $(dirname $0)/libtest.sh

if ! has_gpgme; then
echo "1..0 #SKIP no gpg support compiled in"
exit 0
fi

setup_test_repository "archive-z2"

echo '1..6'

cd ${test_tmpdir}
${OSTREE} commit -b test2 -s "A GPG signed commit" -m "Signed commit body" \
--gpg-sign=${TEST_GPG_KEYID_1} --gpg-homedir=${TEST_GPG_KEYHOME} \
--tree=dir=files
find repo/objects -name '*.sig' | wc -l > sigcount
assert_file_has_content sigcount "^0$"

echo "ok commit sign no old signature"

setup_fake_remote_repo1 "archive-z2"

cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo \
commit -b main -s "A GPG signed commit" -m "Signed commit body" \
--gpg-sign=${TEST_GPG_KEYID_1} --gpg-homedir=${TEST_GPG_KEYHOME} \
--tree=dir=files

rm -rf local
mkdir local
${CMD_PREFIX} ostree --repo=local init
${CMD_PREFIX} ostree --repo=local remote add --set=gpg-verify=false origin \
$(cat httpd-address)/ostree/gnomerepo
${CMD_PREFIX} ostree --repo=local pull origin main
find local/objects -name '*.sig' | wc -l > sigcount
assert_file_has_content sigcount "^0$"

echo "ok compat pull"

# Test pulls from a repo containing a commit made with old ostree.
# Create a couple needed directories not tracked in git.
cd ${test_tmpdir}
rm -rf compat-repo
cp -a ${test_srcdir}/compat-repo .
chmod -R u+w compat-repo
mkdir -p compat-repo/tmp compat-repo/refs/remotes

rm -rf local
mkdir local
${CMD_PREFIX} ostree --repo=local init --mode=archive-z2
${CMD_PREFIX} ostree --repo=local pull-local compat-repo main
find local/objects -name '*.sig' | wc -l > sigcount
assert_file_has_content sigcount "^0$"
find local/objects -name '*.sizes2' | wc -l > sizescount
assert_file_has_content sizescount "^0$"

echo "ok compat pull-local from old repo"

ln -s ${test_tmpdir}/compat-repo ${test_tmpdir}/httpd/

rm -rf local
mkdir local
${CMD_PREFIX} ostree --repo=local init --mode=archive-z2
${CMD_PREFIX} ostree --repo=local remote add --set=gpg-verify=false origin \
$(cat httpd-address)/compat-repo
${CMD_PREFIX} ostree --repo=local pull origin main
find local/objects -name '*.sig' | wc -l > sigcount
assert_file_has_content sigcount "^0$"
find local/objects -name '*.sizes2' | wc -l > sizescount
assert_file_has_content sizescount "^0$"

echo "ok compat pull from old repo"

rm -rf local
mkdir local
${CMD_PREFIX} ostree --repo=local init --mode=archive-z2
${CMD_PREFIX} ostree --repo=local remote add origin \
$(cat httpd-address)/compat-repo
if ${CMD_PREFIX} ostree --repo=local pull origin main; then
fatal "pulled commit verified unexpectedly"
fi

echo "ok compat pull from old repo with verification fails"

${CMD_PREFIX} ostree --repo=compat-repo refs --delete main
${CMD_PREFIX} ostree --repo=compat-repo prune --depth=-1 --refs-only
find compat-repo/objects -type f | wc -l > objcount
assert_file_has_content objcount "^0$"

echo "ok compat prune"

0 comments on commit e727966

Please sign in to comment.