Rename BUP_TEST_REMOTE_REPO to BUP_TEST_LOCAL_SSH, since that's what
it's for, and what we were already using for a quick check in
test-save-restore. Move those tests to a dedicated test/ext/test-ssh,
and make them a bit more general.
The difference between testing remote operations with and without an
actual ssh connection is minimal (see bup.ssh), so we should only need
some basic validation. The bulk of the testing is already handled by
"fake" connections provided by --remote -:..., etc.
(One notable difference at the moment is that --remote -:... starts
the server with the current working directory, where a real ssh
connection to localhost will not.)
Signed-off-by: Rob Browning <
r...@defaultvalue.org>
Tested-by: Rob Browning <
r...@defaultvalue.org>
---
HACKING.md | 9 ++++++---
lib/bup/ssh.py | 11 +++++++++-
test/ext/test-save-restore | 5 -----
test/ext/test-ssh | 41 ++++++++++++++++++++++++++++++++++++++
4 files changed, 57 insertions(+), 9 deletions(-)
create mode 100755 test/ext/test-ssh
diff --git a/HACKING.md b/HACKING.md
index 139ae01c..132752bc 100644
--- a/HACKING.md
+++ b/HACKING.md
@@ -123,11 +123,14 @@ The tests are affected by a number of environment variables:
long-check does this`).
- `BUP_TEST_OTHER_BUP=PATH`: runs some tests comparing ./bup against
- the bup executable indicated by `PATH`, e.g. an older version of
+ the bup executable indicated by `PATH`, e.g. another version of
bup.
- - `BUP_TEST_REMOTE_REPO=t`: runs real ssh remote tests; "ssh
- localhost" must work without a password (e.g. via agent).
+ - `BUP_TEST_LOCAL_SSH=HOST`: runs real ssh remote tests; "ssh HOST"
+ must work without a password (e.g. via agent), and must refer to
+ the local host (e.g. localhost, 127.0.0.1, ...).
+ (`BUP_TEST_OTHER_BUP` tests rely on a test-only shortcut that
+ doesn't require ssh.)
- `test_prune_older.py` responds to some `BUP_TEST_PRUNE_OLDER_...`
tuning parameters.
diff --git a/lib/bup/ssh.py b/lib/bup/ssh.py
index c231a10f..c33470ba 100644
--- a/lib/bup/ssh.py
+++ b/lib/bup/ssh.py
@@ -18,7 +18,16 @@ def connect(destination, port, subcmd, stderr=None):
When BUP_TEST_LEVEL exists in the environment and the destination
is false, or b'-', run the subcmd as a subprocess rather than via
- ssh.
+ ssh, and choose bup as BUP_TEST_SSH_BUP_PATH when set or
+ path.exe() (the current bup).
+
+ When there is a destination, choose bup as BUP_TEST_SSH_BUP_PATH
+ when set and BUP_TEST_LEVEL exists in the environment, otherwise
+ "bup".
+
+ The BUP_TEST_LEVEL arrangements are to allow testing without
+ needing localhost ssh access, and to allow testing against some
+ other "remote" bup.
"""
assert re.fullmatch(br'[-_a-zA-Z0-9]+', subcmd), subcmd
diff --git a/test/ext/test-save-restore b/test/ext/test-save-restore
index f1d6ffcd..7816ea72 100755
--- a/test/ext/test-save-restore
+++ b/test/ext/test-save-restore
@@ -21,11 +21,6 @@ validate-local-and-remote-restore()
force-delete "$dest"
WVPASS bup restore -r "-:$BUP_DIR" -C "$dest" "$src"
WVPASS "$top/dev/compare-trees" "$cmp_src" "$cmp_dest"
- if test "${BUP_TEST_LOCAL_SSH:-}"; then
- force-delete "$dest"
- WVPASS bup restore -r "$BUP_TEST_LOCAL_SSH:$BUP_DIR" -C "$dest" "$src"
- WVPASS "$top/dev/compare-trees" "$cmp_src" "$cmp_dest"
- fi
}
diff --git a/test/ext/test-ssh b/test/ext/test-ssh
new file mode 100755
index 00000000..0539add2
--- /dev/null
+++ b/test/ext/test-ssh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+. ./wvtest.sh || exit $?
+. ./wvtest-bup.sh || exit $?
+. ./dev/lib.sh || exlt $?
+. ./test/lib/btl.sh || exit $?
+
+set -o pipefail
+
+if test -z "$BUP_TEST_LOCAL_SSH"; then
+ WVSKIP 'Skipping real ssh tests (BUP_TEST_LOCAL_SSH unset)'
+ exit 0
+fi
+
+top="$(WVPASS pwd)" || exit $?
+tmpdir="$(WVPASS wvmktempdir)" || exit $?
+
+bup() { "$top/bup" "$@"; }
+
+
+WVPASS cd "$tmpdir"
+
+export BUP_TEST_SSH_BUP_PATH="$top/bup"
+
+remote="$BUP_TEST_LOCAL_SSH:$(pwd)/remote"
+
+WVSTART "init"
+WVPASS bup init local
+WVPASS test ! -e remote
+WVPASS bup init -r "$remote"
+WVPASS test -f remote/HEAD
+
+WVPASS bup -d local index "$top/test/sampledata"
+WVPASS bup -d local save -r "$remote" -n save --strip "$top/test/sampledata"
+WVPASS bup restore -r "$remote" -C restore save/latest
+WVPASS "$top/dev/compare-trees" "$top/test/sampledata/" restore/latest
+force-delete src repo restore
+
+WVPASS cd "$top"
+WVPASS rm -rf "$tmpdir"
+
+
--
2.47.3