From 2283ee8fcc219c4cec27940899845ce948c7aa55 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 6 Jul 2017 05:49:07 -0700 Subject: [PATCH] Code cleanup and added more log information --- .../SmokeTestsUsingStore/Store.cs | 11 +++++--- .../SmokeTestsUsingStore/TestHelper.cs | 25 ++++++++++++++++++- .../SmokeTestsUsingStore/Tests.cs | 13 ---------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/test/MusicStore.E2ETests/SmokeTestsUsingStore/Store.cs b/test/MusicStore.E2ETests/SmokeTestsUsingStore/Store.cs index 86e4212..a53ad13 100644 --- a/test/MusicStore.E2ETests/SmokeTestsUsingStore/Store.cs +++ b/test/MusicStore.E2ETests/SmokeTestsUsingStore/Store.cs @@ -66,7 +66,7 @@ namespace E2ETests var packageId = "Build.RS"; var runtimeStoreLibrary = DependencyContext.Default.RuntimeLibraries - .Where(library => string.Equals("Build.RS", library.Name, StringComparison.OrdinalIgnoreCase)) + .Where(library => string.Equals(packageId, library.Name, StringComparison.OrdinalIgnoreCase)) .FirstOrDefault(); if (runtimeStoreLibrary == null) { @@ -76,6 +76,8 @@ namespace E2ETests var runtimeStoreVersion = runtimeStoreLibrary.Version; var restoredRuntimeStorePackageDir = Path.Combine(GetNugetPackagesRoot(), runtimeStoreLibrary.Path); + _logger.LogInformation($"Location of the restored runtime store package '{packageId}': {restoredRuntimeStorePackageDir}"); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { string fileNameWithExtension = null; @@ -119,10 +121,11 @@ namespace E2ETests } string fileNameWithExtension = null; + var tarFile = $"{packageIdPrefix}.tar.gz"; foreach (var file in new DirectoryInfo(restoredRuntimeStorePackageDir).GetFiles()) { if (file.Name.StartsWith(packageIdPrefix) - && !string.Equals($"{packageIdPrefix}.tar.gz", file.Name, StringComparison.OrdinalIgnoreCase)) + && !string.Equals(tarFile, file.Name, StringComparison.OrdinalIgnoreCase)) { fileNameWithExtension = file.FullName; break; @@ -132,9 +135,11 @@ namespace E2ETests if (string.IsNullOrEmpty(fileNameWithExtension)) { throw new InvalidOperationException( - $"Could not find a store zip file with version {runtimeStoreVersion}"); + $"Could not find a store tar file with version {runtimeStoreVersion}"); } + _logger.LogInformation($"Extracting the store tar file '{fileNameWithExtension}' to '{storeParentDir}' ..."); + Directory.CreateDirectory(storeParentDir); var startInfo = new ProcessStartInfo() diff --git a/test/MusicStore.E2ETests/SmokeTestsUsingStore/TestHelper.cs b/test/MusicStore.E2ETests/SmokeTestsUsingStore/TestHelper.cs index 37397d4..6d0258b 100644 --- a/test/MusicStore.E2ETests/SmokeTestsUsingStore/TestHelper.cs +++ b/test/MusicStore.E2ETests/SmokeTestsUsingStore/TestHelper.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IntegrationTesting; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; using Xunit; using Xunit.Abstractions; @@ -53,15 +55,36 @@ namespace E2ETests.SmokeTestsUsingStore { var deploymentResult = await deployer.DeployAsync(); - var mvcCoreDllPath = Path.Combine(deploymentResult.ContentRoot, "Microsoft.AspNetCore.Mvc.Core.dll"); + logger.LogInformation("Published output directory structure:"); + logger.LogInformation(GetDirectoryStructure(deploymentResult.ContentRoot)); + + var mvcCoreDll = "Microsoft.AspNetCore.Mvc.Core.dll"; + logger.LogInformation( + $"Checking if published output was trimmed by verifying that the dll '{mvcCoreDll}' is not present..."); + + var mvcCoreDllPath = Path.Combine(deploymentResult.ContentRoot, mvcCoreDll); var fileInfo = new FileInfo(mvcCoreDllPath); Assert.False( File.Exists(mvcCoreDllPath), $"The file '{fileInfo.Name}.{fileInfo.Extension}' was not expected to be present in the publish directory"); + logger.LogInformation($"Published output does not have the dll '{mvcCoreDll}', so the output seems to be trimmed"); + await SmokeTestRunner.RunTestsAsync(deploymentResult, logger); } } } + + // Get the top level view of the published output directory + private string GetDirectoryStructure(string publishedOutputDir) + { + var directoryStructure = new StringBuilder(); + var dir = new DirectoryInfo(publishedOutputDir); + foreach (var fileSystemInfo in dir.GetFileSystemInfos()) + { + directoryStructure.AppendLine(fileSystemInfo.Name); + } + return directoryStructure.ToString(); + } } } diff --git a/test/MusicStore.E2ETests/SmokeTestsUsingStore/Tests.cs b/test/MusicStore.E2ETests/SmokeTestsUsingStore/Tests.cs index 3d5205c..c6a91f4 100644 --- a/test/MusicStore.E2ETests/SmokeTestsUsingStore/Tests.cs +++ b/test/MusicStore.E2ETests/SmokeTestsUsingStore/Tests.cs @@ -29,18 +29,5 @@ namespace E2ETests.SmokeTestsUsingStore ServerType.Kestrel, _testFixture.StoreDirectory); } - - [OSSkipCondition(OperatingSystems.Linux)] - [OSSkipCondition(OperatingSystems.MacOSX)] - [SkipIfEnvironmentVariableNotEnabled("RUN_RUNTIME_STORE_TESTS")] - [ConditionalFact] - [Trait("smoketests", "usestore")] - public async Task DefaultLocation_WebListener() - { - var tests = new TestHelper(_output); - await tests.SmokeTestSuite( - ServerType.WebListener, - _testFixture.StoreDirectory); - } } } \ No newline at end of file