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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
// 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;
using System.IO;
using WixTestTools;
using WixToolset.Mba.Core;
using Xunit;
using Xunit.Abstractions;
public class BundlePackageTests : BurnE2ETests
{
public BundlePackageTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }
[RuntimeFact]
public void CanBuildBundlePackagesWithRemoteBundles()
{
var multipleBundlePackagesWithRemoteBundle = this.CreateBundleInstaller("MultipleBundlePackagesWithRemoteBundle");
multipleBundlePackagesWithRemoteBundle.Install();
// Bundle only contains permanent packages, so it isn't registered
multipleBundlePackagesWithRemoteBundle.VerifyUnregisteredAndRemovedFromPackageCache();
}
[RuntimeFact]
public void CanInstallAndUninstallBundlePackages()
{
var packageA = this.CreatePackageInstaller(@"..\BasicFunctionalityTests\PackageA");
var packageA_x64 = this.CreatePackageInstaller(@"..\BasicFunctionalityTests\PackageA_x64");
var bundleA = this.CreateBundleInstaller(@"..\BasicFunctionalityTests\BundleA");
var bundleB_x64 = this.CreateBundleInstaller(@"..\BasicFunctionalityTests\BundleB_x64");
var multipleBundlePackagesBundle = this.CreateBundleInstaller(@"MultipleBundlePackagesBundle");
var packageA32SourceCodeFilePath = packageA.GetInstalledFilePath("Package.wxs");
var packageA64SourceCodeFilePath = packageA_x64.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageA32SourceCodeFilePath), $"PackageA payload should not be there on test start: {packageA32SourceCodeFilePath}");
Assert.False(File.Exists(packageA64SourceCodeFilePath), $"PackageA_x64 payload should not be there on test start: {packageA64SourceCodeFilePath}");
multipleBundlePackagesBundle.Install();
multipleBundlePackagesBundle.VerifyRegisteredAndInPackageCache();
bundleA.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1);
bundleB_x64.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1);
// Source file should be installed
Assert.True(File.Exists(packageA32SourceCodeFilePath), $"Should have found PackageA payload installed at: {packageA32SourceCodeFilePath}");
Assert.True(File.Exists(packageA64SourceCodeFilePath), $"Should have found PackageA_x64 payload installed at: {packageA64SourceCodeFilePath}");
multipleBundlePackagesBundle.Uninstall();
multipleBundlePackagesBundle.VerifyUnregisteredAndRemovedFromPackageCache();
bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
bundleB_x64.VerifyUnregisteredAndRemovedFromPackageCache();
// Source file should *not* be installed
Assert.False(File.Exists(packageA32SourceCodeFilePath), $"PackageA payload should have been removed by uninstall from: {packageA32SourceCodeFilePath}");
Assert.False(File.Exists(packageA64SourceCodeFilePath), $"PackageA_x64 payload should have been removed by uninstall from: {packageA64SourceCodeFilePath}");
}
[RuntimeFact]
public void CanInstallUpgradeBundlePackage()
{
var bundleAv1 = this.CreateBundleInstaller(@"..\UpgradeRelatedBundleTests\BundleAv1");
var bundleAv2 = this.CreateBundleInstaller(@"..\UpgradeRelatedBundleTests\BundleAv2");
var upgradeBundlePackageBundlev2 = this.CreateBundleInstaller("UpgradeBundlePackageBundlev2");
bundleAv1.Install();
bundleAv1.VerifyRegisteredAndInPackageCache();
upgradeBundlePackageBundlev2.Install();
upgradeBundlePackageBundlev2.VerifyRegisteredAndInPackageCache();
bundleAv2.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1);
bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
}
[RuntimeFact]
public void CanInstallV3BundlePackage()
{
var v3BundleId = "{215a70db-ab35-48c7-be51-d66eaac87177}";
var v3BundleName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Package Cache", v3BundleId, "CustomV3Theme");
var v3Bundle = new BundleInstaller(this.TestContext, v3BundleName);
this.AddBundleInstaller(v3Bundle);
var v3BundlePackageBundle = this.CreateBundleInstaller("V3BundlePackageBundle");
Assert.False(File.Exists(v3Bundle.Bundle), "v3bundle.exe was already installed");
var logPath = v3BundlePackageBundle.Install();
v3BundlePackageBundle.VerifyRegisteredAndInPackageCache();
Assert.True(LogVerifier.MessageInLogFile(logPath, "Applied execute package: v3bundle.exe, result: 0x0, restart: None"));
Assert.True(BundleRegistration.TryGetPerMachineBundleRegistrationById(v3BundleId, false, out var v3Registration));
Assert.Null(v3Registration.SystemComponent);
}
[RuntimeFact]
public void CanLeaveBundlePackageVisible()
{
var bundleAv1 = this.CreateBundleInstaller(@"..\UpgradeRelatedBundleTests\BundleAv1");
var upgradeBundlePackageBundlev1 = this.CreateBundleInstaller("UpgradeBundlePackageBundlev1");
bundleAv1.Install();
bundleAv1.VerifyRegisteredAndInPackageCache();
upgradeBundlePackageBundlev1.Install();
upgradeBundlePackageBundlev1.VerifyRegisteredAndInPackageCache();
bundleAv1.VerifyRegisteredAndInPackageCache();
upgradeBundlePackageBundlev1.Uninstall();
upgradeBundlePackageBundlev1.VerifyUnregisteredAndRemovedFromPackageCache();
bundleAv1.VerifyRegisteredAndInPackageCache();
}
[RuntimeFact]
public void CanReferenceCountBundlePackage()
{
var bundleAv1 = this.CreateBundleInstaller(@"..\UpgradeRelatedBundleTests\BundleAv1");
var upgradeBundlePackageBundlev1 = this.CreateBundleInstaller("UpgradeBundlePackageBundlev1");
upgradeBundlePackageBundlev1.Install();
upgradeBundlePackageBundlev1.VerifyRegisteredAndInPackageCache();
bundleAv1.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1);
// Repair bundle so it adds itself as a reference to itself.
bundleAv1.Repair();
bundleAv1.VerifyRegisteredAndInPackageCache();
upgradeBundlePackageBundlev1.Uninstall();
upgradeBundlePackageBundlev1.VerifyUnregisteredAndRemovedFromPackageCache();
bundleAv1.VerifyRegisteredAndInPackageCache();
}
[RuntimeFact]
public void CanSkipObsoleteBundlePackage()
{
var bundleAv1 = this.CreateBundleInstaller(@"..\UpgradeRelatedBundleTests\BundleAv1");
var bundleAv2 = this.CreateBundleInstaller(@"..\UpgradeRelatedBundleTests\BundleAv2");
var upgradeBundlePackageBundlev1 = this.CreateBundleInstaller("UpgradeBundlePackageBundlev1");
bundleAv2.Install();
bundleAv2.VerifyRegisteredAndInPackageCache();
upgradeBundlePackageBundlev1.Install();
upgradeBundlePackageBundlev1.VerifyUnregisteredAndRemovedFromPackageCache();
bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache();
}
[RuntimeFact]
public void CanRecacheAndReinstallBundlePackageOnUninstallRollback()
{
var packageFail = this.CreatePackageInstaller("PackageFail");
var packageA = this.CreatePackageInstaller(@"..\BasicFunctionalityTests\PackageA");
var bundleA = this.CreateBundleInstaller(@"..\BasicFunctionalityTests\BundleA");
var bundlePackageUninstallFailureBundle = this.CreateBundleInstaller("BundlePackageUninstallFailureBundle");
var testBAController = this.CreateTestBAController();
var bundleASelfCachedPath = bundleA.GetExpectedCachedBundlePath();
var bundleAEmbeddedCachedPath = bundlePackageUninstallFailureBundle.GetPackageEntryPointCachePath("PackageA");
packageA.VerifyInstalled(false);
packageFail.VerifyInstalled(false);
bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
testBAController.SetPackageRequestedCacheType("PackageA", BOOTSTRAPPER_CACHE_TYPE.Remove);
var installLogPath = bundlePackageUninstallFailureBundle.Install();
bundlePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache();
packageFail.VerifyInstalled(true);
bundleA.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1);
Assert.False(LogVerifier.MessageInLogFile(installLogPath, $"Applying execute package: PackageA, action: Install, path: {bundleASelfCachedPath}"), bundleASelfCachedPath);
Assert.True(LogVerifier.MessageInLogFile(installLogPath, $"Applying execute package: PackageA, action: Install, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath);
testBAController.ResetPackageStates("PackageA");
testBAController.SetAllowAcquireAfterValidationFailure();
var uninstallLogPath = bundlePackageUninstallFailureBundle.Uninstall((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE, "FAILWHENDEFERRED=1");
bundlePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache();
bundleA.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1);
packageFail.VerifyInstalled(true);
Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, "TESTBA: OnCachePackageNonVitalValidationFailure() - id: PackageA, default: None, requested: Acquire"));
Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying execute package: PackageA, action: Uninstall, path: {bundleASelfCachedPath}"), bundleASelfCachedPath);
Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying execute package: PackageA, action: Uninstall, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath);
Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying rollback package: PackageA, action: Install, path: {bundleASelfCachedPath}"), bundleASelfCachedPath);
Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying rollback package: PackageA, action: Install, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath);
}
[RuntimeFact]
public void CanReinstallBundlePackageOnUninstallRollback()
{
var packageFail = this.CreatePackageInstaller("PackageFail");
var packageA = this.CreatePackageInstaller(@"..\BasicFunctionalityTests\PackageA");
var bundleA = this.CreateBundleInstaller(@"..\BasicFunctionalityTests\BundleA");
var bundlePackageUninstallFailureBundle = this.CreateBundleInstaller("BundlePackageUninstallFailureBundle");
var bundleASelfCachedPath = bundleA.GetExpectedCachedBundlePath();
var bundleAEmbeddedCachedPath = bundlePackageUninstallFailureBundle.GetPackageEntryPointCachePath("PackageA");
packageA.VerifyInstalled(false);
packageFail.VerifyInstalled(false);
bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
var installLogPath = bundlePackageUninstallFailureBundle.Install();
bundlePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache();
packageFail.VerifyInstalled(true);
bundleA.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1);
Assert.False(LogVerifier.MessageInLogFile(installLogPath, $"Applying execute package: PackageA, action: Install, path: {bundleASelfCachedPath}"), bundleASelfCachedPath);
Assert.True(LogVerifier.MessageInLogFile(installLogPath, $"Applying execute package: PackageA, action: Install, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath);
var uninstallLogPath = bundlePackageUninstallFailureBundle.Uninstall((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE, "FAILWHENDEFERRED=1");
bundlePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache();
bundleA.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1);
packageFail.VerifyInstalled(true);
Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, "TESTBA: OnCachePackageNonVitalValidationFailure() - id: PackageA"));
Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying execute package: PackageA, action: Uninstall, path: {bundleASelfCachedPath}"), bundleASelfCachedPath);
Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying execute package: PackageA, action: Uninstall, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath);
Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying rollback package: PackageA, action: Install, path: {bundleASelfCachedPath}"), bundleASelfCachedPath);
Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying rollback package: PackageA, action: Install, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath);
}
[RuntimeFact]
public void CanSkipReinstallBundlePackageOnUninstallRollback()
{
var packageFail = this.CreatePackageInstaller("PackageFail");
var packageA = this.CreatePackageInstaller(@"..\BasicFunctionalityTests\PackageA");
var bundleA = this.CreateBundleInstaller(@"..\BasicFunctionalityTests\BundleA");
var bundlePackageUninstallFailureBundle = this.CreateBundleInstaller("BundlePackageUninstallFailureBundle");
var testBAController = this.CreateTestBAController();
var bundleASelfCachedPath = bundleA.GetExpectedCachedBundlePath();
var bundleAEmbeddedCachedPath = bundlePackageUninstallFailureBundle.GetPackageEntryPointCachePath("PackageA");
packageA.VerifyInstalled(false);
packageFail.VerifyInstalled(false);
bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
testBAController.SetPackageRequestedCacheType("PackageA", BOOTSTRAPPER_CACHE_TYPE.Remove);
var installLogPath = bundlePackageUninstallFailureBundle.Install();
bundlePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache();
packageFail.VerifyInstalled(true);
bundleA.VerifyRegisteredAndInPackageCache(expectedSystemComponent: 1);
Assert.False(LogVerifier.MessageInLogFile(installLogPath, $"Applying execute package: PackageA, action: Install, path: {bundleASelfCachedPath}"), bundleASelfCachedPath);
Assert.True(LogVerifier.MessageInLogFile(installLogPath, $"Applying execute package: PackageA, action: Install, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath);
var uninstallLogPath = bundlePackageUninstallFailureBundle.Uninstall((int)MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE, "FAILWHENDEFERRED=1");
bundlePackageUninstallFailureBundle.VerifyRegisteredAndInPackageCache();
bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
packageFail.VerifyInstalled(true);
Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, "TESTBA: OnCachePackageNonVitalValidationFailure() - id: PackageA, default: None, requested: None"));
Assert.True(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying execute package: PackageA, action: Uninstall, path: {bundleASelfCachedPath}"), bundleASelfCachedPath);
Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying execute package: PackageA, action: Uninstall, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath);
Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying rollback package: PackageA, action: Install, path: {bundleASelfCachedPath}"), bundleASelfCachedPath);
Assert.False(LogVerifier.MessageInLogFile(uninstallLogPath, $"Applying rollback package: PackageA, action: Install, path: {bundleAEmbeddedCachedPath}"), bundleAEmbeddedCachedPath);
}
}
}
|