diff --git a/eng/pipelines/coreclr/gc-longrunning.yml b/eng/pipelines/coreclr/gc-longrunning.yml new file mode 100644 index 00000000000..c14ba199f7a --- /dev/null +++ b/eng/pipelines/coreclr/gc-longrunning.yml @@ -0,0 +1,27 @@ +trigger: none + +pr: none + +jobs: +- template: /eng/platform-matrix.yml + parameters: + jobTemplate: build-job.yml + buildConfig: release + platforms: + - Linux_x64 +# disable ARM for now - Linux_arm64 + - Windows_NT_x64 +# disable ARM for now - Windows_NT_arm64 + +- template: /eng/platform-matrix.yml + parameters: + jobTemplate: test-job.yml + buildConfig: release + platforms: + - Linux_x64 +# disable ARM for now - Linux_arm64 + - Windows_NT_x64 +# disable ARM for now - Windows_NT_arm64 + helixQueueGroup: ci + jobParameters: + testGroup: gc-longrunning diff --git a/eng/run-test-job.yml b/eng/run-test-job.yml index c529b2e0ad3..f1e72dc9f4f 100644 --- a/eng/run-test-job.yml +++ b/eng/run-test-job.yml @@ -62,6 +62,8 @@ jobs: timeoutInMinutes: 150 ${{ if in(parameters.testGroup, 'outerloop') }}: timeoutInMinutes: 270 + ${{ if in(parameters.testGroup, 'gc-longrunning') }}: + timeoutInMinutes: 480 ${{ if in(parameters.testGroup, 'jitstress', 'jitstress-isas-arm', 'jitstressregs-x86', 'jitstressregs', 'jitstress2-jitstressregs', 'gcstress0x3-gcstress0xc') }}: timeoutInMinutes: 390 ${{ if in(parameters.testGroup, 'jitstress-isas-x86', 'gcstress-extra', 'r2r-extra') }}: @@ -127,7 +129,11 @@ jobs: timeoutPerTestInMinutes: 10 ${{ if in(parameters.testGroup, 'outerloop') }}: timeoutPerTestCollectionInMinutes: 120 - timeoutPerTestInMinutes: 10 + timeoutPerTestInMinutes: 10 + ${{ if in(parameters.testGroup, 'gc-longrunning') }}: + timeoutPerTestCollectionInMinutes: 360 + # gc reliability may take up to 2 hours to shutdown. Some scenarios have very long iteration times. + timeoutPerTestInMinutes: 240 ${{ if in(parameters.testGroup, 'jitstress', 'jitstress-isas-arm', 'jitstress-isas-x86', 'jitstressregs-x86', 'jitstressregs', 'jitstress2-jitstressregs' ) }}: timeoutPerTestCollectionInMinutes: 120 timeoutPerTestInMinutes: 30 @@ -254,3 +260,7 @@ jobs: - jitminopts - forcerelocs - gcstress15 + ${{ if in(parameters.testGroup, 'gc-longrunning') }}: + longRunningGcTests: true + scenarios: + - normal diff --git a/eng/send-to-helix-step.yml b/eng/send-to-helix-step.yml index 9f7816c35b8..aae52f38e02 100644 --- a/eng/send-to-helix-step.yml +++ b/eng/send-to-helix-step.yml @@ -17,6 +17,7 @@ parameters: runCrossGen: '' helixProjectArguments: '' runInUnloadableContext: '' + longRunningGcTests: '' steps: - ${{ if eq(parameters.osGroup, 'Windows_NT') }}: @@ -43,6 +44,7 @@ steps: _HelixType: ${{ parameters.helixType }} _RunCrossGen: ${{ parameters.runCrossGen }} _RunInUnloadableContext: ${{ parameters.runInUnloadableContext }} + _LongRunningGcTests: ${{ parameters.longRunningGcTests }} _Scenarios: ${{ join(',', parameters.scenarios) }} _TimeoutPerTestCollectionInMinutes: ${{ parameters.timeoutPerTestCollectionInMinutes }} _TimeoutPerTestInMinutes: ${{ parameters.timeoutPerTestInMinutes }} @@ -79,6 +81,7 @@ steps: _HelixType: ${{ parameters.helixType }} _RunCrossGen: ${{ parameters.runCrossGen }} _RunInUnloadableContext: ${{ parameters.runInUnloadableContext }} + _LongRunningGcTests: ${{ parameters.longRunningGcTests }} _Scenarios: ${{ join(',', parameters.scenarios) }} _TimeoutPerTestCollectionInMinutes: ${{ parameters.timeoutPerTestCollectionInMinutes }} _TimeoutPerTestInMinutes: ${{ parameters.timeoutPerTestInMinutes }} diff --git a/src/coreclr/tests/helixpublishwitharcade.proj b/src/coreclr/tests/helixpublishwitharcade.proj index a128099a9a7..3548018a8dd 100644 --- a/src/coreclr/tests/helixpublishwitharcade.proj +++ b/src/coreclr/tests/helixpublishwitharcade.proj @@ -25,6 +25,7 @@ HelixType=$(_HelixType); PublishTestResults=$(_PublishTestResults); RunCrossGen=$(_RunCrossGen); + LongRunningGCTests=$(_LongRunningGCTests); RunInUnloadableContext=$(_RunInUnloadableContext); TimeoutPerTestCollectionInMinutes=$(_TimeoutPerTestCollectionInMinutes); TimeoutPerTestInMinutes=$(_TimeoutPerTestInMinutes) @@ -159,6 +160,8 @@ + + $(PublishTestResults) false @@ -169,12 +172,15 @@ $(BuildType) $(BuildType)-$(Scenario) false + false R2R $(TestRunNamePrefix)$(BuildOS) $(BuildArch) $(BuildType) @ $(TestRunNamePrefix)$(BuildOS) $(BuildArch) $(BuildType) $(Scenario) @ $([System.TimeSpan]::FromMinutes($(TimeoutPerTestInMinutes)).TotalMilliseconds) true - -parallel collections -nocolor -noshadow -xml testResults.xml + <_XUnitParallelMode>collections + <_XUnitParallelMode Condition=" '$(LongRunningGCTests)' == 'true' ">none + -parallel $(_XUnitParallelMode) -nocolor -noshadow -xml testResults.xml @@ -182,6 +188,7 @@ + @@ -192,6 +199,7 @@ + diff --git a/src/coreclr/tests/src/GC/Stress/Framework/LoaderClass.cs b/src/coreclr/tests/src/GC/Stress/Framework/LoaderClass.cs index 69387a2a4e0..0154a370265 100644 --- a/src/coreclr/tests/src/GC/Stress/Framework/LoaderClass.cs +++ b/src/coreclr/tests/src/GC/Stress/Framework/LoaderClass.cs @@ -146,7 +146,7 @@ public class LoaderClass #if !PROJECTK_BUILD assem = Assembly.Load(an); #else - LoadFrom(assemblyName + ".exe", paths); + LoadFrom(assemblyName + ".dll", paths); #endif } catch @@ -200,7 +200,7 @@ public class LoaderClass } catch (System.Reflection.ReflectionTypeLoadException e) { - if (assembly.ToLower().IndexOf(".exe") != -1) + if (assembly.ToLower().IndexOf(".dll") != -1) return (assembly); throw new Exception(String.Format("Couldn't GetTypes for {0} ({1})", assembly, e.Message)); } diff --git a/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityConfiguration.cs b/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityConfiguration.cs index 7a230aaa9f7..c2f705ad6b4 100644 --- a/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityConfiguration.cs +++ b/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityConfiguration.cs @@ -187,7 +187,7 @@ public class ReliabilityConfig : IEnumerable, IEnumerator throw new Exception(String.Format("Unknown option value for {0}: {1}", configSettingName, value)); } - + // returns time in minutes public static int ConvertTimeValueToTestRunTime(string timeValue) { int returnValue; @@ -381,7 +381,15 @@ public class ReliabilityConfig : IEnumerable, IEnumerator _curTestSet = new ReliabilityTestSet(); - while (currentXML.MoveToNextAttribute()) + // when running as an ordinary test, limit run time to 10 min. + bool limitTime = ReliabilityFramework.IsRunningAsUnitTest && !ReliabilityFramework.IsRunningLongGCTests; + + if (limitTime) + { + _curTestSet.MaximumTime = 10; + } + + while (currentXML.MoveToNextAttribute()) { XmlDebugOut(" " + currentXML.Name + "=\"" + currentXML.Value + "\""); switch (currentXML.Name) @@ -391,7 +399,12 @@ public class ReliabilityConfig : IEnumerable, IEnumerator break; case "maximumExecutionTime": string timeValue = currentXML.Value; - _curTestSet.MaximumTime = ConvertTimeValueToTestRunTime(timeValue); + + if (!limitTime) + { + _curTestSet.MaximumTime = ConvertTimeValueToTestRunTime(timeValue); + } + break; case "id": _curTestSet.FriendlyName = currentXML.Value; diff --git a/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityFramework.cs b/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityFramework.cs index 197cbc415ed..8398df6737c 100644 --- a/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityFramework.cs +++ b/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityFramework.cs @@ -78,7 +78,7 @@ internal class CustomAssemblyResolver : AssemblyLoadContext else { Console.WriteLine("CustomAssemblyLoader: this looks like a test"); - strPath = Path.Combine(_testsPath, assemblyName.Name + ".exe"); + strPath = Path.Combine(_testsPath, assemblyName.Name + ".dll"); } Console.WriteLine("Incoming AssemblyName: {0}", assemblyName.ToString()); @@ -147,6 +147,10 @@ public class ReliabilityFramework // constants private const string waitingText = "Waiting for all tests to finish loading, Remaining Tests: "; + // support for running in automation + internal static bool IsRunningAsUnitTest = false; + internal static bool IsRunningLongGCTests = false; + /// /// Our main execution routine for the reliability framework. Here we create an instance of the framework & run the reliability tests /// in it. All code in here will execute in our starting app domain. @@ -173,6 +177,10 @@ public class ReliabilityFramework { doReplay = true; } + else if (String.Compare(arg.Substring(1), "unittest", true) == 0) + { + IsRunningAsUnitTest = true; + } else if (String.Compare(arg.Substring(1, arg.IndexOf(':') - 1), sTests, true) == 0) { String testlist = arg.Substring(sTests.Length + 2); @@ -188,6 +196,7 @@ public class ReliabilityFramework { timeValue = arg.Substring(exectime.Length + 2); } + else { Console.WriteLine("Unknown option: {0}", arg); @@ -199,12 +208,28 @@ public class ReliabilityFramework configFile = arg; } } + + IsRunningLongGCTests = System.Environment.GetEnvironmentVariable("RunningLongGCTests") == "1"; + + // if no config file specified, check for [something]_gc.config in the current folder. + if (configFile == null) + { + var config = IsRunningAsUnitTest ? + "*_gc_ci.config" : + "*_gc.config"; + + configFile = Directory.GetFiles(Environment.CurrentDirectory, config).SingleOrDefault(); + } + if (configFile == null) { okToContinue = false; Console.WriteLine("You must specify a config file!"); rf._logger.WriteToInstrumentationLog(null, LoggingLevels.StartupShutdown, "No configuration file specified."); } + + System.Console.WriteLine("Using config file: " + configFile); + if (!okToContinue) { Console.WriteLine("\r\nHost Interface Reliability Harness\r\n"); @@ -215,6 +240,7 @@ public class ReliabilityFramework Console.WriteLine(" -replay - Replay from log file"); Console.WriteLine(" -{0}: - Comma delimited list of tests to run (no spaces)", sTests); Console.WriteLine(" -{0}: - Random Number seed for replays", sSeed); + Console.WriteLine(" -unittest - Set when run via unit test harness"); rf._logger.WriteToInstrumentationLog(null, LoggingLevels.StartupShutdown, "Not ok to continue."); #if PROJECTK_BUILD @@ -250,11 +276,18 @@ public class ReliabilityFramework eTemp = e.InnerException; } + + string err = String.Format("Exception while running tests: {0}", e); + if (eTemp == null) { - rf._logger.WriteToInstrumentationLog(null, LoggingLevels.Tests, String.Format("Exception while running tests: {0}", e)); + rf._logger.WriteToInstrumentationLog(null, LoggingLevels.Tests, err); Console.WriteLine("There was an exception while attempting to run the tests: See Instrumentation Log for details. (Exception: {0})", e); } + + // crash on exceptions when running as a unit test. + if (IsRunningAsUnitTest) + Environment.FailFast(err, e); } } finally @@ -1182,6 +1215,10 @@ public class ReliabilityFramework } catch (Exception e) { + // crash on exceptions when running as a unit test. + if (IsRunningAsUnitTest) + Environment.FailFast("Test failed", e); + Console.WriteLine(e); } Interlocked.Increment(ref _testsRanCount); @@ -1420,12 +1457,18 @@ public class ReliabilityFramework eTemp = eTemp.InnerException; } + string err = String.Format("Error in executing test {0}: {1}", daTest.RefOrID, e); + if (eTemp == null) { - _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.Tests, String.Format("Error in executing test {0}: {1}", daTest.RefOrID, e)); + _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.Tests, err); AddFailure("Failed to ExecuteAssembly (" + e.ToString() + ")", daTest, -1); } + // crash on exceptions when running as a unit test. + if (IsRunningAsUnitTest) + Environment.FailFast(err, e); + #if !PROJECTK_BUILD if ((Thread.CurrentThread.ThreadState & System.Threading.ThreadState.AbortRequested) != 0) { @@ -1452,8 +1495,14 @@ public class ReliabilityFramework } catch (Exception e) { - Console.WriteLine("Error in executing ISingleReliabilityTest: {0}", e); + string err = $"Error in executing ISingleReliabilityTest: {e}"; + + Console.WriteLine(err); AddFailure("ISingleReliabilityTest threw exception!", daTest, -1); + + // crash on exceptions when running as a unit test. + if (IsRunningAsUnitTest) + Environment.FailFast(err, e); } } else if (daTest.TestObject is IMultipleReliabilityTest) @@ -1471,8 +1520,14 @@ public class ReliabilityFramework } catch (Exception ex) { - Console.WriteLine("Error in executing IMultipleReliabilityTest: {0}", ex); + string err = $"Error in executing IMultipleReliabilityTest: {ex}"; + + Console.WriteLine(err); AddFailure("IMultipleReliabilityTest threw exception!", daTest, -1); + + // crash on exceptions when running as a unit test. + if (IsRunningAsUnitTest) + Environment.FailFast(err, ex); } } @@ -1569,7 +1624,12 @@ public class ReliabilityFramework } catch (Exception e) { - _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.Tests, String.Format("Unexpected exception on StartTestWorker: {0}", e)); + string err = String.Format("Unexpected exception on StartTestWorker: {0}", e); + _logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.Tests, err); + + // crash on exceptions when running as a unit test. + if (IsRunningAsUnitTest) + Environment.FailFast(err, e); } } @@ -1701,6 +1761,10 @@ public class ReliabilityFramework { BadTestDebugBreak(msg); } + + // crash on exceptions when running as a unit test. + if (IsRunningAsUnitTest) + Environment.FailFast(msg, e); } Interlocked.Decrement(ref LoadingCount); } diff --git a/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityFramework.csproj b/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityFramework.csproj index e02f616a17b..3169fea772b 100644 --- a/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityFramework.csproj +++ b/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityFramework.csproj @@ -1,8 +1,10 @@ Exe - BuildOnly + BuildAndRun + -unittest false + true 0 $(DefineConstants);STATIC;PROJECTK_BUILD @@ -19,11 +21,14 @@ Always + + Always + - + diff --git a/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityTest.cs b/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityTest.cs index 13585bbd543..faf445247f2 100644 --- a/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityTest.cs +++ b/src/coreclr/tests/src/GC/Stress/Framework/ReliabilityTest.cs @@ -42,7 +42,7 @@ public class TestAssemblyLoadContext : AssemblyLoadContext public int ExecuteAssemblyByName(string name, string[] args) { - return ExecuteAssembly(name + ".exe", args); + return ExecuteAssembly(name + ".dll", args); } diff --git a/src/coreclr/tests/src/GC/Stress/testmix_gc.config b/src/coreclr/tests/src/GC/Stress/testmix_gc.config index 5a4fa786063..ce26d465acf 100644 --- a/src/coreclr/tests/src/GC/Stress/testmix_gc.config +++ b/src/coreclr/tests/src/GC/Stress/testmix_gc.config @@ -13,111 +13,111 @@ minMaxTestUseCPUCount="true" suppressConsoleOutputFromTests="false"> - - - - - - - - - - - - - - - - - - diff --git a/src/coreclr/tests/src/GC/Stress/testmix_gc_ci.config b/src/coreclr/tests/src/GC/Stress/testmix_gc_ci.config new file mode 100644 index 00000000000..92b3b839b7a --- /dev/null +++ b/src/coreclr/tests/src/GC/Stress/testmix_gc_ci.config @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + +