sapling/eden/hg-server/tests/test-commitcloud-backup-sql2.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

91 lines
3.9 KiB
Perl

#require py2
#chg-compatible
#if no-windows no-osx
$ . "$TESTDIR/library.sh"
$ . "$TESTDIR/infinitepush/library.sh"
$ setupcommon
$ mkcommit() {
> echo "$1" > "$1"
> hg add "$1"
> hg ci -m "$1"
> }
$ hg init server
$ cd server
$ setupsqlserverhgrc babar
$ setupdb
$ cd ..
$ hg clone -q ssh://user@dummy/server client
$ cd client
$ setupsqlclienthgrc
$ mkcommit initialcommit
$ hg cloud backup
backing up stack rooted at 67145f466344
commitcloud: backed up 1 commit
remote: pushing 1 commit:
remote: 67145f466344 initialcommit
$ mkcommit commitwithbookmark
$ hg book abook
$ sleep 1 # Resolution of the database is in seconds. This avoids test flakiness
$ hg cloud backup
backing up stack rooted at 67145f466344
commitcloud: backed up 1 commit
remote: pushing 2 commits:
remote: 67145f466344 initialcommit
remote: 5ea4271ca0f0 commitwithbookmark
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'SELECT bookmark, node, reponame from bookmarkstonode'
bookmark node reponame
infinitepush/backups/test/.*\$TESTTMP/client/bookmarks/abook 5ea4271ca0f0cda5477241ae95ffc1fa7056ee6f babar (re)
infinitepush/backups/test/.*\$TESTTMP/client/heads/5ea4271ca0f0cda5477241ae95ffc1fa7056ee6f 5ea4271ca0f0cda5477241ae95ffc1fa7056ee6f babar (re)
Create a few more commits to test that cloud restorebackup preserves order
$ hg up -q 0
$ mkcommit anothercommit > /dev/null
$ hg cloud backup -q
$ hg up -q 0
$ sleep 1 # Resolution of the database is in seconds. This avoids test flakiness
$ mkcommit anothercommit2 > /dev/null
$ hg cloud backup -q
$ hg log -T '{node}\n'
e1c1c1f2871f70bd24f941ebfec59f14adf7a13d
f0d24965f49e87fc581a603dee76196f433444ff
5ea4271ca0f0cda5477241ae95ffc1fa7056ee6f
67145f4663446a9580364f70034fea6e21293b6f
Pull backup and check that commits are in the same order
$ cd ..
$ hg clone -q ssh://user@dummy/server client2
$ cd client2
$ hg cloud restore -q
commitcloud: this command is deprecated, please use 'hg cloud list' and 'hg cloud switch' commands instead
$ hg log -T '{node}\n'
e1c1c1f2871f70bd24f941ebfec59f14adf7a13d
f0d24965f49e87fc581a603dee76196f433444ff
5ea4271ca0f0cda5477241ae95ffc1fa7056ee6f
67145f4663446a9580364f70034fea6e21293b6f
Create a server with different name that connects to the same db
$ cd ..
$ rm -rf server
$ hg init server
$ cd server
$ setupsqlserverhgrc newserver
$ echo "sqlhost=$DBHOST:$DBPORT:$DBNAME:$DBUSER:$DBPASS" >> .hg/hgrc
Go to client, delete backup state and run pushbackup. Make sure that it doesn't delete entries from another repo
$ cd ../client
$ rm -r .hg/infinitepushbackups
$ hg cloud backup
nothing to back up
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'SELECT bookmark, node, reponame from bookmarkstonode'
bookmark node reponame
infinitepush/backups/test/.*\$TESTTMP/client/bookmarks/abook 5ea4271ca0f0cda5477241ae95ffc1fa7056ee6f babar (re)
infinitepush/backups/test/.*\$TESTTMP/client/heads/5ea4271ca0f0cda5477241ae95ffc1fa7056ee6f 5ea4271ca0f0cda5477241ae95ffc1fa7056ee6f babar (re)
infinitepush/backups/test/.*\$TESTTMP/client/heads/e1c1c1f2871f70bd24f941ebfec59f14adf7a13d e1c1c1f2871f70bd24f941ebfec59f14adf7a13d babar (re)
infinitepush/backups/test/.*\$TESTTMP/client/heads/f0d24965f49e87fc581a603dee76196f433444ff f0d24965f49e87fc581a603dee76196f433444ff babar (re)
infinitepush/backups/test/.*\$TESTTMP/client/bookmarks/abook 5ea4271ca0f0cda5477241ae95ffc1fa7056ee6f newserver (re)
infinitepush/backups/test/.*\$TESTTMP/client/heads/5ea4271ca0f0cda5477241ae95ffc1fa7056ee6f 5ea4271ca0f0cda5477241ae95ffc1fa7056ee6f newserver (re)
infinitepush/backups/test/.*\$TESTTMP/client/heads/e1c1c1f2871f70bd24f941ebfec59f14adf7a13d e1c1c1f2871f70bd24f941ebfec59f14adf7a13d newserver (re)
infinitepush/backups/test/.*\$TESTTMP/client/heads/f0d24965f49e87fc581a603dee76196f433444ff f0d24965f49e87fc581a603dee76196f433444ff newserver (re)
#endif