| 1 |
======================================================= |
| 2 |
Test the persistent on-disk nodemap during stream-clone |
| 3 |
======================================================= |
| 4 |
|
| 5 |
#testcases stream-v2 stream-v3 |
| 6 |
|
| 7 |
#if stream-v3 |
| 8 |
$ cat << EOF >> $HGRCPATH |
| 9 |
> [experimental] |
| 10 |
> stream-v3=yes |
| 11 |
> EOF |
| 12 |
#endif |
| 13 |
|
| 14 |
Setup |
| 15 |
===== |
| 16 |
|
| 17 |
#if no-rust |
| 18 |
|
| 19 |
$ cat << EOF >> $HGRCPATH |
| 20 |
> [format] |
| 21 |
> use-persistent-nodemap=yes |
| 22 |
> [devel] |
| 23 |
> persistent-nodemap=yes |
| 24 |
> [storage] |
| 25 |
> # to avoid spamming the test |
| 26 |
> revlog.persistent-nodemap.slow-path=allow |
| 27 |
> EOF |
| 28 |
|
| 29 |
#endif |
| 30 |
|
| 31 |
Recreate the same repo as in `test-persistent-nodemap.t` |
| 32 |
|
| 33 |
$ hg init test-repo --config storage.revlog.persistent-nodemap.slow-path=allow |
| 34 |
$ hg -R test-repo debugbuilddag .+5000 --new-file |
| 35 |
|
| 36 |
stream clone |
| 37 |
============ |
| 38 |
|
| 39 |
The persistent nodemap should exist after a streaming clone |
| 40 |
|
| 41 |
Simple case |
| 42 |
----------- |
| 43 |
|
| 44 |
No race condition |
| 45 |
|
| 46 |
$ hg clone -U --stream ssh://user@dummy/test-repo stream-clone --debug | grep -E '00(changelog|manifest)' |
| 47 |
adding [s] 00manifest.n (62 bytes) |
| 48 |
adding [s] 00manifest-*.nd (118 KB) (glob) |
| 49 |
adding [s] 00manifest.d (4?? KB) (glob) |
| 50 |
adding [s] 00manifest.i (313 KB) |
| 51 |
adding [s] 00changelog.n (62 bytes) |
| 52 |
adding [s] 00changelog-*.nd (118 KB) (glob) |
| 53 |
adding [s] 00changelog.d (3?? KB) (glob) |
| 54 |
adding [s] 00changelog.i (313 KB) |
| 55 |
$ ls -1 stream-clone/.hg/store/ | grep -E '00(changelog|manifest)(\.n|-.*\.nd)' |
| 56 |
00changelog-*.nd (glob) |
| 57 |
00changelog.n |
| 58 |
00manifest-*.nd (glob) |
| 59 |
00manifest.n |
| 60 |
$ hg -R stream-clone debugnodemap --metadata |
| 61 |
uid: * (glob) |
| 62 |
tip-rev: 5000 |
| 63 |
tip-node: 6b02b8c7b96654c25e86ba69eda198d7e6ad8b3c |
| 64 |
data-length: 121088 |
| 65 |
data-unused: 0 |
| 66 |
data-unused: 0.000% |
| 67 |
$ hg verify -R stream-clone |
| 68 |
checking changesets |
| 69 |
checking manifests |
| 70 |
crosschecking files in changesets and manifests |
| 71 |
checking files |
| 72 |
checking dirstate |
| 73 |
checked 5001 changesets with 5001 changes to 5001 files |
| 74 |
|
| 75 |
new data appened |
| 76 |
----------------- |
| 77 |
|
| 78 |
Other commit happening on the server during the stream clone |
| 79 |
|
| 80 |
setup the step-by-step stream cloning |
| 81 |
|
| 82 |
$ HG_TEST_STREAM_WALKED_FILE_1="$TESTTMP/sync_file_walked_1" |
| 83 |
$ export HG_TEST_STREAM_WALKED_FILE_1 |
| 84 |
$ HG_TEST_STREAM_WALKED_FILE_2="$TESTTMP/sync_file_walked_2" |
| 85 |
$ export HG_TEST_STREAM_WALKED_FILE_2 |
| 86 |
$ HG_TEST_STREAM_WALKED_FILE_3="$TESTTMP/sync_file_walked_3" |
| 87 |
$ export HG_TEST_STREAM_WALKED_FILE_3 |
| 88 |
$ HG_TEST_STREAM_WALKED_FILE_4="$TESTTMP/sync_file_walked_4" |
| 89 |
$ export HG_TEST_STREAM_WALKED_FILE_4 |
| 90 |
$ HG_TEST_STREAM_WALKED_FILE_5="$TESTTMP/sync_file_walked_5" |
| 91 |
$ export HG_TEST_STREAM_WALKED_FILE_5 |
| 92 |
$ cat << EOF >> test-repo/.hg/hgrc |
| 93 |
> [extensions] |
| 94 |
> steps=$RUNTESTDIR/testlib/ext-stream-clone-steps.py |
| 95 |
> EOF |
| 96 |
(we don't need this wait point) |
| 97 |
$ touch $HG_TEST_STREAM_WALKED_FILE_2 |
| 98 |
|
| 99 |
Check and record file state beforehand |
| 100 |
|
| 101 |
$ f --size test-repo/.hg/store/00changelog* |
| 102 |
test-repo/.hg/store/00changelog-*.nd: size=121088 (glob) |
| 103 |
test-repo/.hg/store/00changelog.d: size=3????? (glob) |
| 104 |
test-repo/.hg/store/00changelog.i: size=320064 |
| 105 |
test-repo/.hg/store/00changelog.n: size=62 |
| 106 |
$ hg -R test-repo debugnodemap --metadata | tee server-metadata.txt |
| 107 |
uid: * (glob) |
| 108 |
tip-rev: 5000 |
| 109 |
tip-node: 6b02b8c7b96654c25e86ba69eda198d7e6ad8b3c |
| 110 |
data-length: 121088 |
| 111 |
data-unused: 0 |
| 112 |
data-unused: 0.000% |
| 113 |
|
| 114 |
Prepare a commit |
| 115 |
|
| 116 |
$ echo foo >> test-repo/foo |
| 117 |
$ hg -R test-repo/ add test-repo/foo |
| 118 |
|
| 119 |
Do a mix of clone and commit at the same time so that the file listed on disk differ at actual transfer time. |
| 120 |
|
| 121 |
$ (hg clone -U --stream ssh://user@dummy/test-repo stream-clone-race-1 --debug 2>> clone-output | grep -E '00(changelog|manifest)' >> clone-output; touch $HG_TEST_STREAM_WALKED_FILE_5) & |
| 122 |
$ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_3 |
| 123 |
$ hg -R test-repo/ commit -m foo |
| 124 |
created new head |
| 125 |
$ touch $HG_TEST_STREAM_WALKED_FILE_4 |
| 126 |
$ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_5 |
| 127 |
$ cat clone-output |
| 128 |
adding [s] 00manifest.n (62 bytes) |
| 129 |
adding [s] 00manifest-*.nd (118 KB) (glob) |
| 130 |
adding [s] 00manifest.d (4?? KB) (glob) |
| 131 |
adding [s] 00manifest.i (313 KB) |
| 132 |
adding [s] 00changelog.n (62 bytes) |
| 133 |
adding [s] 00changelog-*.nd (118 KB) (glob) |
| 134 |
adding [s] 00changelog.d (36? KB) (glob) |
| 135 |
adding [s] 00changelog.i (313 KB) |
| 136 |
|
| 137 |
Check the result state |
| 138 |
|
| 139 |
$ f --size stream-clone-race-1/.hg/store/00changelog* |
| 140 |
stream-clone-race-1/.hg/store/00changelog-*.nd: size=121088 (glob) |
| 141 |
stream-clone-race-1/.hg/store/00changelog.d: size=3????? (glob) |
| 142 |
stream-clone-race-1/.hg/store/00changelog.i: size=320064 |
| 143 |
stream-clone-race-1/.hg/store/00changelog.n: size=62 |
| 144 |
|
| 145 |
$ hg -R stream-clone-race-1 debugnodemap --metadata | tee client-metadata.txt |
| 146 |
uid: * (glob) |
| 147 |
tip-rev: 5000 |
| 148 |
tip-node: 6b02b8c7b96654c25e86ba69eda198d7e6ad8b3c |
| 149 |
data-length: 121088 |
| 150 |
data-unused: 0 |
| 151 |
data-unused: 0.000% |
| 152 |
$ hg verify -R stream-clone-race-1 |
| 153 |
checking changesets |
| 154 |
checking manifests |
| 155 |
crosschecking files in changesets and manifests |
| 156 |
checking files |
| 157 |
checking dirstate |
| 158 |
checked 5001 changesets with 5001 changes to 5001 files |
| 159 |
|
| 160 |
We get a usable nodemap, so no rewrite would be needed and the metadata should be identical |
| 161 |
(ie: the following diff should be empty) |
| 162 |
|
| 163 |
This isn't the case for the `no-rust` `no-pure` implementation as it use a very minimal nodemap implementation that unconditionnaly rewrite the nodemap "all the time". |
| 164 |
|
| 165 |
#if no-rust no-pure |
| 166 |
$ diff -u server-metadata.txt client-metadata.txt |
| 167 |
--- server-metadata.txt * (glob) |
| 168 |
+++ client-metadata.txt * (glob) |
| 169 |
@@ -1,4 +1,4 @@ |
| 170 |
-uid: * (glob) |
| 171 |
+uid: * (glob) |
| 172 |
tip-rev: 5000 |
| 173 |
tip-node: 6b02b8c7b96654c25e86ba69eda198d7e6ad8b3c |
| 174 |
data-length: 121088 |
| 175 |
[1] |
| 176 |
#else |
| 177 |
$ diff -u server-metadata.txt client-metadata.txt |
| 178 |
#endif |
| 179 |
|
| 180 |
|
| 181 |
Clean up after the test. |
| 182 |
|
| 183 |
$ rm -f "$HG_TEST_STREAM_WALKED_FILE_3" |
| 184 |
$ rm -f "$HG_TEST_STREAM_WALKED_FILE_4" |
| 185 |
$ rm -f "$HG_TEST_STREAM_WALKED_FILE_5" |
| 186 |
|
| 187 |
full regeneration |
| 188 |
----------------- |
| 189 |
|
| 190 |
A full nodemap is generated |
| 191 |
|
| 192 |
(ideally this test would append enough data to make sure the nodemap data file |
| 193 |
get changed, however to make thing simpler we will force the regeneration for |
| 194 |
this test. |
| 195 |
|
| 196 |
Check the initial state |
| 197 |
|
| 198 |
$ f --size test-repo/.hg/store/00changelog* |
| 199 |
test-repo/.hg/store/00changelog-*.nd: size=121??? (glob) |
| 200 |
test-repo/.hg/store/00changelog.d: size=3????? (glob) |
| 201 |
test-repo/.hg/store/00changelog.i: size=320128 |
| 202 |
test-repo/.hg/store/00changelog.n: size=62 |
| 203 |
$ hg -R test-repo debugnodemap --metadata | tee server-metadata-2.txt |
| 204 |
uid: * (glob) |
| 205 |
tip-rev: 5001 |
| 206 |
tip-node: e63c23eaa88ae77967edcf4ea194d31167c478b0 |
| 207 |
data-length: 121408 (pure !) |
| 208 |
data-unused: 256 (pure !) |
| 209 |
data-unused: 0.211% (pure !) |
| 210 |
data-length: 121408 (rust !) |
| 211 |
data-unused: 256 (rust !) |
| 212 |
data-unused: 0.211% (rust !) |
| 213 |
data-length: 121152 (no-pure no-rust !) |
| 214 |
data-unused: 0 (no-pure no-rust !) |
| 215 |
data-unused: 0.000% (no-pure no-rust !) |
| 216 |
|
| 217 |
Performe the mix of clone and full refresh of the nodemap, so that the files |
| 218 |
(and filenames) are different between listing time and actual transfer time. |
| 219 |
|
| 220 |
$ (hg clone -U --stream ssh://user@dummy/test-repo stream-clone-race-2 --debug 2>> clone-output-2 | grep -E '00(changelog|manifest)' >> clone-output-2; touch $HG_TEST_STREAM_WALKED_FILE_5) & |
| 221 |
$ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_3 |
| 222 |
$ rm test-repo/.hg/store/00changelog.n |
| 223 |
$ rm test-repo/.hg/store/00changelog-*.nd |
| 224 |
$ hg -R test-repo/ debugupdatecache |
| 225 |
$ touch $HG_TEST_STREAM_WALKED_FILE_4 |
| 226 |
$ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_5 |
| 227 |
|
| 228 |
(note: the stream clone code wronly pick the `undo.` files) |
| 229 |
|
| 230 |
$ cat clone-output-2 |
| 231 |
adding [s] 00manifest.n (62 bytes) |
| 232 |
adding [s] 00manifest-*.nd (118 KB) (glob) |
| 233 |
adding [s] 00manifest.d (4?? KB) (glob) |
| 234 |
adding [s] 00manifest.i (313 KB) |
| 235 |
adding [s] 00changelog.n (62 bytes) |
| 236 |
adding [s] 00changelog-*.nd (11? KB) (glob) |
| 237 |
adding [s] 00changelog.d (3?? KB) (glob) |
| 238 |
adding [s] 00changelog.i (313 KB) |
| 239 |
|
| 240 |
Check the result. |
| 241 |
|
| 242 |
$ f --size stream-clone-race-2/.hg/store/00changelog* |
| 243 |
stream-clone-race-2/.hg/store/00changelog-*.nd: size=1????? (glob) |
| 244 |
stream-clone-race-2/.hg/store/00changelog.d: size=3????? (glob) |
| 245 |
stream-clone-race-2/.hg/store/00changelog.i: size=320128 |
| 246 |
stream-clone-race-2/.hg/store/00changelog.n: size=62 |
| 247 |
|
| 248 |
$ hg -R stream-clone-race-2 debugnodemap --metadata | tee client-metadata-2.txt |
| 249 |
uid: * (glob) |
| 250 |
tip-rev: 5001 |
| 251 |
tip-node: e63c23eaa88ae77967edcf4ea194d31167c478b0 |
| 252 |
data-length: 121408 (pure !) |
| 253 |
data-unused: 256 (pure !) |
| 254 |
data-unused: 0.211% (pure !) |
| 255 |
data-length: 121408 (rust !) |
| 256 |
data-unused: 256 (rust !) |
| 257 |
data-unused: 0.211% (rust !) |
| 258 |
data-length: 121152 (no-pure no-rust !) |
| 259 |
data-unused: 0 (no-pure no-rust !) |
| 260 |
data-unused: 0.000% (no-pure no-rust !) |
| 261 |
$ hg verify -R stream-clone-race-2 |
| 262 |
checking changesets |
| 263 |
checking manifests |
| 264 |
crosschecking files in changesets and manifests |
| 265 |
checking files |
| 266 |
checking dirstate |
| 267 |
checked 5002 changesets with 5002 changes to 5002 files |
| 268 |
|
| 269 |
We get a usable nodemap, so no rewrite would be needed and the metadata should be identical |
| 270 |
(ie: the following diff should be empty) |
| 271 |
|
| 272 |
This isn't the case for the `no-rust` `no-pure` implementation as it use a very minimal nodemap implementation that unconditionnaly rewrite the nodemap "all the time". |
| 273 |
|
| 274 |
#if no-rust no-pure |
| 275 |
$ diff -u server-metadata-2.txt client-metadata-2.txt |
| 276 |
--- server-metadata-2.txt * (glob) |
| 277 |
+++ client-metadata-2.txt * (glob) |
| 278 |
@@ -1,4 +1,4 @@ |
| 279 |
-uid: * (glob) |
| 280 |
+uid: * (glob) |
| 281 |
tip-rev: 5001 |
| 282 |
tip-node: e63c23eaa88ae77967edcf4ea194d31167c478b0 |
| 283 |
data-length: 121152 |
| 284 |
[1] |
| 285 |
#else |
| 286 |
$ diff -u server-metadata-2.txt client-metadata-2.txt |
| 287 |
#endif |
| 288 |
|
| 289 |
Clean up after the test |
| 290 |
|
| 291 |
$ rm -f $HG_TEST_STREAM_WALKED_FILE_3 |
| 292 |
$ rm -f $HG_TEST_STREAM_WALKED_FILE_4 |
| 293 |
$ rm -f $HG_TEST_STREAM_WALKED_FILE_5 |
| 294 |
|