| 1 |
Test stream cloning while a revlog split happens |
| 2 |
------------------------------------------------ |
| 3 |
|
| 4 |
#testcases stream-bundle2-v2 stream-bundle2-v3 |
| 5 |
#testcases fncache fileindex |
| 6 |
|
| 7 |
#if stream-bundle2-v3 |
| 8 |
$ cat << EOF >> $HGRCPATH |
| 9 |
> [experimental] |
| 10 |
> stream-v3 = yes |
| 11 |
> EOF |
| 12 |
#endif |
| 13 |
|
| 14 |
#if fileindex |
| 15 |
$ cat >> $HGRCPATH << EOF |
| 16 |
> [format] |
| 17 |
> use-fileindex-v1=yes |
| 18 |
> EOF |
| 19 |
#else |
| 20 |
$ cat >> $HGRCPATH << EOF |
| 21 |
> [format] |
| 22 |
> use-fileindex-v1=no |
| 23 |
> EOF |
| 24 |
#endif |
| 25 |
|
| 26 |
#if fileindex no-rust |
| 27 |
$ cat >> $HGRCPATH << EOF |
| 28 |
> [storage] |
| 29 |
> fileindex.slow-path=allow |
| 30 |
> EOF |
| 31 |
#endif |
| 32 |
|
| 33 |
setup a repository for tests |
| 34 |
---------------------------- |
| 35 |
|
| 36 |
$ cat >> $HGRCPATH << EOF |
| 37 |
> [format] |
| 38 |
> # skip compression to make it easy to trigger a split |
| 39 |
> revlog-compression=none |
| 40 |
> [phases] |
| 41 |
> publish=no |
| 42 |
> EOF |
| 43 |
|
| 44 |
$ hg init server |
| 45 |
$ cd server |
| 46 |
$ file="some-file" |
| 47 |
$ printf '%20d' '1' > $file |
| 48 |
$ hg commit -Aqma |
| 49 |
$ printf '%1024d' '1' > $file |
| 50 |
$ hg commit -Aqmb |
| 51 |
$ printf '%20d' '1' > $file |
| 52 |
$ hg commit -Aqmc |
| 53 |
|
| 54 |
check the revlog is inline |
| 55 |
|
| 56 |
$ f -s .hg/store/data/some-file* |
| 57 |
.hg/store/data/some-file.i: size=1259 |
| 58 |
$ hg debug-revlog-index some-file |
| 59 |
rev linkrev nodeid p1-nodeid p2-nodeid |
| 60 |
0 0 ed70cecbc103 000000000000 000000000000 |
| 61 |
1 1 7241018db64c ed70cecbc103 000000000000 |
| 62 |
2 2 fa1120531cc1 7241018db64c 000000000000 |
| 63 |
$ cd .. |
| 64 |
|
| 65 |
setup synchronisation file |
| 66 |
|
| 67 |
$ HG_TEST_STREAM_WALKED_FILE_1="$TESTTMP/sync_file_walked_1" |
| 68 |
$ export HG_TEST_STREAM_WALKED_FILE_1 |
| 69 |
$ HG_TEST_STREAM_WALKED_FILE_2="$TESTTMP/sync_file_walked_2" |
| 70 |
$ export HG_TEST_STREAM_WALKED_FILE_2 |
| 71 |
$ HG_TEST_STREAM_WALKED_FILE_3="$TESTTMP/sync_file_walked_3" |
| 72 |
$ export HG_TEST_STREAM_WALKED_FILE_3 |
| 73 |
$ HG_TEST_STREAM_WALKED_FILE_4="$TESTTMP/sync_file_walked_4" |
| 74 |
$ export HG_TEST_STREAM_WALKED_FILE_4 |
| 75 |
$ HG_TEST_STREAM_WALKED_FILE_5="$TESTTMP/sync_file_walked_5" |
| 76 |
$ export HG_TEST_STREAM_WALKED_FILE_5 |
| 77 |
(we don't need this wait point) |
| 78 |
$ touch $HG_TEST_STREAM_WALKED_FILE_2 |
| 79 |
|
| 80 |
|
| 81 |
Test stream-clone raced by a revlog-split |
| 82 |
========================================= |
| 83 |
|
| 84 |
Test stream-clone where the file is split right after the lock section is done |
| 85 |
|
| 86 |
Start the server |
| 87 |
|
| 88 |
$ hg serve -R server \ |
| 89 |
> -p $HGPORT1 -d --error errors.log --pid-file=hg.pid \ |
| 90 |
> --config extensions.stream_steps="$RUNTESTDIR/testlib/ext-stream-clone-steps.py" |
| 91 |
$ cat hg.pid >> $DAEMON_PIDS |
| 92 |
|
| 93 |
Start a client doing a streaming clone |
| 94 |
|
| 95 |
$ ( \ |
| 96 |
> hg clone --debug --stream -U http://localhost:$HGPORT1 \ |
| 97 |
> clone-while-split --config worker.backgroundclose=0 > client.log 2>&1; \ |
| 98 |
> touch "$HG_TEST_STREAM_WALKED_FILE_5" \ |
| 99 |
> ) & |
| 100 |
|
| 101 |
Wait for the server to be done collecting data |
| 102 |
|
| 103 |
$ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_3 |
| 104 |
|
| 105 |
trigger a split |
| 106 |
|
| 107 |
$ dd if=/dev/zero of=server/$file bs=1k count=128 > /dev/null 2>&1 |
| 108 |
$ hg -R server ci -m "triggering a split" --config ui.timeout.warn=-1 |
| 109 |
|
| 110 |
unlock the stream generation |
| 111 |
|
| 112 |
$ touch $HG_TEST_STREAM_WALKED_FILE_4 |
| 113 |
|
| 114 |
wait for the client to be done cloning. |
| 115 |
|
| 116 |
$ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_5 |
| 117 |
|
| 118 |
Check everything is fine |
| 119 |
|
| 120 |
$ cat client.log |
| 121 |
using http://localhost:$HGPORT1/ |
| 122 |
sending capabilities command |
| 123 |
query 1; heads |
| 124 |
sending batch command |
| 125 |
streaming all changes |
| 126 |
sending getbundle command |
| 127 |
bundle2-input-bundle: with-transaction |
| 128 |
bundle2-input-part: "stream2" (params: 3 mandatory) supported (stream-bundle2-v2 !) |
| 129 |
bundle2-input-part: "stream3-exp" (params: 1 mandatory) supported (stream-bundle2-v3 !) |
| 130 |
applying stream bundle |
| 131 |
8 files to transfer, 2.11 KB of data (stream-bundle2-v2 no-rust !) |
| 132 |
10 files to transfer, 2.29 KB of data (stream-bundle2-v2 rust !) |
| 133 |
adding [s] data/some-file.i (1.23 KB) (stream-bundle2-v2 !) |
| 134 |
7 entries to transfer (stream-bundle2-v3 !) |
| 135 |
adding [s] data/some-file.d (1.04 KB) (stream-bundle2-v3 !) |
| 136 |
adding [s] data/some-file.i (192 bytes) (stream-bundle2-v3 !) |
| 137 |
adding [s] phaseroots (43 bytes) |
| 138 |
adding [s] 00manifest.i (348 bytes) |
| 139 |
adding [s] 00changelog.n (62 bytes) (rust !) |
| 140 |
adding [s] 00changelog-88698448.nd (128 bytes) (rust !) |
| 141 |
adding [s] 00changelog.d (189 bytes) |
| 142 |
adding [s] 00changelog.i (192 bytes) |
| 143 |
adding [c] branch2-served (94 bytes) |
| 144 |
adding [c] rbc-names-v2 (7 bytes) |
| 145 |
adding [c] rbc-revs-v2 (24 bytes) |
| 146 |
updating the branch cache |
| 147 |
stream-cloned 9 files / 2.11 KB in * seconds (* */sec) (glob) (no-rust stream-bundle2-v3 !) |
| 148 |
stream-cloned 11 files / 2.29 KB in * seconds (* */sec) (glob) (rust stream-bundle2-v3 !) |
| 149 |
bundle2-input-part: total payload size 2285 (stream-bundle2-v2 no-rust !) |
| 150 |
bundle2-input-part: total payload size 2518 (stream-bundle2-v2 rust !) |
| 151 |
bundle2-input-part: total payload size 2313 (stream-bundle2-v3 no-rust !) |
| 152 |
bundle2-input-part: total payload size 2546 (stream-bundle2-v3 rust !) |
| 153 |
stream-cloned 8 files / 2.11 KB in * seconds (* */sec) (glob) (no-rust stream-bundle2-v2 !) |
| 154 |
stream-cloned 10 files / 2.29 KB in * seconds (* */sec) (glob) (rust stream-bundle2-v2 !) |
| 155 |
bundle2-input-part: "listkeys" (params: 1 mandatory) supported |
| 156 |
bundle2-input-bundle: 2 parts total |
| 157 |
checking for updated bookmarks |
| 158 |
updating the branch cache |
| 159 |
(sent 3 HTTP requests and * bytes; received * bytes in responses) (glob) |
| 160 |
$ tail -2 errors.log |
| 161 |
$ hg -R clone-while-split verify |
| 162 |
checking changesets |
| 163 |
checking manifests |
| 164 |
crosschecking files in changesets and manifests |
| 165 |
checking files |
| 166 |
checking dirstate |
| 167 |
checked 3 changesets with 3 changes to 1 files |
| 168 |
$ hg -R clone-while-split tip |
| 169 |
changeset: 2:dbd9854c38a6 |
| 170 |
tag: tip |
| 171 |
user: test |
| 172 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 173 |
summary: c |
| 174 |
|
| 175 |
$ hg -R clone-while-split debug-revlog-index some-file |
| 176 |
rev linkrev nodeid p1-nodeid p2-nodeid |
| 177 |
0 0 ed70cecbc103 000000000000 000000000000 |
| 178 |
1 1 7241018db64c ed70cecbc103 000000000000 |
| 179 |
2 2 fa1120531cc1 7241018db64c 000000000000 |
| 180 |
$ hg -R server phase --rev 'all()' |
| 181 |
0: draft |
| 182 |
1: draft |
| 183 |
2: draft |
| 184 |
3: draft |
| 185 |
$ hg -R clone-while-split phase --rev 'all()' |
| 186 |
0: draft |
| 187 |
1: draft |
| 188 |
2: draft |
| 189 |
|
| 190 |
subsequent pull work |
| 191 |
|
| 192 |
$ hg -R clone-while-split pull |
| 193 |
pulling from http://localhost:$HGPORT1/ |
| 194 |
searching for changes |
| 195 |
adding changesets |
| 196 |
adding manifests |
| 197 |
adding file changes |
| 198 |
added 1 changesets with 1 changes to 1 files |
| 199 |
new changesets df05c6cb1406 (1 drafts) |
| 200 |
(run 'hg update' to get a working copy) |
| 201 |
|
| 202 |
$ hg -R clone-while-split debug-revlog-index some-file |
| 203 |
rev linkrev nodeid p1-nodeid p2-nodeid |
| 204 |
0 0 ed70cecbc103 000000000000 000000000000 |
| 205 |
1 1 7241018db64c ed70cecbc103 000000000000 |
| 206 |
2 2 fa1120531cc1 7241018db64c 000000000000 |
| 207 |
3 3 a631378adaa3 fa1120531cc1 000000000000 |
| 208 |
$ hg -R clone-while-split verify |
| 209 |
checking changesets |
| 210 |
checking manifests |
| 211 |
crosschecking files in changesets and manifests |
| 212 |
checking files |
| 213 |
checking dirstate |
| 214 |
checked 4 changesets with 4 changes to 1 files |
| 215 |
|
| 216 |
Cloning after the split also works |
| 217 |
|
| 218 |
$ hg clone --stream -U http://localhost:$HGPORT1 clone-after-split |
| 219 |
streaming all changes |
| 220 |
10 files to transfer, 130 KB of data (stream-bundle2-v2 no-rust !) |
| 221 |
12 files to transfer, 131 KB of data (stream-bundle2-v2 rust !) |
| 222 |
8 entries to transfer (stream-bundle2-v3 !) |
| 223 |
stream-cloned 10 files / 130 KB in * seconds (* */sec) (glob) (no-rust !) |
| 224 |
stream-cloned 12 files / 131 KB in * seconds (* */sec) (glob) (rust !) |