Skip to content

Commit

Permalink
test: Improve integration test reliability (#1825)
Browse files Browse the repository at this point in the history
  • Loading branch information
chynesNR authored Aug 7, 2023
1 parent 1e4198a commit 8cedbb6
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ public virtual void Initialize()
}
catch (Exception ex)
{
retryTest = true;
TestLogger?.WriteLine("Exception occurred in try number " + (numberOfTries + 1) + " : " + ex.ToString());
retryMessage = "Exception thrown.";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class Timing
{
public static readonly TimeSpan TimeToColdStart = TimeSpan.FromMinutes(5);
public static readonly TimeSpan TimeToConnect = TimeSpan.FromSeconds(30);
public static readonly TimeSpan TimeToWaitForLog = TimeSpan.FromMinutes(1);
public static readonly TimeSpan TimeToWaitForLog = TimeSpan.FromMinutes(3);
public static readonly TimeSpan TimeToApm = TimeSpan.FromMinutes(7);
public static readonly TimeSpan TimeBetweenHarvests = TimeSpan.FromMinutes(1);
public static readonly TimeSpan ApmCheckInterval = TimeSpan.FromSeconds(5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ public void Test()
NrAssert.Multiple(
() => Assert.Contains(@"""OTHER"":[[[""Native"",""Function Call"",0]", _threadProfileString),
() => Assert.Contains(@"[""HostedWebCore.Program"",""Main"",0]", _threadProfileString),
() => Assert.Contains(@"System.Threading", _threadProfileString),
() => Assert.Contains(@"System.Web", _threadProfileString)
() => Assert.Contains(@"System.Threading", _threadProfileString)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public InfiniteTracingTestsBase(TFixture fixture, ITestOutputHelper output) : ba
_fixture.SendCommand("InfiniteTracingTester Make8TSpan");
// Now wait to see that the 8T spans were sent successfully
_fixture.AgentLog.WaitForLogLinesCapturedIntCount(AgentLogBase.SpanStreamingSuccessfullySentLogLineRegex, TimeSpan.FromMinutes(1), ExpectedSentCount);
_fixture.AgentLog.WaitForLogLinesCapturedIntCount(AgentLogBase.SpanStreamingSuccessfullyProcessedByServerResponseLogLineRegex, TimeSpan.FromMinutes(1), ExpectedSentCount);
}

);
Expand All @@ -57,13 +56,11 @@ public void Test()
{
//1 span count for the Make8TSpan method, another span count for the root span.
var expectedSeenCount = 2;
var expectedReceivedCount = 2;

var actualMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"Supportability/InfiniteTracing/Span/Seen", callCount = expectedSeenCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/InfiniteTracing/Span/Sent", callCount = ExpectedSentCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/InfiniteTracing/Span/Received", callCount = expectedReceivedCount }
};

var metrics = _fixture.AgentLog.GetMetrics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ public void Test()

var generalMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsSeen", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Supportability/AnalyticsEvents/TotalEventsCollected", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"Apdex"},
new Assertions.ExpectedMetric { metricName = @"ApdexAll"},
new Assertions.ExpectedMetric { metricName = @"HttpDispatcher", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"HttpDispatcher", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransaction", CallCountAllHarvests = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"WebTransactionTotalTime", callCount = ExpectedTransactionCount },

new Assertions.ExpectedMetric { metricName = @"DotNet/Owin Middleware Pipeline", callCount = ExpectedTransactionCount },
new Assertions.ExpectedMetric { metricName = @"DotNet/Owin Middleware Pipeline", CallCountAllHarvests = ExpectedTransactionCount },
};

var ioBoundNoSpecialAsyncMetrics = new List<Assertions.ExpectedMetric> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public void Test()

var expectedMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric {metricName = @"DotNet/Owin Middleware Pipeline", callCount = expectedCallCount},
new Assertions.ExpectedMetric {metricName = @"WebTransaction", callCount = expectedCallCount},
new Assertions.ExpectedMetric {metricName = @"WebTransaction/StatusCode/404", callCount = expectedCallCount},
new Assertions.ExpectedMetric {metricName = @"DotNet/Owin Middleware Pipeline", CallCountAllHarvests = expectedCallCount},
new Assertions.ExpectedMetric {metricName = @"WebTransaction", CallCountAllHarvests = expectedCallCount},
new Assertions.ExpectedMetric {metricName = @"WebTransaction/StatusCode/404", CallCountAllHarvests = expectedCallCount},
};
var unexpectedMetrics = new List<Assertions.ExpectedMetric>();
foreach (var bogusPath in bogusPaths)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ private void WriteApplicationAgentLogToTestLogger(string applicationName, Remote
public override void ShutdownRemoteApplication()
{
FirstCallApplication.Shutdown();
FirstCallApplication.WaitForExit();
FirstCallApplication.CapturedOutput?.WriteProcessOutputToLog($"{nameof(FirstCallApplication)} application:");

SecondCallApplication.Shutdown();
SecondCallApplication.WaitForExit();
SecondCallApplication.CapturedOutput?.WriteProcessOutputToLog($"{nameof(SecondCallApplication)} application:");

base.ShutdownRemoteApplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ public void BulkCreatingItemsTests()
new Assertions.ExpectedMetric { metricName = $"Datastore/operation/CosmosDB/ReadDatabase", metricScope = expectedTransactionName, callCount = 1 },
new Assertions.ExpectedMetric { metricName = $"Datastore/operation/CosmosDB/DeleteDatabase", metricScope = expectedTransactionName, callCount = 1 },
new Assertions.ExpectedMetric { metricName = $"Datastore/operation/CosmosDB/CreateCollection", metricScope = expectedTransactionName, callCount = 1 },
new Assertions.ExpectedMetric { metricName = $"Datastore/statement/CosmosDB/{_testContainerName}/BatchDocument", metricScope = expectedTransactionName, callCount = 1 }
};

var metrics = _fixture.AgentLog.GetMetrics().ToList();
Expand Down

0 comments on commit 8cedbb6

Please sign in to comment.