Skip to content

Commit d3117a4

Browse files
authored
test: Upgrade to XUnit 2.9.0, fix some test failures (#2684) (#2686)
1 parent 18a17af commit d3117a4

File tree

7 files changed

+27
-29
lines changed

7 files changed

+27
-29
lines changed

.github/dependabot.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,4 @@ updates:
4343
- dependency-name: "Microsoft.VisualStudio.Threading.Analyzers"
4444
- dependency-name: "NUnit*"
4545
- dependency-name: "Selenium*"
46-
# Enable xunit after we fix the v2.9.0 upgrade blocker https://github.com/newrelic/newrelic-dotnet-agent/issues/2684
47-
# - dependency-name: "xunit*"
46+
- dependency-name: "xunit*"

tests/Agent/IntegrationTests/ContainerIntegrationTests/ContainerIntegrationTests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
13-
<PackageReference Include="xunit" Version="2.8.0" />
14-
<PackageReference Include="xunit.runner.console" Version="2.8.0">
13+
<PackageReference Include="xunit" Version="2.9.0" />
14+
<PackageReference Include="xunit.runner.console" Version="2.9.0">
1515
<PrivateAssets>all</PrivateAssets>
1616
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1717
</PackageReference>

tests/Agent/IntegrationTests/IntegrationTestHelpers/AgentLogBase.cs

+10-11
Original file line numberDiff line numberDiff line change
@@ -88,34 +88,37 @@ public AgentLogBase(ITestOutputHelper testLogger)
8888

8989
public abstract IEnumerable<string> GetFileLines();
9090

91-
public string GetAccountId(TimeSpan? timeoutOrZero = null)
91+
public string GetAccountId()
9292
{
93-
var reportingAppLink = GetReportingAppLink(timeoutOrZero);
93+
var reportingAppLink = GetReportingAppLink();
9494
var reportingAppUri = new Uri(reportingAppLink);
9595
var accountId = reportingAppUri.Segments[2];
9696
if (accountId == null)
9797
throw new Exception("Could not find account ID in second segment of reporting app link: " + reportingAppLink);
9898
return accountId.TrimEnd('/');
9999
}
100100

101-
public string GetApplicationId(TimeSpan? timeoutOrZero = null)
101+
public string GetApplicationId()
102102
{
103-
var reportingAppLink = GetReportingAppLink(timeoutOrZero);
103+
var reportingAppLink = GetReportingAppLink();
104104
var reportingAppUri = new Uri(reportingAppLink);
105105
var applicationId = reportingAppUri.Segments[4];
106106
if (applicationId == null)
107107
throw new Exception("Could not find application ID in second segment of reporting app link: " + reportingAppLink);
108108
return applicationId.TrimEnd('/');
109109
}
110110

111-
public string GetCrossProcessId(TimeSpan? timeoutOrZero = null)
111+
public string GetCrossProcessId()
112112
{
113113
return $@"{GetAccountId()}#{GetApplicationId()}";
114114
}
115115

116-
public string GetReportingAppLink(TimeSpan? timeoutOrZero = null)
116+
private string GetReportingAppLink()
117117
{
118-
var match = WaitForLogLine(AgentReportingToLogLineRegex, timeoutOrZero);
118+
var match = TryGetLogLine(AgentReportingToLogLineRegex);
119+
if (!match.Success || match.Groups.Count < 2)
120+
throw new Exception("Could not find reporting app link in log file.");
121+
119122
return match.Groups[1].Value;
120123
}
121124

@@ -164,23 +167,19 @@ public IEnumerable<Match> WaitForLogLines(string regularExpression, TimeSpan? ti
164167

165168
var timeout = timeoutOrZero ?? TimeSpan.Zero;
166169

167-
_testLogger?.WriteLine($"{Timestamp} WaitForLogLines Waiting for expression: {regularExpression}. Duration: {timeout.TotalSeconds:N0} seconds. Minimum count: {minimumCount}");
168-
169170
var timeTaken = Stopwatch.StartNew();
170171
do
171172
{
172173
var matches = TryGetLogLines(regularExpression).ToList();
173174
if (matches.Count >= minimumCount)
174175
{
175-
_testLogger?.WriteLine($"{Timestamp} WaitForLogLines Matched expression: {regularExpression} in {timeTaken.Elapsed.TotalSeconds:N1}s.");
176176
return matches;
177177
}
178178

179179
Thread.Sleep(TimeSpan.FromMilliseconds(100));
180180
} while (timeTaken.Elapsed < timeout);
181181

182182
var message = $"{Timestamp} Log line did not appear a minimum of {minimumCount} times within {timeout.TotalSeconds:N0} seconds. Expected line expression: {regularExpression}";
183-
_testLogger?.WriteLine(message);
184183
throw new Exception(message);
185184
}
186185

tests/Agent/IntegrationTests/IntegrationTestHelpers/IntegrationTestHelpers.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
</PackageReference>
1212
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1313
<PackageReference Include="SharpZipLib" Version="1.4.2" />
14-
<PackageReference Include="xunit" version="2.8.0" />
15-
<PackageReference Include="xunit.assert" Version="2.8.0" />
16-
<PackageReference Include="xunit.core" Version="2.8.0" />
14+
<PackageReference Include="xunit" version="2.9.0" />
15+
<PackageReference Include="xunit.assert" Version="2.9.0" />
16+
<PackageReference Include="xunit.core" Version="2.9.0" />
1717
</ItemGroup>
1818
<ItemGroup>
1919
<ProjectReference Include="..\..\Shared\TestSerializationHelpers\TestSerializationHelpers.csproj" />

tests/Agent/IntegrationTests/IntegrationTests/IntegrationTests.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
4343
<PackageReference Include="Selenium.Support" Version="4.17.0" />
4444
<PackageReference Include="Selenium.WebDriver" Version="4.17.0" />
45-
<PackageReference Include="xunit" Version="2.8.0" />
45+
<PackageReference Include="xunit" Version="2.9.0" />
4646
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
47-
<PackageReference Include="xunit.assert" Version="2.8.0" />
48-
<PackageReference Include="xunit.core" Version="2.8.0" />
49-
<PackageReference Include="xunit.runner.console" Version="2.8.0">
47+
<PackageReference Include="xunit.assert" Version="2.9.0" />
48+
<PackageReference Include="xunit.core" Version="2.9.0" />
49+
<PackageReference Include="xunit.runner.console" Version="2.9.0">
5050
<PrivateAssets>all</PrivateAssets>
5151
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5252
</PackageReference>

tests/Agent/IntegrationTests/UnboundedIntegrationTests/UnboundedIntegrationTests.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
5252
<PackageReference Include="CouchbaseNetClient" Version="2.3.8" />
5353
<PackageReference Include="Oracle.ManagedDataAccess" Version="12.1.2400" />
54-
<PackageReference Include="xunit" version="2.8.0" />
55-
<PackageReference Include="xunit.assert" Version="2.8.0" />
56-
<PackageReference Include="xunit.core" Version="2.8.0" />
54+
<PackageReference Include="xunit" version="2.9.0" />
55+
<PackageReference Include="xunit.assert" Version="2.9.0" />
56+
<PackageReference Include="xunit.core" Version="2.9.0" />
5757
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
5858
<PrivateAssets>all</PrivateAssets>
5959
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

tests/Agent/Shared/TestSerializationHelpers.Test/TestSerializationHelpers.Test.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
<PrivateAssets>all</PrivateAssets>
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageReference>
14-
<PackageReference Include="xunit" Version="2.8.0" />
14+
<PackageReference Include="xunit" Version="2.9.0" />
1515
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
16-
<PackageReference Include="xunit.assert" Version="2.8.0" />
17-
<PackageReference Include="xunit.core" Version="2.8.0" />
18-
<PackageReference Include="xunit.runner.console" Version="2.8.0">
16+
<PackageReference Include="xunit.assert" Version="2.9.0" />
17+
<PackageReference Include="xunit.core" Version="2.9.0" />
18+
<PackageReference Include="xunit.runner.console" Version="2.9.0">
1919
<PrivateAssets>all</PrivateAssets>
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2121
</PackageReference>

0 commit comments

Comments
 (0)