Skip to content

Commit

Permalink
Add test?
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrero committed Oct 11, 2023
1 parent 2f67d1f commit 885428f
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/test-pull-connection-reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
#
# Copyright (C) 2023 Red Hat
#
# SPDX-License-Identifier: LGPL-2.0+
#
# 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, see <https://www.gnu.org/licenses/>.

# This test will only pass if the host experiences tcp-resets we are doing that by setting:
# sudo iptables -A OUTPUT -p tcp -m statistic --mode random --probability 0.50 -j REJECT --reject-with tcp-reset
# on the VM running this test.
set -euo pipefail

. $(dirname $0)/libtest.sh

COMMIT_SIGN=""
if has_gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
fi

echo "1..6"

# pull should fail but retries should be present.
rm ostree-srv httpd repo -rf
setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}"

pushd ${test_tmpdir}
ostree_repo_init repo --mode=archive
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
assert_fail ${CMD_PREFIX} ostree --repo=repo pull --mirror origin main 2>err.txt
assert_file_has_content err.txt "Should retry request \(remaining: 3 retries\), due to transient error"
popd
echo "ok retries present after tcp-reset"

0 comments on commit 885428f

Please sign in to comment.