Skip to content

Commit be8f76e

Browse files
authored
test: reduce logging integration testing time (#1606)
1 parent dceecc7 commit be8f76e

File tree

11 files changed

+431
-1861
lines changed

11 files changed

+431
-1861
lines changed

.github/workflows/all_solutions.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,7 @@ jobs:
471471
matrix:
472472
namespace: [ AgentFeatures, AgentLogs, AgentMetrics, Api, AppDomainCaching, AspNetCore, BasicInstrumentation, CatInbound, CatOutbound, CodeLevelMetrics, Configuration,
473473
CSP, CustomAttributes, CustomInstrumentation, DataTransmission, DistributedTracing, Errors, HttpClientInstrumentation, InfiniteTracing, Logging.ContextData,
474-
Logging.HsmAndCsp, Logging.LocalDecoration, Logging.LogLevelDetection, Logging.MaxSamplesStored, Logging.MetricsAndForwarding.log4net,
475-
Logging.MetricsAndForwarding.MicrosoftLogging, Logging.MetricsAndForwarding.NLog, Logging.MetricsAndForwarding.Serilog, Logging.ZeroMaxSamplesStored,
474+
Logging.HsmAndCsp, Logging.LocalDecoration, Logging.LogLevelDetection, Logging.MaxSamplesStored, Logging.MetricsAndForwarding, Logging.ZeroMaxSamplesStored,
476475
Owin, ReJit.NetCore, ReJit.NetFramework, RequestHandling, RequestHeadersCapture.AspNet, RequestHeadersCapture.AspNetCore, RequestHeadersCapture.EnvironmentVariables,
477476
RequestHeadersCapture.Owin, RequestHeadersCapture.WCF, RestSharp, WCF.Client.IIS.ASPDisabled, WCF.Client.IIS.ASPEnabled, WCF.Client.Self,
478477
WCF.Service.IIS.ASPDisabled, WCF.Service.IIS.ASPEnabled, WCF.Service.Self] # maintain alphabetical order, please!

.github/workflows/run_integration_tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ jobs:
5454
# Use the full list of namespaces
5555
namespaces="[ 'AgentFeatures', 'AgentLogs', 'AgentMetrics', 'Api', 'AppDomainCaching', 'AspNetCore', 'BasicInstrumentation', 'CatInbound', 'CatOutbound', 'CodeLevelMetrics', 'Configuration', \
5656
'CSP', 'CustomAttributes', 'CustomInstrumentation', 'DataTransmission', 'DistributedTracing', 'Errors', 'HttpClientInstrumentation', 'InfiniteTracing', 'Logging.ContextData', \
57-
'Logging.HsmAndCsp', 'Logging.LocalDecoration', 'Logging.LogLevelDetection', 'Logging.MaxSamplesStored', 'Logging.MetricsAndForwarding.log4net', \
58-
'Logging.MetricsAndForwarding.MicrosoftLogging', 'Logging.MetricsAndForwarding.NLog', 'Logging.MetricsAndForwarding.Serilog', 'Logging.ZeroMaxSamplesStored', \
57+
'Logging.HsmAndCsp', 'Logging.LocalDecoration', 'Logging.LogLevelDetection', 'Logging.MaxSamplesStored', 'Logging.MetricsAndForwarding', 'Logging.ZeroMaxSamplesStored', \
5958
'Owin', 'ReJit.NetCore', 'ReJit.NetFramework', 'RequestHandling', 'RequestHeadersCapture.AspNet', 'RequestHeadersCapture.AspNetCore', 'RequestHeadersCapture.EnvironmentVariables', \
6059
'RequestHeadersCapture.Owin', 'RequestHeadersCapture.WCF', 'RestSharp', 'WCF.Client.IIS.ASPDisabled', 'WCF.Client.IIS.ASPEnabled', 'WCF.Client.Self', \
6160
'WCF.Service.IIS.ASPDisabled', 'WCF.Service.IIS.ASPEnabled', 'WCF.Service.Self' ]"

tests/Agent/IntegrationTests/IntegrationTests/Logging/ContextDataNotSupportedTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public ContextDataNotSupportedTestsBase(TFixture fixture, ITestOutputHelper outp
6060
},
6161
exerciseApplication: () =>
6262
{
63-
Thread.Sleep(TimeSpan.FromSeconds(2));
63+
_fixture.AgentLog.WaitForLogLine(AgentLogBase.LogDataLogLineRegex, TimeSpan.FromSeconds(30));
6464
}
6565
);
6666

tests/Agent/IntegrationTests/IntegrationTests/Logging/ContextDataTests.cs

Lines changed: 86 additions & 369 deletions
Large diffs are not rendered by default.

tests/Agent/IntegrationTests/IntegrationTests/Logging/HSMOrCSPDisablesForwardingTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public HSMOrCSPDisablesForwardingTestsBase(TFixture fixture, ITestOutputHelper o
3737

3838
// applicationLogging metrics and forwarding enabled by default
3939
configModifier
40-
.EnableDistributedTrace()
4140
.SetLogLevel("debug");
4241

4342
if (typeof(TFixture).ToString().Contains("HSM"))

tests/Agent/IntegrationTests/IntegrationTests/Logging/LocalDecorationTests.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2020 New Relic, Inc. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
using System;
45
using System.Linq;
56
using System.Text.RegularExpressions;
67
using System.Web;
@@ -34,7 +35,7 @@ public LocalDecorationTestsBase(TFixture fixture, ITestOutputHelper output, bool
3435
_decorationEnabled = decorationEnabled;
3536
_isWebLogTest = isWebLogTest;
3637
_fixture = fixture;
37-
_fixture.SetTimeout(System.TimeSpan.FromMinutes(2));
38+
_fixture.SetTimeout(TimeSpan.FromMinutes(2));
3839
_fixture.TestLogger = output;
3940

4041
_fixture.AddCommand($"LoggingTester SetFramework {loggingFramework}");
@@ -50,16 +51,20 @@ public LocalDecorationTestsBase(TFixture fixture, ITestOutputHelper output, bool
5051

5152
_fixture.RemoteApplication.AppName = _compositeApplicationName;
5253

53-
_fixture.Actions
54+
_fixture.AddActions
5455
(
5556
setupConfiguration: () =>
5657
{
5758
var configModifier = new NewRelicConfigModifier(fixture.DestinationNewRelicConfigFilePath);
5859

5960
configModifier
6061
.EnableLogDecoration(_decorationEnabled)
61-
.EnableDistributedTrace()
62-
.SetLogLevel("debug");
62+
.SetLogLevel("finest");
63+
},
64+
exerciseApplication: () =>
65+
{
66+
_fixture.AgentLog.WaitForLogLine(AgentLogBase.TransactionTransformCompletedLogLineRegex, TimeSpan.FromSeconds(30));
67+
_fixture.AgentLog.WaitForLogLine(AgentLogBase.LogDataLogLineRegex, TimeSpan.FromSeconds(30));
6368
}
6469
);
6570

@@ -71,8 +76,8 @@ public void LogIsDecorated()
7176
{
7277
var testOutput = _fixture.RemoteApplication.CapturedOutput.StandardOutput;
7378
// Make sure the original message is there
74-
var commandResults = Regex.Split(testOutput, System.Environment.NewLine).Where(l => !l.Contains("EXECUTING"));
75-
Assert.Contains(_testMessage, string.Join(System.Environment.NewLine, commandResults));
79+
var commandResults = Regex.Split(testOutput, Environment.NewLine).Where(l => !l.Contains("EXECUTING"));
80+
Assert.Contains(_testMessage, string.Join(Environment.NewLine, commandResults));
7681

7782
// Sample decorated data we are looking for:
7883
// "NR-LINKING|MjczMDcwfEFQTXxBUFBMSUNBVElPTnwxODQyMg|blah.hsd1.ca.comcast.net|45f120972d61834b96fb890d2a8f97e7|840d9a82e8bc18a8|myApplicationName|"

tests/Agent/IntegrationTests/IntegrationTests/Logging/LogLevelTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public LogLevelTestsBase(TFixture fixture, ITestOutputHelper output, LoggingFram
3838

3939
// applicationLogging metrics and forwarding enabled by default
4040
configModifier
41-
.EnableDistributedTrace()
4241
.SetLogLevel("debug");
4342
},
4443
exerciseApplication: () =>

tests/Agent/IntegrationTests/IntegrationTests/Logging/MaxSamplesStoredTests.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public abstract class MaxSamplesStoredTestsBase<TFixture> : NewRelicIntegrationT
1818
public MaxSamplesStoredTestsBase(TFixture fixture, ITestOutputHelper output, LoggingFramework loggingFramework) : base(fixture)
1919
{
2020
_fixture = fixture;
21-
_fixture.SetTimeout(System.TimeSpan.FromMinutes(2));
21+
_fixture.SetTimeout(TimeSpan.FromMinutes(2));
2222
_fixture.TestLogger = output;
2323

2424
_fixture.AddCommand($"LoggingTester SetFramework {loggingFramework}");
@@ -37,8 +37,10 @@ public MaxSamplesStoredTestsBase(TFixture fixture, ITestOutputHelper output, Log
3737

3838
// applicationLogging metrics and forwarding enabled by default
3939
configModifier
40+
// 12 is the per-minute sample limit.
41+
// It gets divided by 12 to come up with the per-five-second-faster-event-harvest limit of 1
42+
// (This assumes that the FEH interval is set to the default five seconds)
4043
.SetLogForwardingMaxSamplesStored(12)
41-
.EnableDistributedTrace()
4244
.SetLogLevel("debug");
4345
},
4446
exerciseApplication: () =>
@@ -61,7 +63,8 @@ public void OnlyOneLogLineIsSent()
6163
Assert.False(string.IsNullOrWhiteSpace(logData.Common.Attributes.EntityGuid));
6264
Assert.False(string.IsNullOrWhiteSpace(logData.Common.Attributes.Hostname));
6365

64-
// Since we set the maximum number of log lines stored to 1 in setupConfiguration, there should only be one log line
66+
// Since we set the maximum number of log lines per five-second harvest interval
67+
// stored to 1 in setupConfiguration, there should only be one log line
6568
Assert.Single(logData.Logs);
6669
var logLine = logData.Logs[0];
6770
Assert.False(string.IsNullOrWhiteSpace(logLine.Message));

0 commit comments

Comments
 (0)