|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | 3 |
|
4 | | -using System; |
5 | | -using System.IO; |
6 | | -using System.Threading.Tasks; |
7 | | -using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities; |
8 | 4 | using Microsoft.AspNetCore.InternalTesting; |
9 | | -using Xunit; |
| 5 | +using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities; |
10 | 6 |
|
11 | 7 | namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests; |
12 | 8 |
|
@@ -142,6 +138,37 @@ public async Task ShadowCopySingleFileChangedWorks() |
142 | 138 | Assert.True(response.IsSuccessStatusCode); |
143 | 139 | } |
144 | 140 |
|
| 141 | + [ConditionalFact] |
| 142 | + public async Task ShadowCopyDeleteFolderDuringShutdownWorks() |
| 143 | + { |
| 144 | + using var directory = TempDirectory.Create(); |
| 145 | + var deploymentParameters = Fixture.GetBaseDeploymentParameters(); |
| 146 | + deploymentParameters.HandlerSettings["enableShadowCopy"] = "true"; |
| 147 | + deploymentParameters.HandlerSettings["shadowCopyDirectory"] = directory.DirectoryPath; |
| 148 | + |
| 149 | + var deploymentResult = await DeployAsync(deploymentParameters); |
| 150 | + var deleteDirPath = Path.Combine(deploymentResult.ContentRoot, "wwwroot/deletethis"); |
| 151 | + Directory.CreateDirectory(deleteDirPath); |
| 152 | + File.WriteAllText(Path.Combine(deleteDirPath, "file.dll"), ""); |
| 153 | + |
| 154 | + var response = await deploymentResult.HttpClient.GetAsync("Wow!"); |
| 155 | + Assert.True(response.IsSuccessStatusCode); |
| 156 | + |
| 157 | + AddAppOffline(deploymentResult.ContentRoot); |
| 158 | + await AssertAppOffline(deploymentResult); |
| 159 | + |
| 160 | + // Delete folder + file after app is shut down |
| 161 | + // Testing specific path on startup where we compare the app directory contents with the shadow copy directory |
| 162 | + Directory.Delete(deleteDirPath, recursive: true); |
| 163 | + |
| 164 | + RemoveAppOffline(deploymentResult.ContentRoot); |
| 165 | + |
| 166 | + await deploymentResult.AssertRecycledAsync(); |
| 167 | + |
| 168 | + response = await deploymentResult.HttpClient.GetAsync("Wow!"); |
| 169 | + Assert.True(response.IsSuccessStatusCode); |
| 170 | + } |
| 171 | + |
145 | 172 | [ConditionalFact] |
146 | 173 | public async Task ShadowCopyE2EWorksWithFolderPresent() |
147 | 174 | { |
|
0 commit comments