Making tests runnable on coreclr
This commit is contained in:
parent
a7a70786a5
commit
0e72888105
|
|
@ -18,15 +18,15 @@ namespace E2ETests
|
|||
private static string GetIISExpressPath(RuntimeArchitecture architecture)
|
||||
{
|
||||
// Get path to program files
|
||||
var iisExpressPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "IIS Express", "iisexpress.exe");
|
||||
var iisExpressPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles(x86)"), "IIS Express", "iisexpress.exe");
|
||||
|
||||
// Get path to 64 bit of IIS Express
|
||||
if (architecture == RuntimeArchitecture.amd64)
|
||||
{
|
||||
iisExpressPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "IIS Express", "iisexpress.exe");
|
||||
iisExpressPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "IIS Express", "iisexpress.exe");
|
||||
|
||||
// If process is 32 bit, the path points to x86. Replace path to point to x64
|
||||
iisExpressPath = Environment.Is64BitProcess ? iisExpressPath : iisExpressPath.Replace(" (x86)", "");
|
||||
iisExpressPath = IntPtr.Size == 8 ? iisExpressPath : iisExpressPath.Replace(" (x86)", "");
|
||||
}
|
||||
|
||||
if (!File.Exists(iisExpressPath))
|
||||
|
|
@ -50,10 +50,7 @@ namespace E2ETests
|
|||
var aspNetLoaderDestPath = Path.Combine(applicationPath, "wwwroot", "bin", "AspNet.Loader.dll");
|
||||
|
||||
// Create bin directory if it does not exist.
|
||||
if (!Directory.Exists(new DirectoryInfo(aspNetLoaderDestPath).Parent.FullName))
|
||||
{
|
||||
Directory.CreateDirectory(new DirectoryInfo(aspNetLoaderDestPath).Parent.FullName);
|
||||
}
|
||||
Directory.CreateDirectory(new DirectoryInfo(aspNetLoaderDestPath).Parent.FullName);
|
||||
|
||||
if (!File.Exists(aspNetLoaderDestPath))
|
||||
{
|
||||
|
|
@ -65,7 +62,7 @@ namespace E2ETests
|
|||
|
||||
public static Process StartApplication(StartParameters startParameters, ILogger logger)
|
||||
{
|
||||
startParameters.ApplicationPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, APP_RELATIVE_PATH));
|
||||
startParameters.ApplicationPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), APP_RELATIVE_PATH));
|
||||
|
||||
//To avoid the KRE_DEFAULT_LIB of the test process flowing into Helios, set it to empty
|
||||
var backupRuntimeDefaultLibPath = Environment.GetEnvironmentVariable("KRE_DEFAULT_LIB");
|
||||
|
|
@ -100,6 +97,7 @@ namespace E2ETests
|
|||
//Reason to do pack here instead of in a common place is use the right runtime to do the packing. Previous line switches to use the right runtime.
|
||||
if (startParameters.BundleApplicationBeforeStart)
|
||||
{
|
||||
#if ASPNET50
|
||||
if (startParameters.ServerType == ServerType.IISNativeModule ||
|
||||
startParameters.ServerType == ServerType.IIS)
|
||||
{
|
||||
|
|
@ -141,18 +139,22 @@ namespace E2ETests
|
|||
Thread.Sleep(1 * 1000);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
KpmBundle(startParameters, logger);
|
||||
}
|
||||
}
|
||||
|
||||
#if ASPNET50
|
||||
if (startParameters.ServerType == ServerType.IISNativeModule ||
|
||||
startParameters.ServerType == ServerType.IIS)
|
||||
{
|
||||
startParameters.IISApplication = new IISApplication(startParameters, logger);
|
||||
startParameters.IISApplication.SetupApplication();
|
||||
}
|
||||
else if (startParameters.ServerType == ServerType.IISExpress)
|
||||
else
|
||||
#endif
|
||||
if (startParameters.ServerType == ServerType.IISExpress)
|
||||
{
|
||||
hostProcess = StartHeliosHost(startParameters, logger);
|
||||
}
|
||||
|
|
@ -358,11 +360,13 @@ namespace E2ETests
|
|||
if (startParameters.ServerType == ServerType.IISNativeModule ||
|
||||
startParameters.ServerType == ServerType.IIS)
|
||||
{
|
||||
#if ASPNET50
|
||||
// Stop & delete the application pool.
|
||||
if (startParameters.IISApplication != null)
|
||||
{
|
||||
startParameters.IISApplication.StopAndDeleteAppPool();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (hostProcess != null && !hostProcess.HasExited)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,7 +28,11 @@ namespace E2ETests
|
|||
}
|
||||
catch (AggregateException exception)
|
||||
{
|
||||
if (exception.InnerException is HttpRequestException || exception.InnerException is WebException)
|
||||
if (exception.InnerException is HttpRequestException
|
||||
#if ASPNET50
|
||||
|| exception.InnerException is WebException
|
||||
#endif
|
||||
)
|
||||
{
|
||||
logger.WriteWarning("Failed to complete the request.", exception);
|
||||
Thread.Sleep(7 * 1000); //Wait for a while before retry.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
#if ASPNET50
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.Framework.Logging;
|
||||
|
|
@ -76,4 +77,5 @@ namespace E2ETests
|
|||
_logger.WriteInformation("Successfully stopped application pool '{name}' and deleted application from IIS.", _applicationPool.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
public string Runtime { get; set; }
|
||||
|
||||
#if ASPNET50
|
||||
public IISApplication IISApplication { get; set; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ namespace E2ETests
|
|||
content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||
// Need a non-redirecting handler
|
||||
var handler = new HttpClientHandler() { AllowAutoRedirect = false };
|
||||
handler.CookieContainer.Add(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)));
|
||||
handler.CookieContainer.Add(new Uri(_applicationBaseUrl), _httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)));
|
||||
_httpClient = new HttpClient(handler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||
|
||||
response = _httpClient.PostAsync("Account/LogOff", content).Result;
|
||||
|
|
|
|||
|
|
@ -64,10 +64,14 @@ namespace E2ETests
|
|||
|
||||
private string PrefixBaseAddress(string url)
|
||||
{
|
||||
#if ASPNET50
|
||||
url = (_startParameters.ServerType == ServerType.IISNativeModule ||
|
||||
_startParameters.ServerType == ServerType.IIS) ?
|
||||
string.Format(url, _startParameters.IISApplication.VirtualDirectoryName) :
|
||||
string.Format(url, string.Empty);
|
||||
#else
|
||||
url = string.Format(url, string.Empty);
|
||||
#endif
|
||||
|
||||
return url.Replace("//", "/").Replace("%2F%2F", "%2F").Replace("%2F/", "%2F");
|
||||
}
|
||||
|
|
@ -291,6 +295,7 @@ namespace E2ETests
|
|||
private string CreateAlbum()
|
||||
{
|
||||
var albumName = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12);
|
||||
#if ASPNET50
|
||||
string dataFromHub = null;
|
||||
var OnReceivedEvent = new AutoResetEvent(false);
|
||||
var hubConnection = new HubConnection(_applicationBaseUrl + "SignalR");
|
||||
|
|
@ -303,7 +308,7 @@ namespace E2ETests
|
|||
|
||||
IHubProxy proxy = hubConnection.CreateHubProxy("Announcement");
|
||||
hubConnection.Start().Wait();
|
||||
|
||||
#endif
|
||||
_logger.WriteInformation("Trying to create an album with name '{album}'", albumName);
|
||||
var response = _httpClient.GetAsync("Admin/StoreManager/create").Result;
|
||||
ThrowIfResponseStatusNotOk(response);
|
||||
|
|
@ -322,12 +327,13 @@ namespace E2ETests
|
|||
response = _httpClient.PostAsync("Admin/StoreManager/create", content).Result;
|
||||
responseContent = response.Content.ReadAsStringAsync().Result;
|
||||
Assert.Equal<string>(_applicationBaseUrl + "Admin/StoreManager", response.RequestMessage.RequestUri.AbsoluteUri);
|
||||
|
||||
Assert.Contains(albumName, responseContent);
|
||||
#if ASPNET50
|
||||
_logger.WriteInformation("Waiting for the SignalR client to receive album created announcement");
|
||||
OnReceivedEvent.WaitOne(TimeSpan.FromSeconds(10));
|
||||
dataFromHub = dataFromHub ?? "No relevant data received from Hub";
|
||||
Assert.Contains(albumName, dataFromHub);
|
||||
#endif
|
||||
_logger.WriteInformation("Successfully created an album with name '{album}' in the store", albumName);
|
||||
return albumName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,9 @@ namespace E2ETests
|
|||
VerifyHomePage(response, responseContent, true);
|
||||
|
||||
//Check if the user name appears in the page
|
||||
Assert.Contains(string.Format("{0}\\{1}", Environment.UserDomainName, Environment.UserName), responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains(
|
||||
string.Format("{0}\\{1}", Environment.GetEnvironmentVariable("USERDOMAIN"), Environment.GetEnvironmentVariable("USERNAME")),
|
||||
responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
//Should be able to access the store as the Startup adds necessary permissions for the current user
|
||||
AccessStoreWithPermissions();
|
||||
|
|
|
|||
|
|
@ -56,12 +56,13 @@ namespace E2ETests
|
|||
try
|
||||
{
|
||||
hostProcess = DeploymentUtility.StartApplication(_startParameters, _logger);
|
||||
#if ASPNET50
|
||||
if (serverType == ServerType.IISNativeModule || serverType == ServerType.IIS)
|
||||
{
|
||||
// Accomodate the vdir name.
|
||||
_applicationBaseUrl += _startParameters.IISApplication.VirtualDirectoryName + "/";
|
||||
}
|
||||
|
||||
#endif
|
||||
_httpClientHandler = new HttpClientHandler();
|
||||
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ namespace E2ETests
|
|||
[SkipIfNativeModuleNotInstalled]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||
[OSSkipCondition(OperatingSystems.Win7And2008R2 | OperatingSystems.MacOSX | OperatingSystems.Unix)]
|
||||
[SkipIfCurrentRuntimeIsCoreClr]
|
||||
[InlineData(ServerType.IISNativeModule, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, "http://localhost:5005/")]
|
||||
public void SmokeTestSuite_On_NativeModule_X86(ServerType serverType, RuntimeFlavor donetFlavor, RuntimeArchitecture architecture, string applicationBaseUrl)
|
||||
{
|
||||
|
|
@ -72,6 +73,7 @@ namespace E2ETests
|
|||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||
[OSSkipCondition(OperatingSystems.Win7And2008R2 | OperatingSystems.MacOSX | OperatingSystems.Unix)]
|
||||
[SkipOn32BitOS]
|
||||
[SkipIfCurrentRuntimeIsCoreClr]
|
||||
[InlineData(ServerType.IISNativeModule, RuntimeFlavor.CoreClr, RuntimeArchitecture.amd64, "http://localhost:5005/")]
|
||||
public void SmokeTestSuite_On_NativeModule_AMD64(ServerType serverType, RuntimeFlavor donetFlavor, RuntimeArchitecture architecture, string applicationBaseUrl)
|
||||
{
|
||||
|
|
@ -81,6 +83,7 @@ namespace E2ETests
|
|||
// [ConditionalTheory]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||
[OSSkipCondition(OperatingSystems.MacOSX | OperatingSystems.Unix)]
|
||||
[SkipIfCurrentRuntimeIsCoreClr]
|
||||
[InlineData(ServerType.IIS, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, "http://localhost:5005/")]
|
||||
public void SmokeTestSuite_On_IIS_X86(ServerType serverType, RuntimeFlavor donetFlavor, RuntimeArchitecture architecture, string applicationBaseUrl)
|
||||
{
|
||||
|
|
@ -117,12 +120,13 @@ namespace E2ETests
|
|||
try
|
||||
{
|
||||
hostProcess = DeploymentUtility.StartApplication(_startParameters, _logger);
|
||||
#if ASPNET50
|
||||
if (serverType == ServerType.IISNativeModule || serverType == ServerType.IIS)
|
||||
{
|
||||
// Accomodate the vdir name.
|
||||
_applicationBaseUrl += _startParameters.IISApplication.VirtualDirectoryName + "/";
|
||||
}
|
||||
|
||||
#endif
|
||||
_httpClientHandler = new HttpClientHandler();
|
||||
_httpClient = new HttpClient(_httpClientHandler) { BaseAddress = new Uri(_applicationBaseUrl) };
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"compilationOptions": { "warningsAsErrors": "true" },
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": "true"
|
||||
},
|
||||
"commands": {
|
||||
"test": "xunit.runner.kre"
|
||||
},
|
||||
|
|
@ -20,6 +22,14 @@
|
|||
"System.Net.Http": "",
|
||||
"System.Xml": ""
|
||||
}
|
||||
}
|
||||
} /*,
|
||||
"aspnetcore50": {
|
||||
"dependencies": {
|
||||
"System.Data.SqlClient": "4.0.0-beta-*",
|
||||
"System.Net.Http": "4.0.0-beta-*",
|
||||
"System.Xml.XmlDocument": "4.0.0-beta-*",
|
||||
"Microsoft.Win32.Primitives": "4.0.0-beta-*"
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNet.Testing.xunit;
|
||||
|
||||
namespace E2ETests
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
public class SkipIfCurrentRuntimeIsCoreClrAttribute : Attribute, ITestCondition
|
||||
{
|
||||
public bool IsMet
|
||||
{
|
||||
get
|
||||
{
|
||||
return !Process.GetCurrentProcess().ProcessName.ToLower().Contains("coreclr");
|
||||
}
|
||||
}
|
||||
|
||||
public string SkipReason
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Cannot run these test variations using CoreCLR KRE as helpers are not available on CoreCLR.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.Testing.xunit;
|
||||
|
||||
namespace E2ETests
|
||||
|
|
@ -10,7 +11,8 @@ namespace E2ETests
|
|||
{
|
||||
get
|
||||
{
|
||||
return Environment.Is64BitOperatingSystem;
|
||||
// Directory found only on 64-bit OS.
|
||||
return Directory.Exists(Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "SysWOW64"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue