sapling/eden/hg-server/tests/test-fb-hgext-snapshot-sync.t
Durham Goode 98d9269874 server: copy hg to a new hg-server directory
Summary:
Create a fork of the Mercurial code that we can use to build server
rpms. The hg servers will continue to exist for a few more months while we move
the darkstorm and ediscovery use cases off them. In the mean time, we want to
start making breaking changes to the client, so let's create a stable copy of
the hg code to produce rpms for the hg servers.

The fork is based off c7770c78d, the latest hg release.

This copies the files as is, then adds some minor tweaks to get it to build:
- Disables some lint checks that appear to be bypassed by path
- sed replace eden/scm with eden/hg-server
- Removed a dependency on scm/telemetry from the edenfs-client tests since
  scm/telemetry pulls in the original eden/scm/lib/configparser which conflicts
  with the hg-server conflict parser.

allow-large-files

Reviewed By: quark-zju

Differential Revision: D27632557

fbshipit-source-id: b2f442f4ec000ea08e4d62de068750832198e1f4
2021-04-09 10:09:06 -07:00

291 lines
8.1 KiB
Perl

#require py2
#chg-compatible
# Initial setup
$ configure dummyssh
$ enable amend commitcloud infinitepush rebase snapshot
$ disable treemanifest
$ setconfig visibility.enabled=true
$ . "$TESTDIR/library.sh"
$ . "$TESTDIR/infinitepush/library.sh"
$ setupcommon
$ setconfig commitcloud.hostname=testhost
$ setconfig remotefilelog.reponame=server
$ setconfig infinitepushbackup.hostname=testhost
$ setconfig snapshot.enable-sync-bundle=true
# Setup server
$ hg init server
$ cd server
$ setupserver
$ setconfig infinitepush.server=yes infinitepush.reponame=testrepo
$ setconfig infinitepush.indextype=disk infinitepush.storetype=disk
$ touch base
$ hg commit -Aqm base
$ hg debugmakepublic .
$ BASEREV="$(hg id -i)"
$ echo "$BASEREV"
df4f53cec30a
$ cd ..
# Setup clients
$ hg clone ssh://user@dummy/server client1 -q
$ cd client1
$ setconfig commitcloud.servicetype=local commitcloud.servicelocation=$TESTTMP commitcloud.token_enforced=False
$ hg debugvisibility start
$ hg cloud join
commitcloud: this repository is now connected to the 'user/test/default' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/test/default'
commitcloud: commits synchronized
finished in 0.00 sec
$ cd ..
$ hg clone ssh://user@dummy/server client2 -q
$ cd client2
$ setconfig commitcloud.servicetype=local commitcloud.servicelocation=$TESTTMP commitcloud.token_enforced=False
$ hg cloud join
commitcloud: this repository is now connected to the 'user/test/default' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/test/default'
commitcloud: commits synchronized
finished in 0.00 sec
$ cd ..
$ testdb() {
> cat commitcloudservicedb | grep "$1" >> /dev/null && echo "$1" || echo "not found"
> cat commitcloudservicedb | grep "$2" >> /dev/null && echo "$2" || echo "not found"
> }
# Snapshot sync test plan:
# 1) Create a snapshot on each host (expected: h1 [s1], h2 [s2], s []);
# 2) Do the sync on the first host (expected: h1 [s1], h2 [s2], s [s1]);
# 3) Do the sync on the second one (expected: h1 [s1], h2 [s1, s2], s [s1, s2]);
# 3.1) Remove snapshot ext from 2nd host and do the sync (expected: nothing changes);
# 4) Remove s1 from the first host and do the sync (expected: h1 [s2], h2 [s1, s2], s [s2]);
# 5) Remove s2 from the second host and do the sync (expected: h1 [s2], h2 [], s []);
# 6) Add s1 to the first host and do the sync on the first host (expected: h1: [s1], h2 [], s[s1]).
# 1) Create a snapshot on each host (expected: h1 [s1], h2 [s2], s []);
$ cd client1
$ echo "snapshot1 data" > data1
$ OID1="$(hg snapshot create --clean | head -n 1 | cut -f2 -d' ')"
$ echo "$OID1"
7917335ca0064e431e045fdebf0bd483fcc8e28d
$ hg snapshot show --debug $OID1
commit: 7917335ca0064e431e045fdebf0bd483fcc8e28d
phase: secret
manifest: 4e7eb8574ed56675aa89d2b5abbced12d5688cef
user: test
date: Thu Jan 01 00:00:00 1970 +0000
extra: branch=default
extra: snapshotmetadataid=16839bd960d247256f387c52c79b0cf144a0209140eb07edf922c762564d7705
description:
snapshot
===
Untracked changes:
===
? data1
@@ -0,0 +1,1 @@
+snapshot1 data
$ hg snapshot list
7917335ca006 snapshot
$ cd ../client2
$ echo "snapshot2 data" > data2
$ OID2="$(hg snapshot create --clean | head -n 1 | cut -f2 -d' ')"
$ echo "$OID2"
5e55990d984329c0cd0395dad5fcee6d6e8cc126
$ hg snapshot show --debug $OID2
commit: 5e55990d984329c0cd0395dad5fcee6d6e8cc126
phase: secret
manifest: 4e7eb8574ed56675aa89d2b5abbced12d5688cef
user: test
date: Thu Jan 01 00:00:00 1970 +0000
extra: branch=default
extra: snapshotmetadataid=9351f31a425f4da1b0efc151e9f7876333aac5bff34d2d29b69ef196c3709467
description:
snapshot
===
Untracked changes:
===
? data2
@@ -0,0 +1,1 @@
+snapshot2 data
$ hg snapshot list
5e55990d9843 snapshot
$ cd ..
$ testdb "$OID1" "$OID2"
not found
not found
# 2) Do the sync on the first host (expected: h1 [s1], h2 [s2], s [s1]);
$ cd client1
$ hg cloud sync
commitcloud: synchronizing 'server' with 'user/test/default'
backing up stack rooted at df4f53cec30a
commitcloud: commits synchronized
finished in 0.00 sec
remote: pushing 2 commits:
remote: df4f53cec30a base
remote: 7917335ca006 snapshot
$ hg snapshot list
7917335ca006 snapshot
$ cd ..
$ testdb "$OID1" "$OID2"
7917335ca0064e431e045fdebf0bd483fcc8e28d
not found
# 3) Do the sync on the second one (expected: h1 [s1], h2 [s1, s2], s [s1, s2]);
$ cd client2
$ hg cloud sync
commitcloud: synchronizing 'server' with 'user/test/default'
backing up stack rooted at df4f53cec30a
pulling 7917335ca006 from ssh://user@dummy/server
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 0 changes to 1 files
remote: pushing 2 commits:
remote: df4f53cec30a base
remote: 5e55990d9843 snapshot
commitcloud: commits synchronized
finished in 0.00 sec
$ hg snapshot list
5e55990d9843 snapshot
7917335ca006 snapshot
$ hg snapshot show --debug "$OID1"
commit: 7917335ca0064e431e045fdebf0bd483fcc8e28d
phase: secret
manifest: 4e7eb8574ed56675aa89d2b5abbced12d5688cef
user: test
date: Thu Jan 01 00:00:00 1970 +0000
extra: branch=default
extra: snapshotmetadataid=16839bd960d247256f387c52c79b0cf144a0209140eb07edf922c762564d7705
description:
snapshot
===
Untracked changes:
===
? data1
@@ -0,0 +1,1 @@
+snapshot1 data
$ cd ..
$ testdb "$OID1" "$OID2"
7917335ca0064e431e045fdebf0bd483fcc8e28d
5e55990d984329c0cd0395dad5fcee6d6e8cc126
# 3.1) Remove snapshot ext from 2nd host and do the sync (expected: nothing changes);
$ cd client2
$ setconfig extensions.snapshot=!
$ hg cloud sync
commitcloud: synchronizing 'server' with 'user/test/default'
commitcloud: commits synchronized
finished in 0.00 sec
$ setconfig extensions.snapshot=
$ hg snapshot list
5e55990d9843 snapshot
7917335ca006 snapshot
$ cd ..
$ testdb "$OID1" "$OID2"
7917335ca0064e431e045fdebf0bd483fcc8e28d
5e55990d984329c0cd0395dad5fcee6d6e8cc126
# 4) Remove s1 from the first host and do the sync (expected: h1 [s2], h2 [s1, s2], s [s2]);
$ cd client1
$ hg snapshot hide "$OID1"
$ hg snapshot list
no snapshots created
$ hg cloud sync
commitcloud: synchronizing 'server' with 'user/test/default'
pulling 5e55990d9843 from ssh://user@dummy/server
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 0 changes to 1 files
commitcloud: commits synchronized
finished in 0.00 sec
$ hg snapshot list
5e55990d9843 snapshot
$ hg snapshot show --debug "$OID2"
commit: 5e55990d984329c0cd0395dad5fcee6d6e8cc126
phase: secret
manifest: 4e7eb8574ed56675aa89d2b5abbced12d5688cef
user: test
date: Thu Jan 01 00:00:00 1970 +0000
extra: branch=default
extra: snapshotmetadataid=9351f31a425f4da1b0efc151e9f7876333aac5bff34d2d29b69ef196c3709467
description:
snapshot
===
Untracked changes:
===
? data2
@@ -0,0 +1,1 @@
+snapshot2 data
$ cd ..
$ testdb "$OID1" "$OID2"
not found
5e55990d984329c0cd0395dad5fcee6d6e8cc126
# 5) Remove s2 from the second host and do the sync (expected: h1 [s2], h2 [], s []);
$ cd client2
$ hg snapshot hide "$OID2"
$ hg snapshot list
7917335ca006 snapshot
$ hg cloud sync
commitcloud: synchronizing 'server' with 'user/test/default'
commitcloud: commits synchronized
finished in 0.00 sec
$ hg snapshot list
no snapshots created
$ cd ..
$ testdb "$OID1" "$OID2"
not found
not found
# 6) Add s1 to the first host and do the sync on the first host (expected: h1: [s1], h2 [], s[s1]).
$ cd client1
$ hg snapshot unhide "$OID1"
$ hg cloud sync
commitcloud: synchronizing 'server' with 'user/test/default'
commitcloud: commits synchronized
finished in 0.00 sec
$ hg snapshot list
7917335ca006 snapshot
$ cd ..
$ testdb "$OID1" "$OID2"
7917335ca0064e431e045fdebf0bd483fcc8e28d
not found