main
cs 296 lines 14.3 KB
Raw
1 // 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.
2
3 namespace WixToolsetTest.BurnE2E
4 {
5 using System;
6 using System.IO;
7 using WixTestTools;
8 using Xunit;
9 using Xunit.Abstractions;
10
11 public class PrereqBaTests : BurnE2ETests
12 {
13 public PrereqBaTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }
14
15 const int E_PREREQBA_INFINITE_LOOP = -2_114_714_646;
16
17 /// <summary>
18 /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist,
19 /// with an MSI package to represent the prerequisite package.
20 /// This verifies that:
21 /// The preqba doesn't infinitely try to install prereqs.
22 /// The engine automatically uninstalls the bundle since only permanent packages were installed.
23 /// </summary>
24 [RuntimeFact(Skip = ".NET displays a message box when runtime is not present on the machine which hangs on CI systems. Skip this test until we can get a different behavior from .NET")]
25 public void DncAlwaysPreqBaDetectsInfiniteLoop()
26 {
27 var packageA = this.CreatePackageInstaller("PackageA");
28 var packageC = this.CreatePackageInstaller("PackageC");
29
30 var bundleC = this.CreateBundleInstaller("BundleC");
31
32 var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
33
34 // Source file should *not* be installed
35 Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
36 packageC.VerifyInstalled(false);
37
38 bundleC.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1");
39
40 // Part of the test is Install actually completing.
41
42 // Source file should be installed
43 Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
44 packageC.VerifyInstalled(false);
45
46 // No non-permanent packages should have ended up installed or cached so it should have unregistered.
47 bundleC.VerifyUnregisteredAndRemovedFromPackageCache();
48 }
49
50 /// <summary>
51 /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist,
52 /// with an MSI package to represent the prerequisite package.
53 /// This verifies that:
54 /// The preqba doesn't infinitely reload itself after failing to load the managed BA.
55 /// The engine automatically uninstalls the bundle since only permanent packages were installed.
56 /// </summary>
57 [RuntimeFact(Skip = ".NET displays a message box when runtime is not present on the machine which hangs on CI systems. Skip this test until we can get a different behavior from .NET")]
58 public void DncPreqBaDetectsInfiniteLoop()
59 {
60 var packageA = this.CreatePackageInstaller("PackageA");
61 var packageC = this.CreatePackageInstaller("PackageC");
62
63 var bundleA = this.CreateBundleInstaller("BundleA");
64
65 var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
66
67 // Source file should *not* be installed
68 Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
69 packageC.VerifyInstalled(false);
70
71 bundleA.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1");
72
73 // Part of the test is Install actually completing.
74
75 // Source file should be installed
76 Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
77 packageC.VerifyInstalled(false);
78
79 // No non-permanent packages should have ended up installed or cached so it should have unregistered.
80 bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
81 }
82
83 /// <summary>
84 /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist,
85 /// with an EXE prereq package to swap it out with a good one.
86 /// This verifies that:
87 /// The preqba doesn't infinitely try to install prereqs.
88 /// The managed BA gets loaded after installing prereqs.
89 /// </summary>
90 [RuntimeFact]
91 public void DncAlwaysPreqBaLoadsManagedBaAfterInstallingPrereqs()
92 {
93 var packageA = this.CreatePackageInstaller("PackageA");
94 var packageC = this.CreatePackageInstaller("PackageC");
95
96 var bundleC = this.CreateBundleInstaller("BundleC");
97
98 var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
99
100 // Source file should *not* be installed
101 Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
102 packageC.VerifyInstalled(false);
103
104 bundleC.Install();
105
106 // Source file should be installed
107 Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
108 packageC.VerifyInstalled(true);
109
110 bundleC.VerifyRegisteredAndInPackageCache();
111
112 bundleC.Uninstall();
113
114 bundleC.VerifyUnregisteredAndRemovedFromPackageCache();
115 }
116
117 /// <summary>
118 /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist,
119 /// with an EXE prereq package to swap it out with a good one.
120 /// This verifies that:
121 /// The preqba doesn't infinitely reload itself after failing to load the managed BA.
122 /// The managed BA gets loaded after installing prereqs.
123 /// </summary>
124 [RuntimeFact]
125 public void DncPreqBaLoadsManagedBaAfterInstallingPrereqs()
126 {
127 var packageA = this.CreatePackageInstaller("PackageA");
128 var packageC = this.CreatePackageInstaller("PackageC");
129
130 var bundleA = this.CreateBundleInstaller("BundleA");
131
132 var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
133
134 // Source file should *not* be installed
135 Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
136 packageC.VerifyInstalled(false);
137
138 bundleA.Install();
139
140 // Source file should be installed
141 Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
142 packageC.VerifyInstalled(true);
143
144 bundleA.VerifyRegisteredAndInPackageCache();
145
146 bundleA.Uninstall();
147
148 bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
149 }
150
151 [RuntimeFact]
152 public void DncAlwaysPreqBaForwardsHelpToManagedBa()
153 {
154 var bundleE = this.CreateBundleInstaller("BundleE");
155
156 var bundleLog = bundleE.Help();
157
158 Assert.True(LogVerifier.MessageInLogFile(bundleLog, "This is a BA for automated testing"));
159 }
160
161 /// <summary>
162 /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist,
163 /// with an MSI package to represent the prerequisite package.
164 /// This verifies that:
165 /// The preqba doesn't infinitely try to install prereqs.
166 /// The engine automatically uninstalls the bundle since only permanent packages were installed.
167 /// </summary>
168 [RuntimeFact(Skip = ".NET displays a message box when runtime is not present on the machine which hangs on CI systems. Skip this test until we can get a different behavior from .NET")]
169 public void MbaAlwaysPreqBaDetectsInfiniteLoop()
170 {
171 var packageB = this.CreatePackageInstaller("PackageB");
172 var packageC = this.CreatePackageInstaller("PackageC");
173
174 var bundleD = this.CreateBundleInstaller("BundleD");
175
176 var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs");
177
178 // Source file should *not* be installed
179 Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}");
180 packageC.VerifyInstalled(false);
181
182 bundleD.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1");
183
184 // Part of the test is Install actually completing.
185
186 // Source file should be installed
187 Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled));
188 packageC.VerifyInstalled(false);
189
190 // No non-permanent packages should have ended up installed or cached so it should have unregistered.
191 bundleD.VerifyUnregisteredAndRemovedFromPackageCache();
192 }
193
194 /// <summary>
195 /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist,
196 /// with an MSI package to represent the prerequisite package.
197 /// This verifies that:
198 /// The preqba doesn't infinitely reload itself after failing to load the managed BA.
199 /// The engine automatically uninstalls the bundle since only permanent packages were installed.
200 /// </summary>
201 [RuntimeFact(Skip = ".NET displays a message box when runtime is not present on the machine which hangs on CI systems. Skip this test until we can get a different behavior from .NET")]
202 public void MbaPreqBaDetectsInfiniteLoop()
203 {
204 var packageB = this.CreatePackageInstaller("PackageB");
205 var packageC = this.CreatePackageInstaller("PackageC");
206
207 var bundleB = this.CreateBundleInstaller("BundleB");
208
209 var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs");
210
211 // Source file should *not* be installed
212 Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}");
213 packageC.VerifyInstalled(false);
214
215 bundleB.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1");
216
217 // Part of the test is Install actually completing.
218
219 // Source file should be installed
220 Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled));
221 packageC.VerifyInstalled(false);
222
223 // No non-permanent packages should have ended up installed or cached so it should have unregistered.
224 bundleB.VerifyUnregisteredAndRemovedFromPackageCache();
225 }
226
227 /// <summary>
228 /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist,
229 /// with an EXE prereq package to swap it out with a good one.
230 /// This verifies that:
231 /// The preqba doesn't infinitely try to install prereqs.
232 /// The managed BA gets loaded after installing prereqs.
233 /// </summary>
234 [RuntimeFact]
235 public void MbaAlwaysPreqBaLoadsManagedBaAfterInstallingPrereqs()
236 {
237 var packageB = this.CreatePackageInstaller("PackageB");
238 var packageC = this.CreatePackageInstaller("PackageC");
239
240 var bundleD = this.CreateBundleInstaller("BundleD");
241
242 var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs");
243
244 // Source file should *not* be installed
245 Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}");
246 packageC.VerifyInstalled(false);
247
248 bundleD.Install();
249
250 // Source file should be installed
251 Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled));
252 packageC.VerifyInstalled(true);
253
254 bundleD.VerifyRegisteredAndInPackageCache();
255
256 bundleD.Uninstall();
257
258 bundleD.VerifyUnregisteredAndRemovedFromPackageCache();
259 }
260
261 /// <summary>
262 /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist,
263 /// with an EXE prereq package to swap it out with a good one.
264 /// This verifies that:
265 /// The preqba doesn't infinitely reload itself after failing to load the managed BA.
266 /// The managed BA gets loaded after installing prereqs.
267 /// </summary>
268 [RuntimeFact]
269 public void MbaPreqBaLoadsManagedBaAfterInstallingPrereqs()
270 {
271 var packageB = this.CreatePackageInstaller("PackageB");
272 var packageC = this.CreatePackageInstaller("PackageC");
273
274 var bundleB = this.CreateBundleInstaller("BundleB");
275
276 var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs");
277
278 // Source file should *not* be installed
279 Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}");
280 packageC.VerifyInstalled(false);
281
282 bundleB.Install();
283
284 // Source file should be installed
285 Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled));
286 packageC.VerifyInstalled(true);
287
288 bundleB.VerifyRegisteredAndInPackageCache();
289
290 bundleB.Uninstall();
291
292 // No non-permanent packages should have ended up installed or cached so it should have unregistered.
293 bundleB.VerifyUnregisteredAndRemovedFromPackageCache();
294 }
295 }
296 }