ANCM test update to fix test issues (#99)
This commit is contained in:
parent
289ecd475d
commit
c7e17d13f3
|
|
@ -81,7 +81,7 @@ namespace AspNetCoreModule.Test.Framework
|
||||||
|
|
||||||
public static void RestoreAppHostConfig(bool restoreFromMasterBackupFile = true)
|
public static void RestoreAppHostConfig(bool restoreFromMasterBackupFile = true)
|
||||||
{
|
{
|
||||||
string masterBackupFileExtension = ".ancmtest.mastebackup";
|
string masterBackupFileExtension = ".ancmtest.masterbackup";
|
||||||
string masterBackupFilePath = Strings.AppHostConfigPath + masterBackupFileExtension;
|
string masterBackupFilePath = Strings.AppHostConfigPath + masterBackupFileExtension;
|
||||||
string temporaryBackupFileExtenstion = null;
|
string temporaryBackupFileExtenstion = null;
|
||||||
string temporaryBackupFilePath = null;
|
string temporaryBackupFilePath = null;
|
||||||
|
|
@ -532,14 +532,14 @@ namespace AspNetCoreModule.Test.Framework
|
||||||
bool result = true;
|
bool result = true;
|
||||||
if (servertype == ServerType.IIS)
|
if (servertype == ServerType.IIS)
|
||||||
{
|
{
|
||||||
if (!File.Exists(InitializeTestMachine.IISAspnetcoreSchema_path))
|
if (!File.Exists(InitializeTestMachine.FullIisAspnetcoreSchema_path))
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!File.Exists(InitializeTestMachine.IISExpressAspnetcoreSchema_path))
|
if (!File.Exists(InitializeTestMachine.IisExpressAspnetcoreSchema_path))
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,24 +17,34 @@ namespace AspNetCoreModule.Test.Framework
|
||||||
|
|
||||||
public static int SiteId = 40000;
|
public static int SiteId = 40000;
|
||||||
public const string PrivateFileName = "aspnetcore_private.dll";
|
public const string PrivateFileName = "aspnetcore_private.dll";
|
||||||
public static string Aspnetcore_path = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "system32", "inetsrv", PrivateFileName);
|
public static string FullIisAspnetcore_path = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "system32", "inetsrv", PrivateFileName);
|
||||||
public static string Aspnetcore_path_original = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "system32", "inetsrv", "aspnetcore.dll");
|
public static string FullIisAspnetcore_path_original = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "system32", "inetsrv", "aspnetcore.dll");
|
||||||
public static string Aspnetcore_X86_path = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "syswow64", "inetsrv", PrivateFileName);
|
public static string FullIisAspnetcore_X86_path = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "syswow64", "inetsrv", PrivateFileName);
|
||||||
public static string IISExpressAspnetcore_path = Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles%"), "IIS Express", PrivateFileName);
|
public static string IisExpressAspnetcore_path = Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles%"), "IIS Express", PrivateFileName);
|
||||||
public static string IISExpressAspnetcore_X86_path = Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), "IIS Express", PrivateFileName);
|
public static string IisExpressAspnetcore_X86_path = Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), "IIS Express", PrivateFileName);
|
||||||
|
|
||||||
public static string IISExpressAspnetcoreSchema_path = Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles%"), "IIS Express", "config", "schema", "aspnetcore_schema.xml");
|
public static string IisExpressAspnetcoreSchema_path = Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles%"), "IIS Express", "config", "schema", "aspnetcore_schema.xml");
|
||||||
public static string IISAspnetcoreSchema_path = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "system32", "inetsrv", "config", "schema", "aspnetcore_schema.xml");
|
public static string IisExpressAspnetcoreSchema_X86_path = Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), "IIS Express", "config", "schema", "aspnetcore_schema.xml");
|
||||||
|
public static string FullIisAspnetcoreSchema_path = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "system32", "inetsrv", "config", "schema", "aspnetcore_schema.xml");
|
||||||
public static int _referenceCount = 0;
|
public static int _referenceCount = 0;
|
||||||
private static bool _InitializeTestMachineCompleted = false;
|
private static bool _InitializeTestMachineCompleted = false;
|
||||||
private string _setupScriptPath = null;
|
private string _setupScriptPath = null;
|
||||||
|
|
||||||
|
private void CheckPerquisiteForANCMTEst()
|
||||||
|
{
|
||||||
|
if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess)
|
||||||
|
{
|
||||||
|
throw new System.InvalidOperationException(@"ANCM test should be started with x64 process mode on 64 bit machine; if you run this test on Visual Studio, you should set X64 first after selecting 'Test -> Test Settings -> Default Process Architecture' menu");
|
||||||
|
}
|
||||||
|
}
|
||||||
public InitializeTestMachine()
|
public InitializeTestMachine()
|
||||||
{
|
{
|
||||||
_referenceCount++;
|
_referenceCount++;
|
||||||
|
|
||||||
if (_referenceCount == 1)
|
if (_referenceCount == 1)
|
||||||
{
|
{
|
||||||
|
CheckPerquisiteForANCMTEst();
|
||||||
|
|
||||||
TestUtility.LogInformation("InitializeTestMachine::InitializeTestMachine() Start");
|
TestUtility.LogInformation("InitializeTestMachine::InitializeTestMachine() Start");
|
||||||
|
|
||||||
_InitializeTestMachineCompleted = false;
|
_InitializeTestMachineCompleted = false;
|
||||||
|
|
@ -160,7 +170,7 @@ namespace AspNetCoreModule.Test.Framework
|
||||||
{
|
{
|
||||||
using (var iisConfig = new IISConfigUtility(ServerType.IIS, null))
|
using (var iisConfig = new IISConfigUtility(ServerType.IIS, null))
|
||||||
{
|
{
|
||||||
iisConfig.AddModule("AspNetCoreModule", Aspnetcore_path, null);
|
iisConfig.AddModule("AspNetCoreModule", FullIisAspnetcore_path, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -269,16 +279,28 @@ namespace AspNetCoreModule.Test.Framework
|
||||||
TestUtility.ResetHelper(ResetHelperMode.KillWorkerProcess);
|
TestUtility.ResetHelper(ResetHelperMode.KillWorkerProcess);
|
||||||
TestUtility.ResetHelper(ResetHelperMode.StopW3svcStartW3svc);
|
TestUtility.ResetHelper(ResetHelperMode.StopW3svcStartW3svc);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
string from = Path.Combine(outputPath, "x64", "aspnetcore.dll");
|
string from = Path.Combine(outputPath, "x64", "aspnetcore.dll");
|
||||||
TestUtility.FileCopy(from, Aspnetcore_path, overWrite:true, ignoreExceptionWhileDeletingExistingFile:false);
|
TestUtility.FileCopy(from, FullIisAspnetcore_path, overWrite:true, ignoreExceptionWhileDeletingExistingFile:false);
|
||||||
TestUtility.FileCopy(from, IISExpressAspnetcore_path, overWrite: true, ignoreExceptionWhileDeletingExistingFile: false);
|
TestUtility.FileCopy(from, IisExpressAspnetcore_path, overWrite: true, ignoreExceptionWhileDeletingExistingFile: false);
|
||||||
|
|
||||||
|
// NOTE: schema file can't be overwritten, if there is any schema change, that should be updated manually
|
||||||
|
from = Path.Combine(outputPath, "x64", "aspnetcore_schema.xml");
|
||||||
|
TestUtility.FileCopy(from, FullIisAspnetcoreSchema_path, overWrite: false, ignoreExceptionWhileDeletingExistingFile: false);
|
||||||
|
TestUtility.FileCopy(from, IisExpressAspnetcoreSchema_path, overWrite: false, ignoreExceptionWhileDeletingExistingFile: false);
|
||||||
|
|
||||||
if (TestUtility.IsOSAmd64)
|
if (TestUtility.IsOSAmd64)
|
||||||
{
|
{
|
||||||
from = Path.Combine(outputPath, "Win32", "aspnetcore.dll");
|
from = Path.Combine(outputPath, "Win32", "aspnetcore.dll");
|
||||||
TestUtility.FileCopy(from, Aspnetcore_X86_path, overWrite: true, ignoreExceptionWhileDeletingExistingFile: false);
|
TestUtility.FileCopy(from, FullIisAspnetcore_X86_path, overWrite: true, ignoreExceptionWhileDeletingExistingFile: false);
|
||||||
TestUtility.FileCopy(from, IISExpressAspnetcore_X86_path, overWrite: true, ignoreExceptionWhileDeletingExistingFile: false);
|
TestUtility.FileCopy(from, IisExpressAspnetcore_X86_path, overWrite: true, ignoreExceptionWhileDeletingExistingFile: false);
|
||||||
|
|
||||||
|
// NOTE: schema file can't be overwritten, if there is any schema change, that should be updated manually
|
||||||
|
from = Path.Combine(outputPath, "Win32", "aspnetcore_schema.xml");
|
||||||
|
TestUtility.FileCopy(from, IisExpressAspnetcoreSchema_X86_path, overWrite: false, ignoreExceptionWhileDeletingExistingFile: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
updateSuccess = true;
|
updateSuccess = true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
|
||||||
|
|
@ -437,25 +437,41 @@ namespace AspNetCoreModule.Test.Framework
|
||||||
public static string GetMakeCertPath()
|
public static string GetMakeCertPath()
|
||||||
{
|
{
|
||||||
string makecertExeFilePath = "makecert.exe";
|
string makecertExeFilePath = "makecert.exe";
|
||||||
var makecertExeFilePaths = new string[]
|
var makecertExeFilePaths = new Dictionary<string, string>();
|
||||||
|
makecertExeFilePaths.Add("default", Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles%"), "Windows Kits"));
|
||||||
|
if (IsOSAmd64)
|
||||||
{
|
{
|
||||||
Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), "Windows Kits", "8.1", "bin", "x64", "makecert.exe"),
|
makecertExeFilePaths.Add("wow64mode", Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), "Windows Kits"));
|
||||||
Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles%"), "Windows Kits", "8.1", "bin", "x86", "makecert.exe"),
|
}
|
||||||
Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), "Windows Kits", "8.0", "bin", "x64", "makecert.exe"),
|
|
||||||
Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles%"), "Windows Kits", "8.0", "bin", "x86", "makecert.exe"),
|
|
||||||
Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), "Windows SKDs", "Windows", "v7.1A", "bin", "x64", "makecert.exe"),
|
|
||||||
Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramFiles%"), "Windows SKDs", "Windows", "v7.1A", "bin", "makecert.exe")
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (string item in makecertExeFilePaths)
|
foreach (var item in makecertExeFilePaths)
|
||||||
{
|
{
|
||||||
if (File.Exists(item))
|
string[] files = null;
|
||||||
|
if (!Directory.Exists(item.Value))
|
||||||
{
|
{
|
||||||
makecertExeFilePath = item;
|
continue;
|
||||||
|
}
|
||||||
|
files = Directory.GetFiles(item.Value, "makecert.exe", SearchOption.AllDirectories);
|
||||||
|
|
||||||
|
foreach (string makecert in files)
|
||||||
|
{
|
||||||
|
if (makecert.Contains("arm"))
|
||||||
|
{
|
||||||
|
// arm process version is skipped here
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
makecertExeFilePath = makecert;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TestUtility.RunCommand(makecertExeFilePath, null, true, true);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return makecertExeFilePath;
|
return makecertExeFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,10 @@ namespace AspNetCoreModule.Test.Framework
|
||||||
string tempSiteName = "ANCMTest_Temp";
|
string tempSiteName = "ANCMTest_Temp";
|
||||||
int tempId = InitializeTestMachine.SiteId - 1;
|
int tempId = InitializeTestMachine.SiteId - 1;
|
||||||
string argumentFileName = (new TestWebApplication("/", publishPathOutput, null)).GetArgumentFileName();
|
string argumentFileName = (new TestWebApplication("/", publishPathOutput, null)).GetArgumentFileName();
|
||||||
|
if (string.IsNullOrEmpty(argumentFileName))
|
||||||
|
{
|
||||||
|
argumentFileName = "AspNetCoreModule.TestSites.Standard.dll";
|
||||||
|
}
|
||||||
iisConfig.CreateSite(tempSiteName, publishPathOutput, tempId, tempId);
|
iisConfig.CreateSite(tempSiteName, publishPathOutput, tempId, tempId);
|
||||||
iisConfig.SetANCMConfig(tempSiteName, "/", "arguments", Path.Combine(publishPathOutput, argumentFileName));
|
iisConfig.SetANCMConfig(tempSiteName, "/", "arguments", Path.Combine(publishPathOutput, argumentFileName));
|
||||||
iisConfig.DeleteSite(tempSiteName);
|
iisConfig.DeleteSite(tempSiteName);
|
||||||
|
|
@ -322,7 +326,6 @@ namespace AspNetCoreModule.Test.Framework
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
statusCode = "ExceptionError";
|
statusCode = "ExceptionError";
|
||||||
|
|
||||||
}
|
}
|
||||||
if ("200" == statusCode)
|
if ("200" == statusCode)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace AspNetCoreModule.Test
|
||||||
if (_environmentVariableName == "%ANCMTestFlags%")
|
if (_environmentVariableName == "%ANCMTestFlags%")
|
||||||
{
|
{
|
||||||
var envValue = Environment.ExpandEnvironmentVariables(_environmentVariableName);
|
var envValue = Environment.ExpandEnvironmentVariables(_environmentVariableName);
|
||||||
if (envValue == "")
|
if (string.IsNullOrEmpty(envValue))
|
||||||
{
|
{
|
||||||
envValue = "AdminAnd64Bit";
|
envValue = "AdminAnd64Bit";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue