Blame tests/test-pull-sizes.sh

Packit Service 2a3f3d
#!/bin/bash
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# Copyright (C) 2019 Endless Mobile, Inc.
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# SPDX-License-Identifier: LGPL-2.0+
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# This library is free software; you can redistribute it and/or
Packit Service 2a3f3d
# modify it under the terms of the GNU Lesser General Public
Packit Service 2a3f3d
# License as published by the Free Software Foundation; either
Packit Service 2a3f3d
# version 2 of the License, or (at your option) any later version.
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# This library is distributed in the hope that it will be useful,
Packit Service 2a3f3d
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 2a3f3d
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 2a3f3d
# Lesser General Public License for more details.
Packit Service 2a3f3d
#
Packit Service 2a3f3d
# You should have received a copy of the GNU Lesser General Public
Packit Service 2a3f3d
# License along with this library; if not, write to the
Packit Service 2a3f3d
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit Service 2a3f3d
# Boston, MA 02111-1307, USA.
Packit Service 2a3f3d
Packit Service 2a3f3d
set -euo pipefail
Packit Service 2a3f3d
Packit Service 2a3f3d
. $(dirname $0)/libtest.sh
Packit Service 2a3f3d
Packit Service 2a3f3d
# Committing SELinux attributes throws off the hardcoded sizes below
Packit Service 2a3f3d
export OSTREE_NO_XATTRS=1
Packit Service 2a3f3d
setup_fake_remote_repo1 "archive" "--generate-sizes"
Packit Service 2a3f3d
Packit Service 2a3f3d
echo '1..3'
Packit Service 2a3f3d
Packit Service 2a3f3d
cd ${test_tmpdir}
Packit Service 2a3f3d
mkdir repo
Packit Service 2a3f3d
ostree_repo_init repo
Packit Service 2a3f3d
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
Packit Service 2a3f3d
Packit Service 2a3f3d
# Pull commit metadata only. All size and objects will be needed.
Packit Service 2a3f3d
${CMD_PREFIX} ostree --repo=repo pull --commit-metadata-only origin main
Packit Service 2a3f3d
${CMD_PREFIX} ostree --repo=repo show --print-sizes origin:main > show.txt
Packit Service 2a3f3d
assert_file_has_content show.txt 'Compressed size (needed/total): 637[  ]bytes/637[  ]bytes'
Packit Service 2a3f3d
assert_file_has_content show.txt 'Unpacked size (needed/total): 457[  ]bytes/457[  ]bytes'
Packit Service 2a3f3d
assert_file_has_content show.txt 'Number of objects (needed/total): 10/10'
Packit Service 2a3f3d
echo "ok sizes commit metadata only"
Packit Service 2a3f3d
Packit Service 2a3f3d
# Pull the parent commit so we get most of the objects
Packit Service 2a3f3d
parent=$(${CMD_PREFIX} ostree --repo=repo rev-parse origin:main^)
Packit Service 2a3f3d
${CMD_PREFIX} ostree --repo=repo pull origin ${parent}
Packit Service 2a3f3d
${CMD_PREFIX} ostree --repo=repo show --print-sizes origin:main > show.txt
Packit Service 2a3f3d
assert_file_has_content show.txt 'Compressed size (needed/total): 501[  ]bytes/637[  ]bytes'
Packit Service 2a3f3d
assert_file_has_content show.txt 'Unpacked size (needed/total): 429[  ]bytes/457[  ]bytes'
Packit Service 2a3f3d
assert_file_has_content show.txt 'Number of objects (needed/total): 6/10'
Packit Service 2a3f3d
echo "ok sizes commit partial"
Packit Service 2a3f3d
Packit Service 2a3f3d
# Finish pulling the commit and check that no objects needed
Packit Service 2a3f3d
${CMD_PREFIX} ostree --repo=repo pull origin main
Packit Service 2a3f3d
${CMD_PREFIX} ostree --repo=repo show --print-sizes origin:main > show.txt
Packit Service 2a3f3d
assert_file_has_content show.txt 'Compressed size (needed/total): 0[  ]bytes/637[  ]bytes'
Packit Service 2a3f3d
assert_file_has_content show.txt 'Unpacked size (needed/total): 0[  ]bytes/457[  ]bytes'
Packit Service 2a3f3d
assert_file_has_content show.txt 'Number of objects (needed/total): 0/10'
Packit Service 2a3f3d
echo "ok sizes commit full"