sapling/eden/scm/tests/test-fb-hgext-remotefilelog-push-pull.t
Meyer Jacobs 640767d414 scmstore: track contentstore fallbacks
Summary:
Introduce basic contentstore fallback tracking to help monitor the scmstore shim rollout.

This will be expanded to a general fetch metrics system for scmstore in a future change.

Reviewed By: kulshrax

Differential Revision: D29305839

fbshipit-source-id: c6cc3ea15a3bb7b90f4ec298febc911ec4e2af91
2021-06-23 15:26:26 -07:00

407 lines
14 KiB
Raku

$ disable treemanifest
$ . "$TESTDIR/library.sh"
$ setconfig devel.print-metrics=1
$ setconfig scmstore.enableshim=True scmstore.contentstorefallback=True
$ hginit master
$ cd master
$ cat >> .hg/hgrc <<EOF
> [remotefilelog]
> server=True
> EOF
$ echo x > x
$ hg commit -qAm x
$ cd ..
$ hgcloneshallow ssh://user@dummy/master shallow -q
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) (?)
{ metrics : { fallback : { fetch : 2,
fetchhitcontent : 2,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0},
ssh : { connections : 2,
getpack : { calls : 1, revs : 1},
read : { bytes : 1484},
write : { bytes : 778}}}}
$ hgcloneshallow ssh://user@dummy/master shallow2 -q
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0},
ssh : { connections : 1,
read : { bytes : 859},
write : { bytes : 631}}}}
We should see the remotefilelog capability here, which advertises that
the server supports our custom getfiles method.
$ cd master
$ echo 'hello' | hg -R . serve --stdio
* (glob)
capabilities: lookup * remotefilelog getflogheads getfile (glob)
$ echo 'capabilities' | hg -R . serve --stdio ; echo
* (glob)
* remotefilelog getflogheads getfile (glob)
# pull to shallow from full
$ echo y > y
$ hg commit -qAm y
$ cd ../shallow
$ hg pull
pulling from ssh://user@dummy/master
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 0 changes to 0 files
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0},
ssh : { connections : 1,
read : { bytes : 975},
write : { bytes : 608}}}}
$ hg up
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) (?)
{ metrics : { fallback : { fetch : 2,
fetchhitcontent : 2,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0},
ssh : { connections : 1,
getpack : { calls : 1, revs : 1},
read : { bytes : 625},
write : { bytes : 147}}}}
$ cat y
y
$ cd ..
# pull from shallow to shallow (local)
$ cd shallow
$ echo z > z
$ hg commit -qAm z
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ echo x >> x
$ echo y >> y
$ hg commit -qAm xxyy
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ cd ../shallow2
$ clearcache
$ hg pull ../shallow
pulling from ../shallow
searching for changes
adding changesets
adding manifests
adding file changes
4 files fetched over 2 fetches - (4 misses, 0.00% hit ratio) over 0.00s (?)
added 3 changesets with 4 changes to 3 files
{ metrics : { fallback : { fetch : 2,
fetchhitcontent : 2,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0},
ssh : { connections : 2,
getpack : { calls : 3, revs : 3},
read : { bytes : 1403},
write : { bytes : 337}}}}
# pull from shallow to shallow (ssh)
$ hg debugstrip -r d34c38483be9d08f205eaae60c380a29b48e0189
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ hg pull ssh://user@dummy/$TESTTMP/shallow --config remotefilelog.cachepath=${CACHEDIR}2
pulling from ssh://user@dummy/$TESTTMP/shallow
searching for changes
adding changesets
adding manifests
adding file changes
2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) (?)
added 3 changesets with 4 changes to 3 files
remote: { metrics : { fallback : { fetch : 2,
remote: fetchhitcontent : 2,
remote: fetchhitptr : 0,
remote: fetchmiss : 0,
remote: writeptr : 0},
remote: ssh : { connections : 1,
remote: getpack : { calls : 1, revs : 1},
remote: read : { bytes : 625},
remote: write : { bytes : 147}}}}
{ metrics : { fallback : { fetch : 2,
fetchhitcontent : 2,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0},
ssh : { connections : 2,
getpack : { calls : 1, revs : 1},
read : { bytes : 2848},
write : { bytes : 755}}}}
$ hg up
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ cat z
z
$ hg -R ../shallow debugstrip -qr 'desc(xxyy)'
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ hg debugstrip -qr 'desc(xxyy)'
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ cd ..
# push from shallow to shallow
$ cd shallow
$ echo a > a
$ hg commit -qAm a
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ hg push ssh://user@dummy/$TESTTMP/shallow2
pushing to ssh://user@dummy/$TESTTMP/shallow2
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
remote: { metrics : { fallback : { fetch : 0,
remote: fetchhitcontent : 0,
remote: fetchhitptr : 0,
remote: fetchmiss : 0,
remote: writeptr : 0}}}
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0},
ssh : { connections : 1,
read : { bytes : 612},
write : { bytes : 991}}}}
$ cd ../shallow2
$ hg up
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ cat a
a
$ cd ..
# push from shallow to full
$ cd shallow
$ hg push
pushing to ssh://user@dummy/master
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 2 changesets with 2 changes to 2 files
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0},
ssh : { connections : 1,
read : { bytes : 589},
write : { bytes : 1454}}}}
$ cd ../master
$ hg log -l 1 -r 'desc(a)' --style compact
1489bbbc46f0 1970-01-01 00:00 +0000 test
a
$ hg up 'desc(a)'
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cat a
a
# push public commits
$ cd ../shallow
$ echo p > p
$ hg commit -qAm p
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ hg debugmakepublic .
$ echo d > d
$ hg commit -qAm d
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ cd ../shallow2
$ hg pull ../shallow
pulling from ../shallow
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 1 changes to 1 files
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ cd ..
# Test pushing from shallow to shallow with multiple manifests introducing the
# same filenode. Test this by constructing two separate histories of file 'c'
# that share a file node and verifying that the history works after pushing.
$ hginit multimf-master
$ hgcloneshallow ssh://user@dummy/multimf-master multimf-shallow -q
{ metrics : { ssh : { connections : 1,
read : { bytes : 502},
write : { bytes : 511}}}}
$ hgcloneshallow ssh://user@dummy/multimf-master multimf-shallow2 -q
{ metrics : { ssh : { connections : 1,
read : { bytes : 502},
write : { bytes : 511}}}}
$ cd multimf-shallow
$ echo a > a
$ hg commit -qAm a
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ echo b > b
$ hg commit -qAm b
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ echo c > c
$ hg commit -qAm c1
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ hg up -q 'desc(a)'
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ echo c > c
$ hg commit -qAm c2
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ echo cc > c
$ hg commit -qAm c22
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ hg log -G -T '{desc}\n'
@ c22
o c2
o c1
│ │
o b
├─╯
o a
$ cd ../multimf-shallow2
- initial commit to prevent hg pull from being a clone
$ echo z > z && hg commit -qAm z
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ hg pull -f ssh://user@dummy/$TESTTMP/multimf-shallow
pulling from ssh://user@dummy/$TESTTMP/multimf-shallow
searching for changes
warning: repository is unrelated
requesting all changes
adding changesets
adding manifests
adding file changes
added 5 changesets with 4 changes to 3 files
remote: { metrics : { fallback : { fetch : 0,
remote: fetchhitcontent : 0,
remote: fetchhitptr : 0,
remote: fetchmiss : 0,
remote: writeptr : 0}}}
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0},
ssh : { connections : 1,
read : { bytes : 2883},
write : { bytes : 608}}}}
$ hg up -q 'desc(c22)'
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}
$ hg log -f -T '{node}\n' c
d8f06a4c6d38c9308d3dcbee10c27ae5a01ab93f
853b3dc5bcf912b088c60ccd3ec60f35e96b92bb
{ metrics : { fallback : { fetch : 0,
fetchhitcontent : 0,
fetchhitptr : 0,
fetchmiss : 0,
writeptr : 0}}}