indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
We previously lacked test coverage of the low-level output of the
"listkeys" wire protocol command.
We add basic testing for the "namespaces," "bookmarks," and
"phases" pushkey namespaces.
We introduce a helper shell function for running tests with version
1 and 2 of the SSH protocol as separate invocations. We could have
used #testcases. However, as the protocols diverge, managing differences
with inline (sshv1 !) syntax will quickly become unwieldy. The output
is much easier to reason about and manage when each protocol version
is self-contained within a continuous block.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D2407
AFFECTED FILES
tests/test-ssh-proto.t
CHANGE DETAILS
diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -1,3 +1,23 @@
+ $ cat > hgrc-sshv2 << EOF
+ > %include $HGRCPATH
+ > [experimental]
+ > sshpeer.advertise-v2 = true
+ > sshserver.support-v2 = true
+ > EOF
+
+Helper function to run protocol tests against multiple protocol versions.
+This is easier than using #testcases because managing differences between
+protocols with inline conditional output is hard to read.
+
+ $ debugwireproto() {
+ > commands=`cat -`
+ > echo 'testing ssh1'
+ > echo "${commands}" | hg --verbose debugwireproto --localssh
+ > echo ""
+ > echo 'testing ssh2'
+ > echo "${commands}" | HGRCPATH=$TESTTMP/hgrc-sshv2 hg --verbose
debugwireproto --localssh
+ > }
+
$ cat >> $HGRCPATH << EOF
> [ui]
> ssh = $PYTHON "$TESTDIR/dummyssh"
@@ -1215,3 +1235,521 @@
e> read(-1) -> 49:
e> malformed handshake protocol: missing pairs 81\n
e> -\n
+
+ $ cd ..
+
+Test listkeys for listing namespaces
+
+ $ hg init empty
+ $ cd empty
+ $ debugwireproto << EOF
+ > command listkeys
+ > namespace namespaces
+ > EOF
+ testing ssh1
+ creating ssh peer from handshake results
+ i> write(104) -> None:
+ i> hello\n
+ i> between\n
+ i> pairs 81\n
+ i>
-
+ i> flush() -> None
+ o> readline() -> 4:
+ o> 384\n
+ o> readline() -> 384:
+ o> capabilities: lookup changegroupsubset branchmap pushkey known
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
+ o> readline() -> 2:
+ o> 1\n
+ o> readline() -> 1:
+ o> \n
+ i> write(9) -> None:
+ i> listkeys\n
+ i> write(13) -> None:
+ i> namespace 10\n
+ i> write(10) -> None: namespaces
+ i> flush() -> None
+ o> osread(4096) -> 33:
+ o> 30\n
+ o> bookmarks \n
+ o> namespaces\n
+ o> phases
+
+ testing ssh2
+ creating ssh peer from handshake results
+ i> write(171) -> None:
+ i> upgrade * proto=exp-ssh-v2-0001\n (glob)
+ i> hello\n
+ i> between\n
+ i> pairs 81\n
+ i>
-
+ i> flush() -> None
+ o> readline() -> 62:
+ o> upgraded * exp-ssh-v2-0001\n (glob)
+ o> readline() -> 4:
+ o> 383\n
+ o> read(383) -> 383: capabilities: lookup changegroupsubset branchmap
pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN
+ o> read(1) -> 1:
+ o> \n
+ i> write(9) -> None:
+ i> listkeys\n
+ i> write(13) -> None:
+ i> namespace 10\n
+ i> write(10) -> None: namespaces
+ i> flush() -> None
+ o> osread(4096) -> 33:
+ o> 30\n
+ o> bookmarks \n
+ o> namespaces\n
+ o> phases
+
+ $ cd ..
+
+Test listkeys for bookmarks
+
+ $ hg init bookmarkrepo
+ $ cd bookmarkrepo
+ $ echo 0 > foo
+ $ hg add foo
+ $ hg -q commit -m initial
+ $ echo 1 > foo
+ $ hg commit -m second
+
+With no bookmarks set
+
+ $ debugwireproto << EOF
+ > command listkeys
+ > namespace bookmarks
+ > EOF
+ testing ssh1
+ creating ssh peer from handshake results
+ i> write(104) -> None:
+ i> hello\n
+ i> between\n
+ i> pairs 81\n
+ i>
-
+ i> flush() -> None
+ o> readline() -> 4:
+ o> 384\n
+ o> readline() -> 384:
+ o> capabilities: lookup changegroupsubset branchmap pushkey known
getbundle unbundlehash batch streamreqs=generaldelta,revlogv1
$USUAL_BUNDLE2_CAPS_SERVER$ unbundle=HG10GZ,HG10BZ,HG10UN\n
+ o> readline() -> 2:
+ o> 1\n
+ o> readline() -> 1:
+ o> \n
+ i> write(9) -> None:
+ i> listkeys\n
+ i> write(12) -> None:
+ i> namespace 9\n
+ i> write(9) -> None: bookmarks
+ i> flush() -> None
+ o> osread(4096) -> 2:
+ o> 0\n
+
+ testing ssh2
+ creating ssh peer from