1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
namespace WixToolsetTest.BurnE2E
{
using System.Threading;
using WixTestTools;
using WixToolset.BootstrapperApplicationApi;
using Xunit;
using Xunit.Abstractions;
public class FailureTests : BurnE2ETests
{
public FailureTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }
[RuntimeFact]
public void CanCancelExePackageAndAbandonIt()
{
var bundleD = this.CreateBundleInstaller("BundleD");
var testBAController = this.CreateTestBAController();
// Cancel package ExeA after it starts.
testBAController.SetPackageCancelExecuteAtProgress("ExeA", 1);
testBAController.SetPackageRecordTestRegistryValue("ExeA");
var logPath = bundleD.Install((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_USEREXIT);
bundleD.VerifyUnregisteredAndRemovedFromPackageCache();
Assert.True(LogVerifier.MessageInLogFile(logPath, "TestRegistryValue: Execute, ExeA, Version, ''"));
Assert.False(LogVerifier.MessageInLogFile(logPath, "TestRegistryValue: Rollback, ExeA, Version"));
}
[RuntimeFact]
public void CanCancelExePackageAndWaitUntilItCompletes()
{
var bundleD = this.CreateBundleInstaller("BundleD");
var testBAController = this.CreateTestBAController();
// Cancel package ExeA after it starts.
testBAController.SetPackageCancelExecuteAtProgress("ExeA", 1);
testBAController.SetPackageProcessCancelAction("ExeA", BOOTSTRAPPER_EXECUTEPROCESSCANCEL_ACTION.Wait);
testBAController.SetPackageRecordTestRegistryValue("ExeA");
var logPath = bundleD.Install((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_USEREXIT);
bundleD.VerifyUnregisteredAndRemovedFromPackageCache();
Assert.True(LogVerifier.MessageInLogFile(logPath, "TestRegistryValue: Execute, ExeA, Version, '1.0.0.0'"));
Assert.True(LogVerifier.MessageInLogFile(logPath, "TestRegistryValue: Rollback, ExeA, Version, ''"));
// The package should have rolled back.
bundleD.VerifyExeTestRegistryRootDeleted("ExeA");
}
[RuntimeFact]
public void CanCancelMsiPackageVeryEarly()
{
var packageA = this.CreatePackageInstaller("PackageA");
var packageB = this.CreatePackageInstaller("PackageB");
var bundleA = this.CreateBundleInstaller("BundleA");
var testBAController = this.CreateTestBAController();
// Cancel package B right away.
testBAController.SetPackageCancelExecuteAtProgress("PackageB", 1);
bundleA.Install((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_USEREXIT);
bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
packageA.VerifyInstalled(false);
packageB.VerifyInstalled(false);
}
[RuntimeFact]
public void CanCancelMsiPackageVeryLate()
{
var packageA = this.CreatePackageInstaller("PackageA");
var packageB = this.CreatePackageInstaller("PackageB");
var bundleA = this.CreateBundleInstaller("BundleA");
var testBAController = this.CreateTestBAController();
// Cancel package B at the last moment possible.
testBAController.SetPackageCancelExecuteAtProgress("PackageB", 100);
bundleA.Install((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_USEREXIT);
bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
packageA.VerifyInstalled(false);
packageB.VerifyInstalled(false);
}
[RuntimeFact]
public void CanCancelMsiPackageInOnProgress()
{
var packageA = this.CreatePackageInstaller("PackageA");
var packageB = this.CreatePackageInstaller("PackageB");
var bundleA = this.CreateBundleInstaller("BundleA");
var testBAController = this.CreateTestBAController();
// Cancel package B during its OnProgress message.
testBAController.SetPackageCancelOnProgressAtProgress("PackageB", 100);
bundleA.Install((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_USEREXIT);
bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
packageA.VerifyInstalled(false);
packageB.VerifyInstalled(false);
}
[RuntimeFact]
public void CanCancelExecuteWhileCaching()
{
var packageA = this.CreatePackageInstaller("PackageA");
var packageB = this.CreatePackageInstaller("PackageB");
var bundleB = this.CreateBundleInstaller("BundleB");
var testBAController = this.CreateTestBAController();
// Slow the caching of package B to ensure that package A starts installing and cancels.
testBAController.SetPackageCancelExecuteAtProgress("PackageA", 50);
testBAController.SetPackageSlowCache("PackageB", 2000);
bundleB.Install((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_USEREXIT);
bundleB.VerifyUnregisteredAndRemovedFromPackageCache();
packageA.VerifyInstalled(false);
packageB.VerifyInstalled(false);
}
/// <summary>
/// BundleC has non-vital PackageA and vital PackageB.
/// PackageA is not compressed in the bundle and has a Name different from the source file. The Name points to a file that does not exist.
/// BundleC should be able to install successfully by ignoring the missing PackageA and installing PackageB.
/// </summary>
[RuntimeFact]
public void CanInstallWhenMissingNonVitalPackage()
{
var packageA = this.CreatePackageInstaller("PackageA");
var packageB = this.CreatePackageInstaller("PackageB");
var bundleC = this.CreateBundleInstaller("BundleC");
var bundleCInstallLogFilePath = bundleC.Install();
bundleC.VerifyRegisteredAndInPackageCache();
Assert.True(LogVerifier.MessageInLogFileRegex(bundleCInstallLogFilePath, "Skipping apply of package: PackageA due to cache error: 0x80070002. Continuing..."));
packageA.VerifyInstalled(false);
packageB.VerifyInstalled(true);
bundleC.Uninstall();
bundleC.VerifyUnregisteredAndRemovedFromPackageCache();
packageA.VerifyInstalled(false);
packageB.VerifyInstalled(false);
}
}
}
|