aboutsummaryrefslogtreecommitdiff
path: root/src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs')
-rw-r--r--src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs81
1 files changed, 77 insertions, 4 deletions
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs
index 4a3ffa2e..ee61baff 100644
--- a/src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs
+++ b/src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs
@@ -15,8 +15,7 @@ namespace WixToolsetTest.BurnE2E
15 { 15 {
16 public CacheTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } 16 public CacheTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }
17 17
18 [Fact] 18 private bool Is5GBFileAvailable()
19 public void CanCache5GBFile()
20 { 19 {
21 // Recreate the 5GB payload to avoid having to copy it to the VM to run the tests. 20 // Recreate the 5GB payload to avoid having to copy it to the VM to run the tests.
22 const long FiveGB = 5_368_709_120; 21 const long FiveGB = 5_368_709_120;
@@ -28,8 +27,8 @@ namespace WixToolsetTest.BurnE2E
28 var drive = new DriveInfo(targetFilePath.Substring(0, 1)); 27 var drive = new DriveInfo(targetFilePath.Substring(0, 1));
29 if (drive.AvailableFreeSpace < FiveGB + OneGB) 28 if (drive.AvailableFreeSpace < FiveGB + OneGB)
30 { 29 {
31 Console.WriteLine("Skipping CanCache5GBFile() test because there is not enough disk space available to run the test."); 30 Console.WriteLine($"Skipping {this.TestContext.TestName} because there is not enough disk space available to run the test.");
32 return; 31 return false;
33 } 32 }
34 33
35 if (!File.Exists(targetFilePath)) 34 if (!File.Exists(targetFilePath))
@@ -42,6 +41,17 @@ namespace WixToolsetTest.BurnE2E
42 testTool.Run(true); 41 testTool.Run(true);
43 } 42 }
44 43
44 return true;
45 }
46
47 [Fact]
48 public void CanCache5GBFile()
49 {
50 if (!this.Is5GBFileAvailable())
51 {
52 return;
53 }
54
45 var packageA = this.CreatePackageInstaller("PackageA"); 55 var packageA = this.CreatePackageInstaller("PackageA");
46 var bundleC = this.CreateBundleInstaller("BundleC"); 56 var bundleC = this.CreateBundleInstaller("BundleC");
47 57
@@ -53,6 +63,69 @@ namespace WixToolsetTest.BurnE2E
53 packageA.VerifyInstalled(true); 63 packageA.VerifyInstalled(true);
54 } 64 }
55 65
66 private string Cache5GBFileFromDownload(bool disableRangeRequests)
67 {
68 if (!this.Is5GBFileAvailable())
69 {
70 return null;
71 }
72
73 var packageA = this.CreatePackageInstaller("PackageA");
74 var bundleC = this.CreateBundleInstaller("BundleC");
75 var webServer = this.CreateWebServer();
76
77 webServer.AddFiles(new Dictionary<string, string>
78 {
79 { "/BundleC/fivegb.file", Path.Combine(this.TestContext.TestDataFolder, "fivegb.file") },
80 { "/BundleC/PackageA.msi", Path.Combine(this.TestContext.TestDataFolder, "PackageA.msi") },
81 });
82 webServer.DisableRangeRequests = disableRangeRequests;
83 webServer.Start();
84
85 using var dfs = new DisposableFileSystem();
86 var separateDirectory = dfs.GetFolder(true);
87
88 // Manually copy bundle to separate directory and then run from there so the non-compressed payloads have to be resolved.
89 var bundleCFileInfo = new FileInfo(bundleC.Bundle);
90 var bundleCCopiedPath = Path.Combine(separateDirectory, bundleCFileInfo.Name);
91 bundleCFileInfo.CopyTo(bundleCCopiedPath);
92
93 packageA.VerifyInstalled(false);
94
95 var installLogPath = bundleC.Install(bundleCCopiedPath);
96 bundleC.VerifyRegisteredAndInPackageCache();
97
98 packageA.VerifyInstalled(true);
99
100 return installLogPath;
101 }
102
103 [Fact]
104 public void CanCache5GBFileFromDownloadWithRangeRequestSupport()
105 {
106 var logPath = this.Cache5GBFileFromDownload(false);
107 if (logPath == null)
108 {
109 return;
110 }
111
112 Assert.False(LogVerifier.MessageInLogFile(logPath, "Range request not supported for URL: http://localhost:9999/e2e/BundleC/fivegb.file"));
113 Assert.True(LogVerifier.MessageInLogFile(logPath, "Content-Length not returned for URL: http://localhost:9999/e2e/BundleC/fivegb.file"));
114 }
115
116 [Fact]
117 public void CanCache5GBFileFromDownloadWithoutRangeRequestSupport()
118 {
119 var logPath = this.Cache5GBFileFromDownload(true);
120 if (logPath == null)
121 {
122 return;
123 }
124
125 Assert.True(LogVerifier.MessageInLogFile(logPath, "Range request not supported for URL: http://localhost:9999/e2e/BundleC/fivegb.file"));
126 Assert.True(LogVerifier.MessageInLogFile(logPath, "Content-Length not returned for URL: http://localhost:9999/e2e/BundleC/fivegb.file"));
127 }
128
56 [Fact] 129 [Fact]
57 public void CanDownloadPayloadsFromMissingAttachedContainer() 130 public void CanDownloadPayloadsFromMissingAttachedContainer()
58 { 131 {