diff --git a/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/PathUtilities.cs b/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/PathUtilities.cs index 5d276e3ae7..e685152da4 100644 --- a/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/PathUtilities.cs +++ b/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/PathUtilities.cs @@ -8,23 +8,31 @@ namespace Microsoft.AspNetCore.AzureAppServices.FunctionalTests { public class PathUtilities { - public static string[] GetStoreModules(string dotnetPath) + public static StoreModuleInfo[] GetStoreModules(string dotnetPath) { var dotnetHome = Path.GetDirectoryName(dotnetPath); return new DirectoryInfo(Path.Combine(dotnetHome, "store", "x64", "netcoreapp2.0")) .GetDirectories() - .Select(d => d.Name) + .Select(d => new StoreModuleInfo + { + Name = d.Name, + Versions = d.GetDirectories().Select(GetName).ToArray() + }) .ToArray(); } - public static string[] GetSharedRuntimeAssemblies(string dotnetPath) + public static string[] GetSharedRuntimeAssemblies(string dotnetPath, out string runtimeVersion) { var dotnetHome = Path.GetDirectoryName(dotnetPath); - return new DirectoryInfo(Path.Combine(dotnetHome, "shared", "Microsoft.NETCore.App")) + var runtimeDirectory = new DirectoryInfo(Path.Combine(dotnetHome, "shared", "Microsoft.NETCore.App")) .GetDirectories() - .Single() + .Single(); + + runtimeVersion = runtimeDirectory.Name; + + return runtimeDirectory .GetFiles("*.dll") - .Select(f => f.Name) + .Select(GetName) .ToArray(); } @@ -36,5 +44,13 @@ namespace Microsoft.AspNetCore.AzureAppServices.FunctionalTests .Single() .Name; } + + private static string GetName(FileSystemInfo info) => info.Name; + + public class StoreModuleInfo + { + public string Name { get; set; } + public string[] Versions { get; set; } + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/TemplateFunctionalTests.cs b/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/TemplateFunctionalTests.cs index fd45e143ff..d3dfa3a0fe 100644 --- a/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/TemplateFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.AzureAppServices.FunctionalTests/TemplateFunctionalTests.cs @@ -86,21 +86,37 @@ namespace Microsoft.AspNetCore.AzureAppServices.FunctionalTests private void ValidateRuntimeInfo(RuntimeInfo runtimeInfo, string dotnetPath) { var storeModules = PathUtilities.GetStoreModules(dotnetPath); - - var runtimeModules = PathUtilities.GetSharedRuntimeAssemblies(dotnetPath); + var runtimeModules = PathUtilities.GetSharedRuntimeAssemblies(dotnetPath, out var runtimeVersion); foreach (var runtimeInfoModule in runtimeInfo.Modules) { - if (storeModules.Any(f => runtimeInfoModule.ModuleName.StartsWith(f, StringComparison.InvariantCultureIgnoreCase))) + var moduleName = Path.GetFileNameWithoutExtension(runtimeInfoModule.ModuleName); + + // Check if module should come from the store, verify that one of the expected versions is loaded + var storeModule = storeModules.SingleOrDefault(f => moduleName.Equals(f.Name, StringComparison.InvariantCultureIgnoreCase)); + if (storeModule != null) { - Assert.Contains("store\\x86\\netcoreapp2.0\\", runtimeInfoModule.FileName); + var expectedVersion = false; + foreach (var version in storeModule.Versions) + { + var expectedModulePath = $"store\\x86\\netcoreapp2.0\\{storeModule.Name}\\{version}"; + + if (runtimeInfoModule.FileName.IndexOf(expectedModulePath, StringComparison.InvariantCultureIgnoreCase) != -1) + { + expectedVersion = true; + break; + } + } + + Assert.True(expectedVersion, $"{runtimeInfoModule.FileName} doesn't match expected versions: {string.Join(",", storeModule.Versions)}"); } + // Verify that modules that we expect to come from runtime actually come from there // Native modules would prefer to be loaded from windows folder, skip them - if (runtimeModules.Any(f => runtimeInfoModule.ModuleName.StartsWith(f, StringComparison.InvariantCultureIgnoreCase)) && + if (runtimeModules.Any(rutimeModule => runtimeInfoModule.ModuleName.Equals(rutimeModule, StringComparison.InvariantCultureIgnoreCase)) && runtimeInfoModule.FileName.IndexOf("windows\\system32", StringComparison.InvariantCultureIgnoreCase) == -1) { - Assert.Contains("shared\\Microsoft.NETCore.App\\", runtimeInfoModule.FileName); + Assert.Contains($"shared\\Microsoft.NETCore.App\\{runtimeVersion}", runtimeInfoModule.FileName); } } }