-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Tests ran counter #111145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests ran counter #111145
Changes from 2 commits
7539bc5
fcd48c2
aec9629
4c63543
18bbc15
77ef42a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
using System.Linq; | ||
|
||
using System.Runtime.Loader; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
|
||
delegate void TestPreLoaderDelegate(ReliabilityTest test, string[] paths); | ||
delegate void AssemblyLoadContextUnloadDelegate(); | ||
|
@@ -119,6 +120,8 @@ public class ReliabilityFramework | |
private int _reportedFailCnt = 0; | ||
private RFLogging _logger = new RFLogging(); | ||
private DateTime _lastLogTime = DateTime.Now; | ||
private Dictionary<string, uint> _testRanCounter = new(); | ||
private object _testRanCounterLock = new(); | ||
|
||
// static members | ||
private static int s_seed = (int)System.DateTime.Now.Ticks; | ||
|
@@ -161,6 +164,11 @@ public static int Main(string[] args) | |
|
||
ReliabilityFramework rf = new ReliabilityFramework(); | ||
rf._logger.WriteToInstrumentationLog(null, LoggingLevels.StartupShutdown, "Started"); | ||
|
||
Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs args) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: Since you aren't using either of the parameters of the delegate, you could easily set them to
|
||
rf.RecordTestRanCount(); | ||
}; | ||
|
||
var configVars = GC.GetConfigurationVariables(); | ||
foreach (var kvp in configVars) | ||
{ | ||
|
@@ -305,7 +313,7 @@ public static int Main(string[] args) | |
} | ||
|
||
NoExitPoll(); | ||
|
||
rf.RecordTestRanCount(); | ||
rf._logger.WriteToInstrumentationLog(null, LoggingLevels.StartupShutdown, String.Format("Shutdown w/ ret val of {0}", retVal)); | ||
|
||
|
||
|
@@ -314,6 +322,16 @@ public static int Main(string[] args) | |
return (retVal); | ||
} | ||
|
||
public void RecordTestRanCount() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: The name |
||
{ | ||
StringBuilder sb = new(); | ||
foreach(var item in _testRanCounter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When called via the |
||
{ | ||
sb.AppendLine($"{item.Key}: {item.Value}"); | ||
} | ||
_logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.StartupShutdown, $"Tests ran count:\n{sb}"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: |
||
} | ||
|
||
public void HandleOom(Exception e, string message) | ||
{ | ||
_logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.Tests, String.Format("Exception while running tests: {0}", e)); | ||
|
@@ -621,6 +639,11 @@ private void TestStarter() | |
DateTime lastStart = DateTime.Now; // keeps track of when we last started a test | ||
TimeSpan minTimeToStartTest = new TimeSpan(0, 5, 0); // after 5 minutes if we haven't started a test we're having problems... | ||
int cpuAdjust = 0, memAdjust = 0; // if we discover that we're not starting new tests quick enough we adjust the CPU/Mem percentages | ||
|
||
foreach (var test in _curTestSet.Tests) | ||
{ | ||
_testRanCounter[test.RefOrID] = 0; | ||
} | ||
// so we start new tests sooner (so they start BEFORE we drop below our minimum CPU) | ||
|
||
//Console.WriteLine("RF - TestStarter found {0} tests to run", totalTestsToRun); | ||
|
@@ -1196,6 +1219,16 @@ private void StartTestWorker(object test) | |
} | ||
break; | ||
} | ||
|
||
lock (_testRanCounterLock) | ||
{ | ||
string testRefOrID = daTest.RefOrID; | ||
if (!_testRanCounter.Keys.Contains(testRefOrID)) | ||
{ | ||
_testRanCounter[testRefOrID] = 0; | ||
} | ||
_testRanCounter[testRefOrID] ++; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (purely a style comment) You can use (you can even leave off the |
||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed