diff options
Diffstat (limited to 'src/test/burn/WixToolsetTest.BurnE2E/UpdateBundleTests.cs')
-rw-r--r-- | src/test/burn/WixToolsetTest.BurnE2E/UpdateBundleTests.cs | 245 |
1 files changed, 245 insertions, 0 deletions
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/UpdateBundleTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/UpdateBundleTests.cs new file mode 100644 index 00000000..9fcd428b --- /dev/null +++ b/src/test/burn/WixToolsetTest.BurnE2E/UpdateBundleTests.cs | |||
@@ -0,0 +1,245 @@ | |||
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.Collections.Generic; | ||
7 | using System.Diagnostics; | ||
8 | using System.IO; | ||
9 | using Xunit; | ||
10 | using Xunit.Abstractions; | ||
11 | |||
12 | public class UpdateBundleTests : BurnE2ETests | ||
13 | { | ||
14 | public UpdateBundleTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } | ||
15 | |||
16 | [Fact] | ||
17 | public void CanLaunchUpdateBundleFromLocalSourceInsteadOfInstall() | ||
18 | { | ||
19 | var packageAv1 = this.CreatePackageInstaller("PackageAv1"); | ||
20 | var packageAv2 = this.CreatePackageInstaller("PackageAv2"); | ||
21 | var bundleAv1 = this.CreateBundleInstaller("BundleAv1"); | ||
22 | var bundleAv2 = this.CreateBundleInstaller("BundleAv2"); | ||
23 | |||
24 | var updateBundleSwitch = String.Concat("\"", "-updatebundle:", bundleAv2.Bundle, "\""); | ||
25 | |||
26 | packageAv1.VerifyInstalled(false); | ||
27 | packageAv2.VerifyInstalled(false); | ||
28 | |||
29 | // Install the v2 bundle by getting v1 to launch it as an update bundle. | ||
30 | bundleAv1.Install(arguments: updateBundleSwitch); | ||
31 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
32 | bundleAv2.VerifyRegisteredAndInPackageCache(); | ||
33 | |||
34 | packageAv1.VerifyInstalled(false); | ||
35 | packageAv2.VerifyInstalled(true); | ||
36 | |||
37 | bundleAv2.Uninstall(); | ||
38 | bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
39 | packageAv2.VerifyInstalled(false); | ||
40 | } | ||
41 | |||
42 | [Fact] | ||
43 | public void CanLaunchUpdateBundleFromLocalSourceInsteadOfModify() | ||
44 | { | ||
45 | var packageAv1 = this.CreatePackageInstaller("PackageAv1"); | ||
46 | var packageAv2 = this.CreatePackageInstaller("PackageAv2"); | ||
47 | var bundleAv1 = this.CreateBundleInstaller("BundleAv1"); | ||
48 | var bundleAv2 = this.CreateBundleInstaller("BundleAv2"); | ||
49 | |||
50 | var updateBundleSwitch = String.Concat("\"", "-updatebundle:", bundleAv2.Bundle, "\""); | ||
51 | |||
52 | packageAv1.VerifyInstalled(false); | ||
53 | packageAv2.VerifyInstalled(false); | ||
54 | |||
55 | bundleAv1.Install(); | ||
56 | bundleAv1.VerifyRegisteredAndInPackageCache(); | ||
57 | |||
58 | packageAv1.VerifyInstalled(true); | ||
59 | packageAv2.VerifyInstalled(false); | ||
60 | |||
61 | // Install the v2 bundle by getting v1 to launch it as an update bundle. | ||
62 | bundleAv1.Modify(arguments: updateBundleSwitch); | ||
63 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
64 | bundleAv2.VerifyRegisteredAndInPackageCache(); | ||
65 | |||
66 | packageAv1.VerifyInstalled(false); | ||
67 | packageAv2.VerifyInstalled(true); | ||
68 | |||
69 | bundleAv2.Uninstall(); | ||
70 | bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
71 | packageAv2.VerifyInstalled(false); | ||
72 | } | ||
73 | |||
74 | [Fact] | ||
75 | public void ForwardsArgumentsToUpdateBundle() | ||
76 | { | ||
77 | var packageAv1 = this.CreatePackageInstaller("PackageAv1"); | ||
78 | var packageAv2 = this.CreatePackageInstaller("PackageAv2"); | ||
79 | var bundleAv1 = this.CreateBundleInstaller("BundleAv1"); | ||
80 | var bundleAv2 = this.CreateBundleInstaller("BundleAv2"); | ||
81 | var testBAController = this.CreateTestBAController(); | ||
82 | |||
83 | const string verifyArguments = "these arguments should exist"; | ||
84 | var updateBundleSwitch = String.Concat("\"", "-updatebundle:", bundleAv2.Bundle, "\" ", verifyArguments); | ||
85 | |||
86 | testBAController.SetVerifyArguments(verifyArguments); | ||
87 | |||
88 | packageAv1.VerifyInstalled(false); | ||
89 | packageAv2.VerifyInstalled(false); | ||
90 | |||
91 | // Install the v2 bundle by getting v1 to launch it as an update bundle. | ||
92 | bundleAv1.Install(arguments: updateBundleSwitch); | ||
93 | bundleAv1.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
94 | bundleAv2.VerifyRegisteredAndInPackageCache(); | ||
95 | |||
96 | packageAv1.VerifyInstalled(false); | ||
97 | packageAv2.VerifyInstalled(true); | ||
98 | |||
99 | // Attempt to uninstall bundleA2 without the verify arguments passed and expect failure code. | ||
100 | bundleAv2.Uninstall(expectedExitCode: -1); | ||
101 | |||
102 | // Remove the required arguments and uninstall again. | ||
103 | testBAController.SetVerifyArguments(null); | ||
104 | bundleAv2.Uninstall(); | ||
105 | bundleAv2.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
106 | packageAv2.VerifyInstalled(false); | ||
107 | } | ||
108 | |||
109 | // Installs bundle Bv1.0 then tries to update to latest version during modify (but no server exists). | ||
110 | [Fact] | ||
111 | public void CanCheckUpdateServerDuringModifyAndDoNothingWhenServerIsntResponsive() | ||
112 | { | ||
113 | var packageB = this.CreatePackageInstaller("PackageBv1"); | ||
114 | var bundleB = this.CreateBundleInstaller("BundleBv1"); | ||
115 | |||
116 | packageB.VerifyInstalled(false); | ||
117 | |||
118 | bundleB.Install(); | ||
119 | bundleB.VerifyRegisteredAndInPackageCache(); | ||
120 | |||
121 | packageB.VerifyInstalled(true); | ||
122 | |||
123 | // Run the v1 bundle requesting an update bundle. | ||
124 | bundleB.Modify(arguments: "-checkupdate"); | ||
125 | bundleB.VerifyRegisteredAndInPackageCache(); | ||
126 | |||
127 | // Verify nothing changed. | ||
128 | packageB.VerifyInstalled(true); | ||
129 | |||
130 | bundleB.Uninstall(); | ||
131 | bundleB.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
132 | packageB.VerifyInstalled(false); | ||
133 | } | ||
134 | |||
135 | // Installs bundle Bv1.0 then tries to update to latest version during modify (server exists, no feed). | ||
136 | [Fact] | ||
137 | public void CanCheckUpdateServerDuringModifyAndDoNothingWhenFeedIsMissing() | ||
138 | { | ||
139 | var packageB = this.CreatePackageInstaller("PackageBv1"); | ||
140 | var bundleB = this.CreateBundleInstaller("BundleBv1"); | ||
141 | var webServer = this.CreateWebServer(); | ||
142 | |||
143 | webServer.Start(); | ||
144 | |||
145 | packageB.VerifyInstalled(false); | ||
146 | |||
147 | bundleB.Install(); | ||
148 | bundleB.VerifyRegisteredAndInPackageCache(); | ||
149 | |||
150 | packageB.VerifyInstalled(true); | ||
151 | |||
152 | // Run the v1 bundle requesting an update bundle. | ||
153 | bundleB.Modify(arguments: "-checkupdate"); | ||
154 | bundleB.VerifyRegisteredAndInPackageCache(); | ||
155 | |||
156 | // Verify nothing changed. | ||
157 | packageB.VerifyInstalled(true); | ||
158 | |||
159 | bundleB.Uninstall(); | ||
160 | bundleB.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
161 | packageB.VerifyInstalled(false); | ||
162 | } | ||
163 | |||
164 | // Installs bundle Bv1.0 then tries to update to latest version during modify (server exists, v1.0 feed). | ||
165 | [Fact] | ||
166 | public void CanCheckUpdateServerDuringModifyAndDoNothingWhenAlreadyLatestVersion() | ||
167 | { | ||
168 | var packageB = this.CreatePackageInstaller("PackageBv1"); | ||
169 | var bundleB = this.CreateBundleInstaller("BundleBv1"); | ||
170 | var webServer = this.CreateWebServer(); | ||
171 | |||
172 | webServer.AddFiles(new Dictionary<string, string> | ||
173 | { | ||
174 | { "/BundleB/feed", Path.Combine(this.TestContext.TestDataFolder, "FeedBv1.0.xml") }, | ||
175 | }); | ||
176 | webServer.Start(); | ||
177 | |||
178 | packageB.VerifyInstalled(false); | ||
179 | |||
180 | bundleB.Install(); | ||
181 | bundleB.VerifyRegisteredAndInPackageCache(); | ||
182 | |||
183 | packageB.VerifyInstalled(true); | ||
184 | |||
185 | // Run the v1 bundle requesting an update bundle. | ||
186 | bundleB.Modify(arguments: "-checkupdate"); | ||
187 | bundleB.VerifyRegisteredAndInPackageCache(); | ||
188 | |||
189 | // Verify nothing changed. | ||
190 | packageB.VerifyInstalled(true); | ||
191 | |||
192 | bundleB.Uninstall(); | ||
193 | bundleB.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
194 | packageB.VerifyInstalled(false); | ||
195 | } | ||
196 | |||
197 | // Installs bundle Bv1.0 then does an update to bundle Bv2.0 during modify (server exists, v2.0 feed). | ||
198 | [Fact] | ||
199 | public void CanLaunchUpdateBundleFromDownloadInsteadOfModify() | ||
200 | { | ||
201 | var packageBv1 = this.CreatePackageInstaller("PackageBv1"); | ||
202 | var packageBv2 = this.CreatePackageInstaller("PackageBv2"); | ||
203 | var bundleBv1 = this.CreateBundleInstaller("BundleBv1"); | ||
204 | var bundleBv2 = this.CreateBundleInstaller("BundleBv2"); | ||
205 | var webServer = this.CreateWebServer(); | ||
206 | |||
207 | webServer.AddFiles(new Dictionary<string, string> | ||
208 | { | ||
209 | { "/BundleB/feed", Path.Combine(this.TestContext.TestDataFolder, "FeedBv2.0.xml") }, | ||
210 | { "/BundleB/2.0/BundleB.exe", bundleBv2.Bundle }, | ||
211 | }); | ||
212 | webServer.Start(); | ||
213 | |||
214 | packageBv1.VerifyInstalled(false); | ||
215 | packageBv2.VerifyInstalled(false); | ||
216 | |||
217 | bundleBv1.Install(); | ||
218 | bundleBv1.VerifyRegisteredAndInPackageCache(); | ||
219 | |||
220 | packageBv1.VerifyInstalled(true); | ||
221 | packageBv2.VerifyInstalled(false); | ||
222 | |||
223 | // Run the v1 bundle requesting an update bundle. | ||
224 | bundleBv1.Modify(arguments: "-checkupdate"); | ||
225 | |||
226 | // The modify -> update is asynchronous, so we need to wait until the real BundleB is done | ||
227 | var childBundles = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(bundleBv2.Bundle)); | ||
228 | foreach (var childBundle in childBundles) | ||
229 | { | ||
230 | childBundle.WaitForExit(); | ||
231 | } | ||
232 | |||
233 | bundleBv1.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
234 | bundleBv2.VerifyRegisteredAndInPackageCache(); | ||
235 | |||
236 | packageBv1.VerifyInstalled(false); | ||
237 | packageBv2.VerifyInstalled(true); | ||
238 | |||
239 | bundleBv2.Uninstall(); | ||
240 | bundleBv2.VerifyUnregisteredAndRemovedFromPackageCache(); | ||
241 | packageBv1.VerifyInstalled(false); | ||
242 | packageBv2.VerifyInstalled(false); | ||
243 | } | ||
244 | } | ||
245 | } | ||