diff options
Diffstat (limited to 'src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs')
-rw-r--r-- | src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs new file mode 100644 index 00000000..e8d37aef --- /dev/null +++ b/src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs | |||
@@ -0,0 +1,133 @@ | |||
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.Collections.Generic; | ||
6 | using System.IO; | ||
7 | using WixBuildTools.TestSupport; | ||
8 | using WixTestTools; | ||
9 | using WixToolset.Mba.Core; | ||
10 | using Xunit; | ||
11 | using Xunit.Abstractions; | ||
12 | |||
13 | public class CacheTests : BurnE2ETests | ||
14 | { | ||
15 | public CacheTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } | ||
16 | |||
17 | [Fact] | ||
18 | public void CanCache5GBFile() | ||
19 | { | ||
20 | var packageA = this.CreatePackageInstaller("PackageA"); | ||
21 | var bundleC = this.CreateBundleInstaller("BundleC"); | ||
22 | |||
23 | packageA.VerifyInstalled(false); | ||
24 | |||
25 | // Recreate the 5GB payload to avoid having to copy it to the VM to run the tests. | ||
26 | var targetFilePath = Path.Combine(this.TestContext.TestDataFolder, "fivegb.file"); | ||
27 | if (!File.Exists(targetFilePath)) | ||
28 | { | ||
29 | var testTool = new TestTool(Path.Combine(TestData.Get(), "win-x86", "TestExe.exe")) | ||
30 | { | ||
31 | Arguments = "/lf \"" + targetFilePath + "|5368709120\"", | ||
32 | ExpectedExitCode = 0, | ||
33 | }; | ||
34 | testTool.Run(true); | ||
35 | } | ||
36 | |||
37 | bundleC.Install(); | ||
38 | bundleC.VerifyRegisteredAndInPackageCache(); | ||
39 | |||
40 | packageA.VerifyInstalled(true); | ||
41 | } | ||
42 | |||
43 | [Fact] | ||
44 | public void CanDownloadPayloadsFromMissingAttachedContainer() | ||
45 | { | ||
46 | var packageA = this.CreatePackageInstaller("PackageA"); | ||
47 | var packageB = this.CreatePackageInstaller("PackageB"); | ||
48 | var bundleA = this.CreateBundleInstaller("BundleA"); | ||
49 | var testBAController = this.CreateTestBAController(); | ||
50 | var webServer = this.CreateWebServer(); | ||
51 | |||
52 | webServer.AddFiles(new Dictionary<string, string> | ||
53 | { | ||
54 | { "/BundleA/PackageA.msi", Path.Combine(this.TestContext.TestDataFolder, "PackageA.msi") }, | ||
55 | { "/BundleA/PackageB.msi", Path.Combine(this.TestContext.TestDataFolder, "PackageB.msi") }, | ||
56 | }); | ||
57 | webServer.Start(); | ||
58 | |||
59 | // Don't install PackageB initially so it will be installed when run from the package cache. | ||
60 | testBAController.SetPackageRequestedState("PackageB", RequestState.Absent); | ||
61 | |||
62 | packageA.VerifyInstalled(false); | ||
63 | packageB.VerifyInstalled(false); | ||
64 | |||
65 | // Manually copy bundle to separate directory, install from there, and then delete it | ||
66 | // so that when run from the package cache, it can't find the attached container. | ||
67 | using (var dfs = new DisposableFileSystem()) | ||
68 | { | ||
69 | var tempDirectory = dfs.GetFolder(true); | ||
70 | |||
71 | var bundleAFileInfo = new FileInfo(bundleA.Bundle); | ||
72 | var bundleACopiedPath = Path.Combine(tempDirectory, bundleAFileInfo.Name); | ||
73 | bundleAFileInfo.CopyTo(bundleACopiedPath); | ||
74 | |||
75 | bundleA.Install(bundleACopiedPath); | ||
76 | } | ||
77 | |||
78 | var bundlePackageCachePath = bundleA.VerifyRegisteredAndInPackageCache(); | ||
79 | |||
80 | packageA.VerifyInstalled(true); | ||
81 | packageB.VerifyInstalled(false); | ||
82 | |||
83 | testBAController.SetPackageRequestedState("PackageB", RequestState.Present); | ||
84 | |||
85 | bundleA.Modify(bundlePackageCachePath); | ||
86 | bundleA.VerifyRegisteredAndInPackageCache(); | ||
87 | |||
88 | packageA.VerifyInstalled(true); | ||
89 | packageB.VerifyInstalled(true); | ||
90 | } | ||
91 | |||
92 | [Fact] | ||
93 | public void CanFindAttachedContainerFromRenamedBundle() | ||
94 | { | ||
95 | var packageA = this.CreatePackageInstaller("PackageA"); | ||
96 | var packageB = this.CreatePackageInstaller("PackageB"); | ||
97 | var bundleB = this.CreateBundleInstaller("BundleB"); | ||
98 | var testBAController = this.CreateTestBAController(); | ||
99 | |||
100 | // Don't install PackageB initially so it will be installed when run from the package cache. | ||
101 | testBAController.SetPackageRequestedState("PackageB", RequestState.Absent); | ||
102 | |||
103 | packageA.VerifyInstalled(false); | ||
104 | packageB.VerifyInstalled(false); | ||
105 | |||
106 | // Manually copy bundle to separate directory with new name and install from there | ||
107 | // so that when run from the package cache, it has to get the attached container from the renamed bundle. | ||
108 | using (var dfs = new DisposableFileSystem()) | ||
109 | { | ||
110 | var tempDirectory = dfs.GetFolder(true); | ||
111 | |||
112 | var bundleBFileInfo = new FileInfo(bundleB.Bundle); | ||
113 | var bundleBCopiedPath = Path.Combine(tempDirectory, "RenamedBundle.exe"); | ||
114 | bundleBFileInfo.CopyTo(bundleBCopiedPath); | ||
115 | |||
116 | bundleB.Install(bundleBCopiedPath); | ||
117 | |||
118 | var bundlePackageCachePath = bundleB.VerifyRegisteredAndInPackageCache(); | ||
119 | |||
120 | packageA.VerifyInstalled(true); | ||
121 | packageB.VerifyInstalled(false); | ||
122 | |||
123 | testBAController.SetPackageRequestedState("PackageB", RequestState.Present); | ||
124 | |||
125 | bundleB.Modify(bundlePackageCachePath); | ||
126 | bundleB.VerifyRegisteredAndInPackageCache(); | ||
127 | |||
128 | packageA.VerifyInstalled(true); | ||
129 | packageB.VerifyInstalled(true); | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | } | ||