diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-01-22 15:59:13 -0600 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-01-22 16:03:02 -0600 |
commit | c8b602e595bced83dad206ce40189634432f1f07 (patch) | |
tree | bd3b781cdabfeb43e17d2ea283c2b11e9974430b /src/Utilities | |
parent | 1eaef3495a36ff275f06359f10e07199f2054ad3 (diff) | |
download | wix-c8b602e595bced83dad206ce40189634432f1f07.tar.gz wix-c8b602e595bced83dad206ce40189634432f1f07.tar.bz2 wix-c8b602e595bced83dad206ce40189634432f1f07.zip |
Add test that cancels an MSI package in the OnProgress for the package.
This makes it cancel after the MSI install completed but before Burn considers the package complete, which needs to cause Burn to roll it back (#3089).
Also add more logging in TestBA when it does non-standard stuff.
Diffstat (limited to 'src/Utilities')
-rw-r--r-- | src/Utilities/TestBA/TestBA.cs | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/src/Utilities/TestBA/TestBA.cs b/src/Utilities/TestBA/TestBA.cs index e3305d33..2a4bd581 100644 --- a/src/Utilities/TestBA/TestBA.cs +++ b/src/Utilities/TestBA/TestBA.cs | |||
@@ -29,6 +29,8 @@ namespace WixToolset.Test.BA | |||
29 | private int cancelCacheAtProgress; | 29 | private int cancelCacheAtProgress; |
30 | private int sleepDuringExecute; | 30 | private int sleepDuringExecute; |
31 | private int cancelExecuteAtProgress; | 31 | private int cancelExecuteAtProgress; |
32 | private string cancelExecuteActionName; | ||
33 | private int cancelOnProgressAtProgress; | ||
32 | private int retryExecuteFilesInUse; | 34 | private int retryExecuteFilesInUse; |
33 | 35 | ||
34 | private IBootstrapperCommand Command { get; } | 36 | private IBootstrapperCommand Command { get; } |
@@ -227,24 +229,34 @@ namespace WixToolset.Test.BA | |||
227 | { | 229 | { |
228 | this.sleepDuringCache = 0; | 230 | this.sleepDuringCache = 0; |
229 | } | 231 | } |
232 | else | ||
233 | { | ||
234 | this.Log(" SlowCache: {0}", this.sleepDuringCache); | ||
235 | } | ||
230 | 236 | ||
231 | string cancelCache = this.ReadPackageAction(args.PackageId, "CancelCacheAtProgress"); | 237 | string cancelCache = this.ReadPackageAction(args.PackageId, "CancelCacheAtProgress"); |
232 | if (String.IsNullOrEmpty(cancelCache) || !Int32.TryParse(cancelCache, out this.cancelCacheAtProgress)) | 238 | if (String.IsNullOrEmpty(cancelCache) || !Int32.TryParse(cancelCache, out this.cancelCacheAtProgress)) |
233 | { | 239 | { |
234 | this.cancelCacheAtProgress = -1; | 240 | this.cancelCacheAtProgress = -1; |
235 | } | 241 | } |
242 | else | ||
243 | { | ||
244 | this.Log(" CancelCacheAtProgress: {0}", this.cancelCacheAtProgress); | ||
245 | } | ||
236 | } | 246 | } |
237 | 247 | ||
238 | protected override void OnCacheAcquireProgress(CacheAcquireProgressEventArgs args) | 248 | protected override void OnCacheAcquireProgress(CacheAcquireProgressEventArgs args) |
239 | { | 249 | { |
240 | this.Log("OnCacheAcquireProgress() - container/package: {0}, payload: {1}, progress: {2}, total: {3}, overall progress: {4}%", args.PackageOrContainerId, args.PayloadId, args.Progress, args.Total, args.OverallPercentage); | 250 | this.Log("OnCacheAcquireProgress() - container/package: {0}, payload: {1}, progress: {2}, total: {3}, overall progress: {4}%", args.PackageOrContainerId, args.PayloadId, args.Progress, args.Total, args.OverallPercentage); |
241 | 251 | ||
242 | if (this.cancelCacheAtProgress > 0 && this.cancelCacheAtProgress <= args.Progress) | 252 | if (this.cancelCacheAtProgress >= 0 && this.cancelCacheAtProgress <= args.Progress) |
243 | { | 253 | { |
244 | args.Cancel = true; | 254 | args.Cancel = true; |
255 | this.Log("OnCacheAcquireProgress(cancel)"); | ||
245 | } | 256 | } |
246 | else if (this.sleepDuringCache > 0) | 257 | else if (this.sleepDuringCache > 0) |
247 | { | 258 | { |
259 | this.Log("OnCacheAcquireProgress(sleep {0})", this.sleepDuringCache); | ||
248 | Thread.Sleep(this.sleepDuringCache); | 260 | Thread.Sleep(this.sleepDuringCache); |
249 | } | 261 | } |
250 | } | 262 | } |
@@ -258,18 +270,46 @@ namespace WixToolset.Test.BA | |||
258 | { | 270 | { |
259 | this.sleepDuringExecute = 0; | 271 | this.sleepDuringExecute = 0; |
260 | } | 272 | } |
273 | else | ||
274 | { | ||
275 | this.Log(" SlowExecute: {0}", this.sleepDuringExecute); | ||
276 | } | ||
261 | 277 | ||
262 | string cancelExecute = this.ReadPackageAction(args.PackageId, "CancelExecuteAtProgress"); | 278 | string cancelExecute = this.ReadPackageAction(args.PackageId, "CancelExecuteAtProgress"); |
263 | if (String.IsNullOrEmpty(cancelExecute) || !Int32.TryParse(cancelExecute, out this.cancelExecuteAtProgress)) | 279 | if (String.IsNullOrEmpty(cancelExecute) || !Int32.TryParse(cancelExecute, out this.cancelExecuteAtProgress)) |
264 | { | 280 | { |
265 | this.cancelExecuteAtProgress = -1; | 281 | this.cancelExecuteAtProgress = -1; |
266 | } | 282 | } |
283 | else | ||
284 | { | ||
285 | this.Log(" CancelExecuteAtProgress: {0}", this.cancelExecuteAtProgress); | ||
286 | } | ||
287 | |||
288 | this.cancelExecuteActionName = this.ReadPackageAction(args.PackageId, "CancelExecuteAtActionStart"); | ||
289 | if (!String.IsNullOrEmpty(this.cancelExecuteActionName)) | ||
290 | { | ||
291 | this.Log(" CancelExecuteAtActionState: {0}", this.cancelExecuteActionName); | ||
292 | } | ||
293 | |||
294 | string cancelOnProgressAtProgress = this.ReadPackageAction(args.PackageId, "CancelOnProgressAtProgress"); | ||
295 | if (String.IsNullOrEmpty(cancelOnProgressAtProgress) || !Int32.TryParse(cancelOnProgressAtProgress, out this.cancelOnProgressAtProgress)) | ||
296 | { | ||
297 | this.cancelOnProgressAtProgress = -1; | ||
298 | } | ||
299 | else | ||
300 | { | ||
301 | this.Log(" CancelOnProgressAtProgress: {0}", this.cancelOnProgressAtProgress); | ||
302 | } | ||
267 | 303 | ||
268 | string retryBeforeCancel = this.ReadPackageAction(args.PackageId, "RetryExecuteFilesInUse"); | 304 | string retryBeforeCancel = this.ReadPackageAction(args.PackageId, "RetryExecuteFilesInUse"); |
269 | if (String.IsNullOrEmpty(retryBeforeCancel) || !Int32.TryParse(retryBeforeCancel, out this.retryExecuteFilesInUse)) | 305 | if (String.IsNullOrEmpty(retryBeforeCancel) || !Int32.TryParse(retryBeforeCancel, out this.retryExecuteFilesInUse)) |
270 | { | 306 | { |
271 | this.retryExecuteFilesInUse = 0; | 307 | this.retryExecuteFilesInUse = 0; |
272 | } | 308 | } |
309 | else | ||
310 | { | ||
311 | this.Log(" RetryExecuteFilesInUse: {0}", this.retryExecuteFilesInUse); | ||
312 | } | ||
273 | } | 313 | } |
274 | 314 | ||
275 | protected override void OnExecuteFilesInUse(ExecuteFilesInUseEventArgs args) | 315 | protected override void OnExecuteFilesInUse(ExecuteFilesInUseEventArgs args) |
@@ -287,16 +327,30 @@ namespace WixToolset.Test.BA | |||
287 | } | 327 | } |
288 | } | 328 | } |
289 | 329 | ||
330 | protected override void OnExecuteMsiMessage(ExecuteMsiMessageEventArgs args) | ||
331 | { | ||
332 | this.Log("OnExecuteMsiMessage() - MessageType: {0}, Message: {1}, Data: '{2}'", args.MessageType, args.Message, String.Join("','", args.Data.ToArray())); | ||
333 | |||
334 | if (!String.IsNullOrEmpty(this.cancelExecuteActionName) && args.MessageType == InstallMessage.ActionStart && | ||
335 | args.Data.Count > 0 && args.Data[0] == this.cancelExecuteActionName) | ||
336 | { | ||
337 | this.Log("OnExecuteMsiMessage(cancelNextProgress)"); | ||
338 | this.cancelExecuteAtProgress = 0; | ||
339 | } | ||
340 | } | ||
341 | |||
290 | protected override void OnExecuteProgress(ExecuteProgressEventArgs args) | 342 | protected override void OnExecuteProgress(ExecuteProgressEventArgs args) |
291 | { | 343 | { |
292 | this.Log("OnExecuteProgress() - package: {0}, progress: {1}%, overall progress: {2}%", args.PackageId, args.ProgressPercentage, args.OverallPercentage); | 344 | this.Log("OnExecuteProgress() - package: {0}, progress: {1}%, overall progress: {2}%", args.PackageId, args.ProgressPercentage, args.OverallPercentage); |
293 | 345 | ||
294 | if (this.cancelExecuteAtProgress > 0 && this.cancelExecuteAtProgress <= args.ProgressPercentage) | 346 | if (this.cancelExecuteAtProgress >= 0 && this.cancelExecuteAtProgress <= args.ProgressPercentage) |
295 | { | 347 | { |
296 | args.Cancel = true; | 348 | args.Cancel = true; |
349 | this.Log("OnExecuteProgress(cancel)"); | ||
297 | } | 350 | } |
298 | else if (this.sleepDuringExecute > 0) | 351 | else if (this.sleepDuringExecute > 0) |
299 | { | 352 | { |
353 | this.Log("OnExecuteProgress(sleep {0})", this.sleepDuringExecute); | ||
300 | Thread.Sleep(this.sleepDuringExecute); | 354 | Thread.Sleep(this.sleepDuringExecute); |
301 | } | 355 | } |
302 | } | 356 | } |
@@ -313,6 +367,12 @@ namespace WixToolset.Test.BA | |||
313 | { | 367 | { |
314 | this.Engine.SendEmbeddedProgress(args.ProgressPercentage, args.OverallPercentage); | 368 | this.Engine.SendEmbeddedProgress(args.ProgressPercentage, args.OverallPercentage); |
315 | } | 369 | } |
370 | |||
371 | if (this.cancelOnProgressAtProgress >= 0 && this.cancelOnProgressAtProgress <= args.OverallPercentage) | ||
372 | { | ||
373 | args.Cancel = true; | ||
374 | this.Log("OnProgress(cancel)"); | ||
375 | } | ||
316 | } | 376 | } |
317 | 377 | ||
318 | protected override void OnResolveSource(ResolveSourceEventArgs args) | 378 | protected override void OnResolveSource(ResolveSourceEventArgs args) |
@@ -323,6 +383,13 @@ namespace WixToolset.Test.BA | |||
323 | } | 383 | } |
324 | } | 384 | } |
325 | 385 | ||
386 | protected override void OnApplyBegin(ApplyBeginEventArgs args) | ||
387 | { | ||
388 | this.cancelOnProgressAtProgress = -1; | ||
389 | this.cancelExecuteAtProgress = -1; | ||
390 | this.cancelCacheAtProgress = -1; | ||
391 | } | ||
392 | |||
326 | protected override void OnApplyComplete(ApplyCompleteEventArgs args) | 393 | protected override void OnApplyComplete(ApplyCompleteEventArgs args) |
327 | { | 394 | { |
328 | // Output what the privileges are now. | 395 | // Output what the privileges are now. |