##// END OF EJS Templates
clone-bundles: add more test cases for automatic generation...
marmoute -
r51305:a53b8ddf default
parent child Browse files
Show More
@@ -1,258 +1,320 b''
1 1
2 2 #require no-reposimplestore no-chg
3 3
4 4 initial setup
5 5
6 6 $ hg init server
7 7 $ cat >> server/.hg/hgrc << EOF
8 8 > [extensions]
9 9 > clonebundles =
10 10 >
11 11 > [clone-bundles]
12 12 > auto-generate.on-change = yes
13 13 > auto-generate.formats = v2
14 14 > upload-command = cp "\$HGCB_BUNDLE_PATH" "$TESTTMP"/final-upload/
15 15 > delete-command = rm -f "$TESTTMP/final-upload/\$HGCB_BASENAME"
16 16 > url-template = file://$TESTTMP/final-upload/{basename}
17 17 >
18 18 > [devel]
19 19 > debug.clonebundles=yes
20 20 > EOF
21 21
22 22 $ mkdir final-upload
23 23 $ hg clone server client
24 24 updating to branch default
25 25 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
26 26 $ cd client
27 27
28 28 Test bundles are generated on push
29 29 ==================================
30 30
31 31 $ touch foo
32 32 $ hg -q commit -A -m 'add foo'
33 33 $ touch bar
34 34 $ hg -q commit -A -m 'add bar'
35 35 $ hg push
36 36 pushing to $TESTTMP/server
37 37 searching for changes
38 38 adding changesets
39 39 adding manifests
40 40 adding file changes
41 41 2 changesets found
42 42 added 2 changesets with 2 changes to 2 files
43 43 clone-bundles: starting bundle generation: v2
44 44 $ cat ../server/.hg/clonebundles.manifest
45 45 file:/*/$TESTTMP/final-upload/full-v2-2_revs-aaff8d2ffbbf_tip-*_txn.hg BUNDLESPEC=v2 REQUIRESNI=true (glob)
46 46 $ ls -1 ../final-upload
47 47 full-v2-2_revs-aaff8d2ffbbf_tip-*_txn.hg (glob)
48 48 $ ls -1 ../server/.hg/tmp-bundles
49 49
50 50 Newer bundles are generated with more pushes
51 51 --------------------------------------------
52 52
53 53 $ touch baz
54 54 $ hg -q commit -A -m 'add baz'
55 55 $ touch buz
56 56 $ hg -q commit -A -m 'add buz'
57 57 $ hg push
58 58 pushing to $TESTTMP/server
59 59 searching for changes
60 60 adding changesets
61 61 adding manifests
62 62 adding file changes
63 63 4 changesets found
64 64 added 2 changesets with 2 changes to 2 files
65 65 clone-bundles: starting bundle generation: v2
66 66
67 67 $ cat ../server/.hg/clonebundles.manifest
68 68 file:/*/$TESTTMP/final-upload/full-v2-4_revs-6427147b985a_tip-*_txn.hg BUNDLESPEC=v2 REQUIRESNI=true (glob)
69 69 $ ls -1 ../final-upload
70 70 full-v2-2_revs-aaff8d2ffbbf_tip-*_txn.hg (glob)
71 71 full-v2-4_revs-6427147b985a_tip-*_txn.hg (glob)
72 72 $ ls -1 ../server/.hg/tmp-bundles
73 73
74 74 Older bundles are cleaned up with more pushes
75 75 ---------------------------------------------
76 76
77 77 $ touch faz
78 78 $ hg -q commit -A -m 'add faz'
79 79 $ touch fuz
80 80 $ hg -q commit -A -m 'add fuz'
81 81 $ hg push
82 82 pushing to $TESTTMP/server
83 83 searching for changes
84 84 adding changesets
85 85 adding manifests
86 86 adding file changes
87 87 clone-bundles: deleting bundle full-v2-2_revs-aaff8d2ffbbf_tip-*_txn.hg (glob)
88 88 6 changesets found
89 89 added 2 changesets with 2 changes to 2 files
90 90 clone-bundles: starting bundle generation: v2
91 91
92 92 $ cat ../server/.hg/clonebundles.manifest
93 93 file:/*/$TESTTMP/final-upload/full-v2-6_revs-b1010e95ea00_tip-*_txn.hg BUNDLESPEC=v2 REQUIRESNI=true (glob)
94 94 $ ls -1 ../final-upload
95 95 full-v2-4_revs-6427147b985a_tip-*_txn.hg (glob)
96 96 full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob)
97 97 $ ls -1 ../server/.hg/tmp-bundles
98 98
99 99 Test conditions to get them generated
100 100 =====================================
101 101
102 102 Check ratio
103 103
104 104 $ cat >> ../server/.hg/hgrc << EOF
105 105 > [clone-bundles]
106 106 > trigger.below-bundled-ratio = 0.5
107 107 > EOF
108 108 $ touch far
109 109 $ hg -q commit -A -m 'add far'
110 110 $ hg push
111 111 pushing to $TESTTMP/server
112 112 searching for changes
113 113 adding changesets
114 114 adding manifests
115 115 adding file changes
116 116 added 1 changesets with 1 changes to 1 files
117 117 $ cat ../server/.hg/clonebundles.manifest
118 118 file:/*/$TESTTMP/final-upload/full-v2-6_revs-b1010e95ea00_tip-*_txn.hg BUNDLESPEC=v2 REQUIRESNI=true (glob)
119 119 $ ls -1 ../final-upload
120 120 full-v2-4_revs-6427147b985a_tip-*_txn.hg (glob)
121 121 full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob)
122 122 $ ls -1 ../server/.hg/tmp-bundles
123 123
124 124 Check absolute number of revisions
125 125
126 126 $ cat >> ../server/.hg/hgrc << EOF
127 127 > [clone-bundles]
128 128 > trigger.revs = 2
129 129 > EOF
130 130 $ touch bur
131 131 $ hg -q commit -A -m 'add bur'
132 132 $ hg push
133 133 pushing to $TESTTMP/server
134 134 searching for changes
135 135 adding changesets
136 136 adding manifests
137 137 adding file changes
138 138 clone-bundles: deleting bundle full-v2-4_revs-6427147b985a_tip-*_txn.hg (glob)
139 139 8 changesets found
140 140 added 1 changesets with 1 changes to 1 files
141 141 clone-bundles: starting bundle generation: v2
142 142 $ cat ../server/.hg/clonebundles.manifest
143 143 file:/*/$TESTTMP/final-upload/full-v2-8_revs-8353e8af1306_tip-*_txn.hg BUNDLESPEC=v2 REQUIRESNI=true (glob)
144 144 $ ls -1 ../final-upload
145 145 full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob)
146 146 full-v2-8_revs-8353e8af1306_tip-*_txn.hg (glob)
147 147 $ ls -1 ../server/.hg/tmp-bundles
148 148
149 149 (that one would not generate new bundles)
150 150
151 151 $ touch tur
152 152 $ hg -q commit -A -m 'add tur'
153 153 $ hg push
154 154 pushing to $TESTTMP/server
155 155 searching for changes
156 156 adding changesets
157 157 adding manifests
158 158 adding file changes
159 159 added 1 changesets with 1 changes to 1 files
160 160 $ cat ../server/.hg/clonebundles.manifest
161 161 file:/*/$TESTTMP/final-upload/full-v2-8_revs-8353e8af1306_tip-*_txn.hg BUNDLESPEC=v2 REQUIRESNI=true (glob)
162 162 $ ls -1 ../final-upload
163 163 full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob)
164 164 full-v2-8_revs-8353e8af1306_tip-*_txn.hg (glob)
165 165 $ ls -1 ../server/.hg/tmp-bundles
166 166
167 167 Test generation through the dedicated command
168 168 =============================================
169 169
170 170 $ cat >> ../server/.hg/hgrc << EOF
171 171 > [clone-bundles]
172 172 > auto-generate.on-change = no
173 173 > EOF
174 174
175 175 Check the command can generate content when needed
176 176 --------------------------------------------------
177 177
178 178 Do a push that makes the condition fulfilled,
179 179 Yet it should not automatically generate a bundle with
180 180 "auto-generate.on-change" not set.
181 181
182 182 $ touch quoi
183 183 $ hg -q commit -A -m 'add quoi'
184 184
185 185 $ pre_push_manifest=`cat ../server/.hg/clonebundles.manifest|f --sha256 | sed 's/.*=//' | cat`
186 186 $ pre_push_upload=`ls -1 ../final-upload|f --sha256 | sed 's/.*=//' | cat`
187 187 $ ls -1 ../server/.hg/tmp-bundles
188 188
189 189 $ hg push
190 190 pushing to $TESTTMP/server
191 191 searching for changes
192 192 adding changesets
193 193 adding manifests
194 194 adding file changes
195 195 added 1 changesets with 1 changes to 1 files
196 196
197 197 $ post_push_manifest=`cat ../server/.hg/clonebundles.manifest|f --sha256 | sed 's/.*=//' | cat`
198 198 $ post_push_upload=`ls -1 ../final-upload|f --sha256 | sed 's/.*=//' | cat`
199 199 $ ls -1 ../server/.hg/tmp-bundles
200 200 $ test "$pre_push_manifest" = "$post_push_manifest"
201 201 $ test "$pre_push_upload" = "$post_push_upload"
202 202
203 203 Running the command should detect the stale bundles, and do the full automatic
204 204 generation logic.
205 205
206 206 $ hg -R ../server/ admin::clone-bundles-refresh
207 207 clone-bundles: deleting bundle full-v2-6_revs-b1010e95ea00_tip-*_txn.hg (glob)
208 208 clone-bundles: starting bundle generation: v2
209 209 10 changesets found
210 210 $ cat ../server/.hg/clonebundles.manifest
211 211 file:/*/$TESTTMP/final-upload/full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg BUNDLESPEC=v2 REQUIRESNI=true (glob)
212 212 $ ls -1 ../final-upload
213 213 full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg (glob)
214 214 full-v2-8_revs-8353e8af1306_tip-*_txn.hg (glob)
215 215 $ ls -1 ../server/.hg/tmp-bundles
216 216
217 217 Check the command cleans up older bundles when possible
218 218 -------------------------------------------------------
219 219
220 220 $ hg -R ../server/ admin::clone-bundles-refresh
221 221 clone-bundles: deleting bundle full-v2-8_revs-8353e8af1306_tip-*_txn.hg (glob)
222 222 $ cat ../server/.hg/clonebundles.manifest
223 223 file:/*/$TESTTMP/final-upload/full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg BUNDLESPEC=v2 REQUIRESNI=true (glob)
224 224 $ ls -1 ../final-upload
225 225 full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg (glob)
226 226 $ ls -1 ../server/.hg/tmp-bundles
227 227
228 228 Nothing is generated when the bundles are sufficiently up to date
229 229 -----------------------------------------------------------------
230 230
231 231 $ touch feur
232 232 $ hg -q commit -A -m 'add feur'
233 233
234 234 $ pre_push_manifest=`cat ../server/.hg/clonebundles.manifest|f --sha256 | sed 's/.*=//' | cat`
235 235 $ pre_push_upload=`ls -1 ../final-upload|f --sha256 | sed 's/.*=//' | cat`
236 236 $ ls -1 ../server/.hg/tmp-bundles
237 237
238 238 $ hg push
239 239 pushing to $TESTTMP/server
240 240 searching for changes
241 241 adding changesets
242 242 adding manifests
243 243 adding file changes
244 244 added 1 changesets with 1 changes to 1 files
245 245
246 246 $ post_push_manifest=`cat ../server/.hg/clonebundles.manifest|f --sha256 | sed 's/.*=//' | cat`
247 247 $ post_push_upload=`ls -1 ../final-upload|f --sha256 | sed 's/.*=//' | cat`
248 248 $ ls -1 ../server/.hg/tmp-bundles
249 249 $ test "$pre_push_manifest" = "$post_push_manifest"
250 250 $ test "$pre_push_upload" = "$post_push_upload"
251 251
252 252 $ hg -R ../server/ admin::clone-bundles-refresh
253 253
254 254 $ post_refresh_manifest=`cat ../server/.hg/clonebundles.manifest|f --sha256 | sed 's/.*=//' | cat`
255 255 $ post_refresh_upload=`ls -1 ../final-upload|f --sha256 | sed 's/.*=//' | cat`
256 256 $ ls -1 ../server/.hg/tmp-bundles
257 257 $ test "$pre_push_manifest" = "$post_refresh_manifest"
258 258 $ test "$pre_push_upload" = "$post_refresh_upload"
259
260 Test modification of configuration
261 ==================================
262
263 Testing that later runs adapt to configuration changes even if the repository is
264 unchanged.
265
266 adding more formats
267 -------------------
268
269 bundle for added formats should be generated
270
271 change configuration
272
273 $ cat >> ../server/.hg/hgrc << EOF
274 > [clone-bundles]
275 > auto-generate.formats = v1, v2
276 > EOF
277
278 refresh the bundles
279
280 $ hg -R ../server/ admin::clone-bundles-refresh
281 clone-bundles: starting bundle generation: v1
282 11 changesets found
283
284 the bundle for the "new" format should have been added
285
286 $ cat ../server/.hg/clonebundles.manifest
287 file:/*/$TESTTMP/final-upload/full-v1-11_revs-4226b1cd5fda_tip-*_acbr.hg BUNDLESPEC=v1 REQUIRESNI=true (glob)
288 file:/*/$TESTTMP/final-upload/full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg BUNDLESPEC=v2 REQUIRESNI=true (glob)
289 $ ls -1 ../final-upload
290 full-v1-11_revs-4226b1cd5fda_tip-*_acbr.hg (glob)
291 full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg (glob)
292 $ ls -1 ../server/.hg/tmp-bundles
293
294 Changing the ratio
295 ------------------
296
297 Changing the ratio to something that would have triggered a bundle during the last push.
298
299 $ cat >> ../server/.hg/hgrc << EOF
300 > [clone-bundles]
301 > trigger.below-bundled-ratio = 0.95
302 > EOF
303
304 refresh the bundles
305
306 $ hg -R ../server/ admin::clone-bundles-refresh
307 clone-bundles: starting bundle generation: v2
308 11 changesets found
309
310
311 the "outdated' bundle should be refreshed
312
313 $ cat ../server/.hg/clonebundles.manifest
314 file:/*/$TESTTMP/final-upload/full-v1-11_revs-4226b1cd5fda_tip-*_acbr.hg BUNDLESPEC=v1 REQUIRESNI=true (glob)
315 file:/*/$TESTTMP/final-upload/full-v2-11_revs-4226b1cd5fda_tip-*_acbr.hg BUNDLESPEC=v2 REQUIRESNI=true (glob)
316 $ ls -1 ../final-upload
317 full-v1-11_revs-4226b1cd5fda_tip-*_acbr.hg (glob)
318 full-v2-10_revs-3b6f57f17d70_tip-*_acbr.hg (glob)
319 full-v2-11_revs-4226b1cd5fda_tip-*_acbr.hg (glob)
320 $ ls -1 ../server/.hg/tmp-bundles
General Comments 0
You need to be logged in to leave comments. Login now