Patchwork [4,of,4,STABLE] tests: expand test coverage for updating phases

login
register
mail settings
Submitter Gregory Szorc
Date Feb. 18, 2018, 6:23 p.m.
Message ID <337491de32e3e273c7b9.1518978187@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/28118/
State Accepted
Headers show

Comments

Gregory Szorc - Feb. 18, 2018, 6:23 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1518978019 28800
#      Sun Feb 18 10:20:19 2018 -0800
# Branch stable
# Node ID 337491de32e3e273c7b98a5259bd053f44acdede
# Parent  ec71cddd8b6915f7fa2029c641a8385bef1392c3
tests: expand test coverage for updating phases

Consolidating the tests demonstrated that there are behavior
differences when pushing phases between bundle1 and bundle2.

A reason for this is the behavior of legacy pushes where the client
queries the state of phases and then conditionally updates phases
after an "unbundle" is processed. This behavior is expected.

The tests were incomplete because they only tested the case of a
publishing repo. In this commit, we add a variant for a non-publishing
repo. We still see some differences between the legacy and bundle2
exchanges. But they are less pronounced.

The behavior of not firing a pushkey hook when phases are updated as
part of changegroup application feels weird to me. I'm not sure if
this is a feature or a bug. By the time the "pushkey" or "phases"
bundle2 part is applied, the phases have already been moved on
a publishing repository. We fire the "pushkey" hook regardless,
even though it would be a no-op. This is the part that feels the
most buggy.
Augie Fackler - Feb. 18, 2018, 9:04 p.m.
On Sun, Feb 18, 2018 at 10:23:07AM -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1518978019 28800
> #      Sun Feb 18 10:20:19 2018 -0800
> # Branch stable
> # Node ID 337491de32e3e273c7b98a5259bd053f44acdede
> # Parent  ec71cddd8b6915f7fa2029c641a8385bef1392c3
> tests: expand test coverage for updating phases

queued for stable, reasoning seems sound, thanks

Patch

diff --git a/tests/test-push-http.t b/tests/test-push-http.t
--- a/tests/test-push-http.t
+++ b/tests/test-push-http.t
@@ -162,7 +162,7 @@  has no parameter
   repository tip rolled back to revision 0 (undo serve)
   $ mv $HGRCPATH.orig $HGRCPATH
 
-expect push success, phase change failure
+Test pushing to a publishing repository with a failing prepushkey hook
 
   $ cat > .hg/hgrc <<EOF
   > [web]
@@ -175,6 +175,10 @@  expect push success, phase change failur
   > EOF
 
 #if bundle1
+Bundle1 works because a) phases are updated as part of changegroup application
+and b) client checks phases after the "unbundle" command. Since it sees no
+phase changes are necessary, it doesn't send the "pushkey" command and the
+prepushkey hook never has to fire.
 
   $ req
   pushing to http://localhost:$HGPORT/
@@ -188,7 +192,8 @@  expect push success, phase change failur
 #endif
 
 #if bundle2
-
+Bundle2 sends a "pushkey" bundle2 part. This runs as part of the transaction
+and fails the entire push.
   $ req
   pushing to http://localhost:$HGPORT/
   searching for changes
@@ -206,30 +211,40 @@  expect push success, phase change failur
 
 #endif
 
-expect phase change success
+Now remove the failing prepushkey hook.
 
   $ cat >> .hg/hgrc <<EOF
   > [hooks]
   > prepushkey = sh -c "printenv.py prepushkey 0"
-  > [devel]
-  > legacy.exchange=
   > EOF
 
-#if bundle1
+We don't need to test bundle1 because it succeeded above.
 
+#if bundle2
   $ req
   pushing to http://localhost:$HGPORT/
   searching for changes
-  no changes found
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP:
   % serve errors
-  [1]
-  $ hg rollback
-  repository tip rolled back to revision 0 (undo serve)
-
 #endif
 
-#if bundle2
+  $ hg --config extensions.strip= strip -r 1:
+  saved backup bundle to $TESTTMP/test/.hg/strip-backup/ba677d0156c1-eea704d7-backup.hg
+
+Now do a variant of the above, except on a non-publishing repository
 
+  $ cat >> .hg/hgrc <<EOF
+  > [phases]
+  > publish = false
+  > [hooks]
+  > prepushkey = sh -c "printenv.py prepushkey 1"
+  > EOF
+
+#if bundle1
   $ req
   pushing to http://localhost:$HGPORT/
   searching for changes
@@ -237,12 +252,61 @@  expect phase change success
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
+  remote: prepushkey hook: HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1
+  remote: pushkey-abort: prepushkey hook exited with status 1
+  updating ba677d0156c1 to public failed!
   % serve errors
-  $ hg rollback
-  repository tip rolled back to revision 0 (undo serve)
+#endif
+
+#if bundle2
+  $ req
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP:
+  remote: pushkey-abort: prepushkey hook exited with status 1
+  remote: transaction abort!
+  remote: rollback completed
+  abort: updating ba677d0156c1 to public failed
+  % serve errors
+  [255]
+#endif
+
+Make phases updates work
 
+  $ cat >> .hg/hgrc <<EOF
+  > [hooks]
+  > prepushkey = sh -c "printenv.py prepushkey 0"
+  > EOF
+
+#if bundle1
+  $ req
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+  remote: prepushkey hook: HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1
+  % serve errors
+  [1]
 #endif
 
+#if bundle2
+  $ req
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP:
+  % serve errors
+#endif
+
+  $ hg --config extensions.strip= strip -r 1:
+  saved backup bundle to $TESTTMP/test/.hg/strip-backup/ba677d0156c1-eea704d7-backup.hg
+
 expect authorization error: all users denied
 
   $ echo '[web]' > .hg/hgrc