|
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; |
| 4 | +using Microsoft.AspNetCore.InternalTesting; |
7 | 5 | using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
8 | 6 | using Microsoft.AspNetCore.Testing;
|
9 | 7 | using Xunit;
|
@@ -142,6 +140,37 @@ public async Task ShadowCopySingleFileChangedWorks()
|
142 | 140 | Assert.True(response.IsSuccessStatusCode);
|
143 | 141 | }
|
144 | 142 |
|
| 143 | + [ConditionalFact] |
| 144 | + public async Task ShadowCopyDeleteFolderDuringShutdownWorks() |
| 145 | + { |
| 146 | + using var directory = TempDirectory.Create(); |
| 147 | + var deploymentParameters = Fixture.GetBaseDeploymentParameters(); |
| 148 | + deploymentParameters.HandlerSettings["enableShadowCopy"] = "true"; |
| 149 | + deploymentParameters.HandlerSettings["shadowCopyDirectory"] = directory.DirectoryPath; |
| 150 | + |
| 151 | + var deploymentResult = await DeployAsync(deploymentParameters); |
| 152 | + var deleteDirPath = Path.Combine(deploymentResult.ContentRoot, "wwwroot/deletethis"); |
| 153 | + Directory.CreateDirectory(deleteDirPath); |
| 154 | + File.WriteAllText(Path.Combine(deleteDirPath, "file.dll"), ""); |
| 155 | + |
| 156 | + var response = await deploymentResult.HttpClient.GetAsync("Wow!"); |
| 157 | + Assert.True(response.IsSuccessStatusCode); |
| 158 | + |
| 159 | + AddAppOffline(deploymentResult.ContentRoot); |
| 160 | + await AssertAppOffline(deploymentResult); |
| 161 | + |
| 162 | + // Delete folder + file after app is shut down |
| 163 | + // Testing specific path on startup where we compare the app directory contents with the shadow copy directory |
| 164 | + Directory.Delete(deleteDirPath, recursive: true); |
| 165 | + |
| 166 | + RemoveAppOffline(deploymentResult.ContentRoot); |
| 167 | + |
| 168 | + await deploymentResult.AssertRecycledAsync(); |
| 169 | + |
| 170 | + response = await deploymentResult.HttpClient.GetAsync("Wow!"); |
| 171 | + Assert.True(response.IsSuccessStatusCode); |
| 172 | + } |
| 173 | + |
145 | 174 | [ConditionalFact]
|
146 | 175 | public async Task ShadowCopyE2EWorksWithFolderPresent()
|
147 | 176 | {
|
|
0 commit comments