Patchwork [1,of,2] test: add a test file dedicated to an important distributed case

login
register
mail settings
Submitter Boris Feld
Date Oct. 12, 2017, 10:29 a.m.
Message ID <8252157034b4e4f9f851.1507804164@FB>
Download mbox | patch
Permalink /patch/24769/
State Superseded
Headers show

Comments

Boris Feld - Oct. 12, 2017, 10:29 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1506711555 -3600
#      Fri Sep 29 19:59:15 2017 +0100
# Node ID 8252157034b4e4f9f851f328633ef86df44cc9cf
# Parent  60213a2eca81af4e1daa3ef9e44af859ba1e5756
# EXP-Topic obs-tests
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 8252157034b4
test: add a test file dedicated to an important distributed case

This test file introduce documented test case for obsolescence markers usage
that are important to distributed workflow cases.

In the distributed case, new changesets, markers, and phases can be added in
orders that would not happen during the local only usage. Documenting these
scenarios and test them is important as we make progress with various
obsolescence aspect.
Denis Laxalde - Oct. 12, 2017, 11:56 a.m.
Boris Feld a écrit :
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1506711555 -3600
> #      Fri Sep 29 19:59:15 2017 +0100
> # Node ID 8252157034b4e4f9f851f328633ef86df44cc9cf
> # Parent  60213a2eca81af4e1daa3ef9e44af859ba1e5756
> # EXP-Topic obs-tests
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 8252157034b4
> test: add a test file dedicated to an important distributed case
> 
> This test file introduce documented test case for obsolescence markers usage

typos: introduces documented test cases

> that are important to distributed workflow cases.
> 
> In the distributed case, new changesets, markers, and phases can be added in
> orders that would not happen during the local only usage. Documenting these
> scenarios and test them is important as we make progress with various
> obsolescence aspect.

typo: aspects

> 
> diff --git a/tests/test-obsolete-distributed.t b/tests/test-obsolete-distributed.t
> new file mode 100644
> --- /dev/null
> +++ b/tests/test-obsolete-distributed.t
> @@ -0,0 +1,199 @@
> +=============================
> +Test distributed obsolescence
> +=============================
> +
> +This file test various case where data (changeset, phase, obsmarkers) is added

typo: various cases

> +to the repository in a specific order. Usually, this order is unlikely to
> +happen in the local case but can easily happen in the distributed case.
> +
> +  $ . $TESTDIR/testlib/obsmarker-common.sh
> +  $ cat >> $HGRCPATH << EOF
> +  > [experimental]
> +  > evolution = all
> +  > [phases]
> +  > publish = False
> +  > [templates]
> +  > obsfatesuccessors = "{if(successors, " as ")}{join(successors, ", ")}"
> +  > obsfateverb = "{obsfateverb(successors)}"
> +  > obsfateoperations = "{if(obsfateoperations(markers), " using {join(obsfateoperations(markers), ", ")}")}"
> +  > obsfateusers = "{if(obsfateusers(markers), " by {join(obsfateusers(markers), ", ")}")}"
> +  > obsfatedate = "{if(obsfatedate(markers), "{ifeq(min(obsfatedate(markers)), max(obsfatedate(markers)), " (at {min(obsfatedate(markers))|isodate})", " (between {min(obsfatedate(markers))|isodate} and {max(obsfatedate(markers))|isodate})")}")}"
> +  > obsfate = "{obsfateverb}{obsfateoperations}{obsfatesuccessors}{obsfateusers}{obsfatedate}; "
> +  > [ui]
> +  > logtemplate= {rev}:{node|short} {desc} {if(succsandmarkers, "[{succsandmarkers % "{obsfate}"}]")}\n
> +  > EOF
> +
> +Check distributed chain building
> +================================
> +
> +Test case where a changeset is marked as a successor of another locally
> +changeset while the successor has already been obsoleted remotely.

either "of another local changeset while [...]" or "of another locally
while [...]"

> +
> +The chain of evolution should seamlessly connect and all but the new version
> +(created remotely) should be seen as obsolete.
> +
> +Initial setup
> +
> +  $ mkdir distributed-chain-building
> +  $ cd distributed-chain-building
> +  $ hg init server
> +  $ cd server
> +  $ mkcommit ROOT
> +  $ mkcommit c_A0
> +  $ hg up 'desc("ROOT")'
> +  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  $ mkcommit c_A1
> +  created new head
> +  $ hg up 'desc("ROOT")'
> +  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  $ mkcommit c_B0
> +  created new head
> +  $ hg debugobsolete `getid 'desc("c_A0")'` `getid 'desc("c_A1")'`
> +  obsoleted 1 changesets
> +  $ hg log -G --hidden
> +  @  3:b305f85f127a c_B0
> +  |
> +  | o  2:23422fed6b3d c_A1
> +  |/
> +  | x  1:d1ada4861b76 c_A0 [rewritten as 2:23422fed6b3d by test (at 1970-01-01 00:00 +0000); ]
> +  |/
> +  o  0:ea207398892e ROOT
> +
> +  $ hg debugobsolete
> +  d1ada4861b7669f79a948eefaea6950b5e543855 23422fed6b3d22e1b9d89fb82bdb68edc19079b4 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
> +  $ cd ..
> +
> +duplicate the repo for the client:
> +
> +  $ cp -R server client
> +  $ cat << EOF >> client/.hg/hgrc
> +  > [paths]
> +  > default = ../server/
> +  > EOF

Might be nice in this client/server setup to set ui.username=client
(resp. server) on each side. This way, obsfate information would read
more easily below.

> +
> +server side: create new revision on the server (obsoleting another one)
> +
> +  $ cd server
> +  $ hg up 'desc("ROOT")'
> +  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  $ mkcommit c_B1
> +  created new head
> +  $ hg debugobsolete `getid 'desc("c_B0")'` `getid 'desc("c_B1")'`
> +  obsoleted 1 changesets
> +  $ hg log -G
> +  @  4:388f688b3711 c_B1
> +  |
> +  | o  2:23422fed6b3d c_A1
> +  |/
> +  o  0:ea207398892e ROOT
> +
> +  $ hg log -G --hidden
> +  @  4:388f688b3711 c_B1
> +  |
> +  | x  3:b305f85f127a c_B0 [rewritten as 4:388f688b3711 by test (at 1970-01-01 00:00 +0000); ]
> +  |/
> +  | o  2:23422fed6b3d c_A1
> +  |/
> +  | x  1:d1ada4861b76 c_A0 [rewritten as 2:23422fed6b3d by test (at 1970-01-01 00:00 +0000); ]
> +  |/
> +  o  0:ea207398892e ROOT
> +
> +  $ hg debugobsolete
> +  d1ada4861b7669f79a948eefaea6950b5e543855 23422fed6b3d22e1b9d89fb82bdb68edc19079b4 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
> +  b305f85f127a9d2e608bcbd83c59373fec615cb2 388f688b3711ebec978514297edccfe19b2fbed9 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
> +  $ cd ..
> +
> +client side: create a marker between two common changesets
> +(client is not aware of the server activity yet)
> +
> +  $ cd client
> +  $ hg debugobsolete `getid 'desc("c_A1")'` `getid 'desc("c_B0")'`
> +  obsoleted 1 changesets
> +  $ hg log -G
> +  @  3:b305f85f127a c_B0
> +  |
> +  o  0:ea207398892e ROOT
> +
> +  $ hg log -G --hidden
> +  @  3:b305f85f127a c_B0
> +  |
> +  | x  2:23422fed6b3d c_A1 [rewritten as 3:b305f85f127a by test (at 1970-01-01 00:00 +0000); ]
> +  |/
> +  | x  1:d1ada4861b76 c_A0 [rewritten as 2:23422fed6b3d by test (at 1970-01-01 00:00 +0000); ]
> +  |/
> +  o  0:ea207398892e ROOT
> +
> +  $ hg debugobsolete
> +  d1ada4861b7669f79a948eefaea6950b5e543855 23422fed6b3d22e1b9d89fb82bdb68edc19079b4 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
> +  23422fed6b3d22e1b9d89fb82bdb68edc19079b4 b305f85f127a9d2e608bcbd83c59373fec615cb2 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
> +
> +client side: pull from the server
> +(the new successors should take over)
> +
> +  $ hg up 'desc("ROOT")'
> +  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  $ hg pull
> +  pulling from $TESTTMP/distributed-chain-building/server (glob)
> +  searching for changes
> +  adding changesets
> +  adding manifests
> +  adding file changes
> +  added 1 changesets with 1 changes to 1 files (+1 heads)
> +  1 new obsolescence markers
> +  obsoleted 1 changesets
> +  (run 'hg heads' to see heads)
> +  $ hg log -G
> +  o  4:388f688b3711 c_B1
> +  |
> +  @  0:ea207398892e ROOT
> +
> +  $ hg log -G --hidden
> +  o  4:388f688b3711 c_B1
> +  |
> +  | x  3:b305f85f127a c_B0 [rewritten as 4:388f688b3711 by test (at 1970-01-01 00:00 +0000); ]
> +  |/
> +  | x  2:23422fed6b3d c_A1 [rewritten as 3:b305f85f127a by test (at 1970-01-01 00:00 +0000); ]
> +  |/
> +  | x  1:d1ada4861b76 c_A0 [rewritten as 2:23422fed6b3d by test (at 1970-01-01 00:00 +0000); ]
> +  |/
> +  @  0:ea207398892e ROOT
> +
> +  $ hg debugobsolete
> +  d1ada4861b7669f79a948eefaea6950b5e543855 23422fed6b3d22e1b9d89fb82bdb68edc19079b4 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
> +  23422fed6b3d22e1b9d89fb82bdb68edc19079b4 b305f85f127a9d2e608bcbd83c59373fec615cb2 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
> +  b305f85f127a9d2e608bcbd83c59373fec615cb2 388f688b3711ebec978514297edccfe19b2fbed9 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
> +
> +server side: receive client push
> +(the other way around, pushing to the server, the obsolete changesets stay
> +obsolete on the server side but the marker is sent out.)
> +
> +  $ hg rollback
> +  repository tip rolled back to revision 3 (undo pull)
> +  $ hg push -f
> +  pushing to $TESTTMP/distributed-chain-building/server (glob)
> +  searching for changes
> +  adding changesets
> +  adding manifests
> +  adding file changes
> +  added 0 changesets with 0 changes to 1 files
> +  1 new obsolescence markers
> +  obsoleted 1 changesets
> +  $ hg -R ../server/ log -G
> +  @  4:388f688b3711 c_B1
> +  |
> +  o  0:ea207398892e ROOT
> +
> +  $ hg -R ../server/ log -G --hidden
> +  @  4:388f688b3711 c_B1
> +  |
> +  | x  3:b305f85f127a c_B0 [rewritten as 4:388f688b3711 by test (at 1970-01-01 00:00 +0000); ]
> +  |/
> +  | x  2:23422fed6b3d c_A1 [rewritten as 3:b305f85f127a by test (at 1970-01-01 00:00 +0000); ]
> +  |/
> +  | x  1:d1ada4861b76 c_A0 [rewritten as 2:23422fed6b3d by test (at 1970-01-01 00:00 +0000); ]
> +  |/
> +  o  0:ea207398892e ROOT
> +
> +  $ hg debugobsolete
> +  d1ada4861b7669f79a948eefaea6950b5e543855 23422fed6b3d22e1b9d89fb82bdb68edc19079b4 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
> +  23422fed6b3d22e1b9d89fb82bdb68edc19079b4 b305f85f127a9d2e608bcbd83c59373fec615cb2 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}

Patch

diff --git a/tests/test-obsolete-distributed.t b/tests/test-obsolete-distributed.t
new file mode 100644
--- /dev/null
+++ b/tests/test-obsolete-distributed.t
@@ -0,0 +1,199 @@ 
+=============================
+Test distributed obsolescence
+=============================
+
+This file test various case where data (changeset, phase, obsmarkers) is added
+to the repository in a specific order. Usually, this order is unlikely to
+happen in the local case but can easily happen in the distributed case.
+
+  $ . $TESTDIR/testlib/obsmarker-common.sh
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > evolution = all
+  > [phases]
+  > publish = False
+  > [templates]
+  > obsfatesuccessors = "{if(successors, " as ")}{join(successors, ", ")}"
+  > obsfateverb = "{obsfateverb(successors)}"
+  > obsfateoperations = "{if(obsfateoperations(markers), " using {join(obsfateoperations(markers), ", ")}")}"
+  > obsfateusers = "{if(obsfateusers(markers), " by {join(obsfateusers(markers), ", ")}")}"
+  > obsfatedate = "{if(obsfatedate(markers), "{ifeq(min(obsfatedate(markers)), max(obsfatedate(markers)), " (at {min(obsfatedate(markers))|isodate})", " (between {min(obsfatedate(markers))|isodate} and {max(obsfatedate(markers))|isodate})")}")}"
+  > obsfate = "{obsfateverb}{obsfateoperations}{obsfatesuccessors}{obsfateusers}{obsfatedate}; "
+  > [ui]
+  > logtemplate= {rev}:{node|short} {desc} {if(succsandmarkers, "[{succsandmarkers % "{obsfate}"}]")}\n
+  > EOF
+
+Check distributed chain building
+================================
+
+Test case where a changeset is marked as a successor of another locally
+changeset while the successor has already been obsoleted remotely.
+
+The chain of evolution should seamlessly connect and all but the new version
+(created remotely) should be seen as obsolete.
+
+Initial setup
+
+  $ mkdir distributed-chain-building
+  $ cd distributed-chain-building
+  $ hg init server
+  $ cd server
+  $ mkcommit ROOT
+  $ mkcommit c_A0
+  $ hg up 'desc("ROOT")'
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ mkcommit c_A1
+  created new head
+  $ hg up 'desc("ROOT")'
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ mkcommit c_B0
+  created new head
+  $ hg debugobsolete `getid 'desc("c_A0")'` `getid 'desc("c_A1")'`
+  obsoleted 1 changesets
+  $ hg log -G --hidden
+  @  3:b305f85f127a c_B0
+  |
+  | o  2:23422fed6b3d c_A1
+  |/
+  | x  1:d1ada4861b76 c_A0 [rewritten as 2:23422fed6b3d by test (at 1970-01-01 00:00 +0000); ]
+  |/
+  o  0:ea207398892e ROOT
+  
+  $ hg debugobsolete
+  d1ada4861b7669f79a948eefaea6950b5e543855 23422fed6b3d22e1b9d89fb82bdb68edc19079b4 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+  $ cd ..
+
+duplicate the repo for the client:
+
+  $ cp -R server client
+  $ cat << EOF >> client/.hg/hgrc
+  > [paths]
+  > default = ../server/
+  > EOF
+
+server side: create new revision on the server (obsoleting another one)
+
+  $ cd server
+  $ hg up 'desc("ROOT")'
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ mkcommit c_B1
+  created new head
+  $ hg debugobsolete `getid 'desc("c_B0")'` `getid 'desc("c_B1")'`
+  obsoleted 1 changesets
+  $ hg log -G
+  @  4:388f688b3711 c_B1
+  |
+  | o  2:23422fed6b3d c_A1
+  |/
+  o  0:ea207398892e ROOT
+  
+  $ hg log -G --hidden
+  @  4:388f688b3711 c_B1
+  |
+  | x  3:b305f85f127a c_B0 [rewritten as 4:388f688b3711 by test (at 1970-01-01 00:00 +0000); ]
+  |/
+  | o  2:23422fed6b3d c_A1
+  |/
+  | x  1:d1ada4861b76 c_A0 [rewritten as 2:23422fed6b3d by test (at 1970-01-01 00:00 +0000); ]
+  |/
+  o  0:ea207398892e ROOT
+  
+  $ hg debugobsolete
+  d1ada4861b7669f79a948eefaea6950b5e543855 23422fed6b3d22e1b9d89fb82bdb68edc19079b4 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+  b305f85f127a9d2e608bcbd83c59373fec615cb2 388f688b3711ebec978514297edccfe19b2fbed9 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+  $ cd ..
+
+client side: create a marker between two common changesets
+(client is not aware of the server activity yet)
+
+  $ cd client
+  $ hg debugobsolete `getid 'desc("c_A1")'` `getid 'desc("c_B0")'`
+  obsoleted 1 changesets
+  $ hg log -G
+  @  3:b305f85f127a c_B0
+  |
+  o  0:ea207398892e ROOT
+  
+  $ hg log -G --hidden
+  @  3:b305f85f127a c_B0
+  |
+  | x  2:23422fed6b3d c_A1 [rewritten as 3:b305f85f127a by test (at 1970-01-01 00:00 +0000); ]
+  |/
+  | x  1:d1ada4861b76 c_A0 [rewritten as 2:23422fed6b3d by test (at 1970-01-01 00:00 +0000); ]
+  |/
+  o  0:ea207398892e ROOT
+  
+  $ hg debugobsolete
+  d1ada4861b7669f79a948eefaea6950b5e543855 23422fed6b3d22e1b9d89fb82bdb68edc19079b4 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+  23422fed6b3d22e1b9d89fb82bdb68edc19079b4 b305f85f127a9d2e608bcbd83c59373fec615cb2 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+
+client side: pull from the server
+(the new successors should take over)
+
+  $ hg up 'desc("ROOT")'
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg pull
+  pulling from $TESTTMP/distributed-chain-building/server (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  (run 'hg heads' to see heads)
+  $ hg log -G
+  o  4:388f688b3711 c_B1
+  |
+  @  0:ea207398892e ROOT
+  
+  $ hg log -G --hidden
+  o  4:388f688b3711 c_B1
+  |
+  | x  3:b305f85f127a c_B0 [rewritten as 4:388f688b3711 by test (at 1970-01-01 00:00 +0000); ]
+  |/
+  | x  2:23422fed6b3d c_A1 [rewritten as 3:b305f85f127a by test (at 1970-01-01 00:00 +0000); ]
+  |/
+  | x  1:d1ada4861b76 c_A0 [rewritten as 2:23422fed6b3d by test (at 1970-01-01 00:00 +0000); ]
+  |/
+  @  0:ea207398892e ROOT
+  
+  $ hg debugobsolete
+  d1ada4861b7669f79a948eefaea6950b5e543855 23422fed6b3d22e1b9d89fb82bdb68edc19079b4 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+  23422fed6b3d22e1b9d89fb82bdb68edc19079b4 b305f85f127a9d2e608bcbd83c59373fec615cb2 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+  b305f85f127a9d2e608bcbd83c59373fec615cb2 388f688b3711ebec978514297edccfe19b2fbed9 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+
+server side: receive client push
+(the other way around, pushing to the server, the obsolete changesets stay
+obsolete on the server side but the marker is sent out.)
+
+  $ hg rollback
+  repository tip rolled back to revision 3 (undo pull)
+  $ hg push -f
+  pushing to $TESTTMP/distributed-chain-building/server (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 0 changesets with 0 changes to 1 files
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg -R ../server/ log -G
+  @  4:388f688b3711 c_B1
+  |
+  o  0:ea207398892e ROOT
+  
+  $ hg -R ../server/ log -G --hidden
+  @  4:388f688b3711 c_B1
+  |
+  | x  3:b305f85f127a c_B0 [rewritten as 4:388f688b3711 by test (at 1970-01-01 00:00 +0000); ]
+  |/
+  | x  2:23422fed6b3d c_A1 [rewritten as 3:b305f85f127a by test (at 1970-01-01 00:00 +0000); ]
+  |/
+  | x  1:d1ada4861b76 c_A0 [rewritten as 2:23422fed6b3d by test (at 1970-01-01 00:00 +0000); ]
+  |/
+  o  0:ea207398892e ROOT
+  
+  $ hg debugobsolete
+  d1ada4861b7669f79a948eefaea6950b5e543855 23422fed6b3d22e1b9d89fb82bdb68edc19079b4 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
+  23422fed6b3d22e1b9d89fb82bdb68edc19079b4 b305f85f127a9d2e608bcbd83c59373fec615cb2 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}