Skip to content

Commit

Permalink
vcsreplicator: send heads message as part of replicatesync (Bug 175…
Browse files Browse the repository at this point in the history
…7183) r=zeid

Adds a call to `sendheadsmessage` as part of `replicatesync`. Adds a flag
to control whether the heads message is sent.

Differential Revision: https://phabricator.services.mozilla.com/D142101

--HG--
extra : moz-landing-system : lando
  • Loading branch information
cgsheeh committed Mar 25, 2022
1 parent 838b60f commit 94ca688
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 6 deletions.
3 changes: 3 additions & 0 deletions hgext/unifyrepo/tests/test-daemon.t
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ Create a repo as the origin repo and make copies
$ hgmo exec hgssh /var/hg/venv_tools/bin/hg -R /repo/hg/mozilla/repo1 replicatesync
wrote synchronization message into replication log
wrote heads synchronization message into replication log
$ hgmo exec hgssh /var/hg/venv_tools/bin/hg -R /repo/hg/mozilla/repo2 replicatesync
wrote synchronization message into replication log
wrote heads synchronization message into replication log
$ hgmo exec hgssh /var/hg/venv_tools/bin/hg -R /repo/hg/mozilla/repo3 replicatesync
wrote synchronization message into replication log
wrote heads synchronization message into replication log
$ hgmo exec hgweb0 /var/hg/venv_replication/bin/vcsreplicator-consumer --wait-for-no-lag /etc/mercurial/vcsreplicator.ini
$ hgmo exec hgweb1 /var/hg/venv_replication/bin/vcsreplicator-consumer --wait-for-no-lag /etc/mercurial/vcsreplicator.ini
Expand Down
1 change: 1 addition & 0 deletions hgserver/tests/test-clonebundles.t
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ An index.html and bundles.json document should be produced
$ hgmo exec hgssh sudo -u hg SINGLE_THREADED=1 /var/hg/venv_bundles/bin/generate-hg-s3-bundles mozilla-central --no-upload
wrote synchronization message into replication log
wrote heads synchronization message into replication log
tip is 77538e1ce4bec5f7aac58a7ceca2da0e38e90a72
verifying or rebuilding fncache
fncache for mozilla-central: adding data/foo.i
Expand Down
1 change: 1 addition & 0 deletions hgserver/tests/test-obsolescence-server.t
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ Blowing away the repo on hgweb and re-cloning should retain pushlog and hidden c
/repo/hg/mozilla/users/user_example.com/repo-1: changed owner on 7; mode on 7
$ hgmo exec hgssh /var/hg/venv_pash/bin/hg --hidden -R /repo/hg/mozilla/users/user_example.com/repo-1 replicatesync
wrote synchronization message into replication log
wrote heads synchronization message into replication log
$ hgmo exec hgweb0 /var/hg/venv_replication/bin/vcsreplicator-consumer --wait-for-no-lag /etc/mercurial/vcsreplicator.ini
$ hgmo exec hgweb0 /var/hg/venv_replication/bin/hg --hidden -R /repo/hg/mozilla/users/user_example.com/repo-1 log -r 0:tip -T '{rev}:{node|short} {phase} {pushid} {pushuser}\n'
Expand Down
97 changes: 92 additions & 5 deletions pylib/vcsreplicator/tests/test-sync.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

$ hgmo exec hgssh /var/hg/venv_tools/bin/hg -R /repo/hg/mozilla/mozilla-central replicatesync
wrote synchronization message into replication log
wrote heads synchronization message into replication log

$ consumer --dump --partition 2
- _created: \d+\.\d+ (re)
Expand All @@ -34,29 +35,36 @@
- dotencode
- fncache
- generaldelta
- revlog-compression-zstd
- revlogv1
- sparserevlog (hg49 !)
- store
- _created: 1648222565.020264
heads:
- '0000000000000000000000000000000000000000'
last_push_id: 0
name: hg-heads-1
path: '{moz}/mozilla-central'

$ hgmo exec hgweb0 /var/hg/venv_replication/bin/vcsreplicator-consumer --wait-for-no-lag /etc/mercurial/vcsreplicator.ini

$ hgmo exec hgweb0 tail -n 16 /var/log/vcsreplicator/consumer.log
vcsreplicator.consumer starting consumer for topic=pushdata group=* partitions=[*] (glob)
vcsreplicator.consumer starting consumer for topic=pushdata group=* partitions=[*] (glob)
vcsreplicator.consumer processing heartbeat-1 from partition 0 offset 0
vcsreplicator.consumer processing hg-repo-init-2: (repo: {moz}/mozilla-central) from partition 2 offset 0
vcsreplicator.consumer created Mercurial repository: /repo/hg/mozilla/mozilla-central
vcsreplicator.consumer processing hg-repo-sync-2: (repo: {moz}/mozilla-central, heads: ['0000000000000000000000000000000000000000'], bootstrap: False) from partition 2 offset 1
vcsreplicator.consumer processing hg-repo-sync-2: (repo: {moz}/mozilla-central, heads: ['000000000000'], bootstrap: False) from partition 2 offset 1
vcsreplicator.consumer writing hgrc: /repo/hg/mozilla/mozilla-central/.hg/hgrc
vcsreplicator.consumer pulling 1 heads into /repo/hg/mozilla/mozilla-central
vcsreplicator.consumer $ /var/hg/venv_replication/bin/hg pull -r0000000000000000000000000000000000000000 -- ssh://hgssh/mozilla-central
vcsreplicator.consumer > not trusting file /vct/.hg/hgrc from untrusted user root, group root
vcsreplicator.consumer > pulling from ssh://hgssh/mozilla-central
vcsreplicator.consumer > remote: Warning: Permanently added the RSA host key for IP address '*' to the list of known hosts. (glob)
vcsreplicator.consumer > no changes found
vcsreplicator.consumer > added 0 pushes
vcsreplicator.consumer > updating moz-owner file
vcsreplicator.consumer [0]
vcsreplicator.consumer pulled 0 changesets into /repo/hg/mozilla/mozilla-central
vcsreplicator.consumer processing hg-heads-1: (repo: {moz}/mozilla-central, heads: ['000000000000'], last_push_id: 0) from partition 2 offset 2

$ hgmo exec hgweb0 cat /repo/hg/mozilla/mozilla-central/.hg/hgrc
[hooks]
Expand All @@ -70,8 +78,87 @@ We should not see any pulls, even after waiting for no lag

$ hgmo exec hgweb0 /var/hg/venv_replication/bin/vcsreplicator-consumer --wait-for-no-lag /etc/mercurial/vcsreplicator.ini
$ hgmo exec hgweb0 tail -n 2 /var/log/vcsreplicator/consumer.log
vcsreplicator.consumer pulled 0 changesets into /repo/hg/mozilla/mozilla-central
vcsreplicator.consumer processing hg-repo-sync-2: (repo: {moz}/mozilla-central, heads: ['0000000000000000000000000000000000000000'], bootstrap: True) from partition 2 offset 2
vcsreplicator.consumer processing hg-heads-1: (repo: {moz}/mozilla-central, heads: ['000000000000'], last_push_id: 0) from partition 2 offset 2
vcsreplicator.consumer processing hg-repo-sync-2: (repo: {moz}/mozilla-central, heads: ['000000000000'], bootstrap: True) from partition 2 offset 3

Running `replicatesync --no-heads` will not send heads message.

$ hgmo exec hgssh /var/hg/venv_tools/bin/hg -R /repo/hg/mozilla/mozilla-central replicatesync --no-heads
wrote synchronization message into replication log

$ hgmo exec hgweb0 /var/hg/venv_replication/bin/vcsreplicator-consumer --wait-for-no-lag /etc/mercurial/vcsreplicator.ini

$ consumer --dump --partition 2
- _created: 1648222562.9029722
generaldelta: true
name: hg-repo-init-2
path: '{moz}/mozilla-central'
- _created: 1648222565.0108953
bootstrap: false
heads:
- '0000000000000000000000000000000000000000'
hgrc: '[hooks]
foo = bar
'
name: hg-repo-sync-2
path: '{moz}/mozilla-central'
requirements:
- dotencode
- fncache
- generaldelta
- revlog-compression-zstd
- revlogv1
- sparserevlog
- store
- _created: 1648222565.020264
heads:
- '0000000000000000000000000000000000000000'
last_push_id: 0
name: hg-heads-1
path: '{moz}/mozilla-central'
- _created: 1648222569.4841566
bootstrap: true
heads:
- '0000000000000000000000000000000000000000'
hgrc: '[hooks]
foo = bar
'
name: hg-repo-sync-2
path: '{moz}/mozilla-central'
requirements:
- dotencode
- fncache
- generaldelta
- revlog-compression-zstd
- revlogv1
- sparserevlog
- store
- _created: 1648222572.5529828
bootstrap: false
heads:
- '0000000000000000000000000000000000000000'
hgrc: '[hooks]
foo = bar
'
name: hg-repo-sync-2
path: '{moz}/mozilla-central'
requirements:
- dotencode
- fncache
- generaldelta
- revlog-compression-zstd
- revlogv1
- sparserevlog
- store

Cleanup

Expand Down
11 changes: 10 additions & 1 deletion pylib/vcsreplicator/vcsreplicator/hgext.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,12 @@ def sendheartbeat(ui):
len(partitions))


@command(b'replicatesync', [(b'b', b'bootstrap', False, b'Use bootstrap mode')], b'replicate this repository to mirrors')
@command(b'replicatesync',
[
(b'b', b'bootstrap', False, b'Use bootstrap mode'),
(b'h', b'heads', True, b'Send heads message'),
],
b'replicate this repository to mirrors')
def replicatecommand(ui, repo, **opts):
"""Tell mirrors to synchronize their copy of this repo.
Expand All @@ -499,6 +504,10 @@ def replicatecommand(ui, repo, **opts):
sendreposyncmessage(ui, repo, bootstrap=opts.get('bootstrap'))
ui.status(_(b'wrote synchronization message into replication log\n'))

if opts.get('heads') and not opts.get('bootstrap'):
sendheadsmessage(ui, repo)
ui.status(_(b'wrote heads synchronization message into replication log\n'))


@command(b'replicatedelete', [], b'delete this repository and all mirrors')
def replicatedelete(ui, repo):
Expand Down

0 comments on commit 94ca688

Please sign in to comment.