-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix a crash that can occur when the profiler logs certain charac…
- Loading branch information
1 parent
2d8da68
commit 742d232
Showing
7 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...rationTests/ContainerIntegrationTests/ContainerFixtures/LinuxUnicodeLogFileTestFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2020 New Relic, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
namespace NewRelic.Agent.ContainerIntegrationTests.ContainerFixtures | ||
{ | ||
public class LinuxUnicodeLogFileTestFixture : LinuxSmokeTestFixtureBase | ||
{ | ||
private static readonly string Dockerfile = "SmokeTestApp/Dockerfile"; | ||
private static readonly string ApplicationDirectoryName = "LinuxUnicodeLogfileTestApp"; | ||
private static readonly ContainerApplication.Architecture Architecture = ContainerApplication.Architecture.X64; | ||
private static readonly string DistroTag = "jammy"; | ||
|
||
public LinuxUnicodeLogFileTestFixture() : base(ApplicationDirectoryName, DistroTag, Architecture, Dockerfile) { } | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
tests/Agent/IntegrationTests/ContainerIntegrationTests/LinuxUnicodeLogFileTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2020 New Relic, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using NewRelic.Agent.IntegrationTestHelpers; | ||
using Xunit.Abstractions; | ||
using Xunit; | ||
using NewRelic.Agent.ContainerIntegrationTests.ContainerFixtures; | ||
using System; | ||
|
||
namespace ContainerIntegrationTests | ||
{ | ||
/// <summary> | ||
/// This test is meant to prevent any regressions from occurring when profiler log lines containing | ||
/// character codes outside of the ascii range are written to log files. Older profiler versions | ||
/// could trigger an error or crash when this happened. Before the profiler change, no transactions | ||
/// would be created by the test application, with the profiler change, the test transaction should be | ||
/// created successfully. | ||
/// </summary> | ||
public class LinuxUnicodeLogFileTest : NewRelicIntegrationTest<DebianX64SmokeTestFixture> | ||
{ | ||
private readonly DebianX64SmokeTestFixture _fixture; | ||
|
||
public LinuxUnicodeLogFileTest(DebianX64SmokeTestFixture fixture, ITestOutputHelper output) : base(fixture) | ||
{ | ||
_fixture = fixture; | ||
_fixture.TestLogger = output; | ||
|
||
_fixture.Actions(setupConfiguration: () => | ||
{ | ||
var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath); | ||
configModifier.ConfigureFasterMetricsHarvestCycle(10); | ||
// The original problem only seemed to occur with some of the finest level log lines | ||
// and it did not occur with console logs. | ||
configModifier.SetLogLevel("finest"); | ||
}, | ||
exerciseApplication: () => | ||
{ | ||
_fixture.ExerciseApplication(); | ||
|
||
_fixture.Delay(11); // wait long enough to ensure a metric harvest occurs after we exercise the app | ||
_fixture.AgentLog.WaitForLogLine(AgentLogBase.HarvestFinishedLogLineRegex, TimeSpan.FromSeconds(11)); | ||
|
||
// shut down the container and wait for the agent log to see it | ||
_fixture.ShutdownRemoteApplication(); | ||
_fixture.AgentLog.WaitForLogLine(AgentLogBase.ShutdownLogLineRegex, TimeSpan.FromSeconds(10)); | ||
}); | ||
|
||
_fixture.Initialize(); | ||
} | ||
|
||
[Fact] | ||
public void Test() | ||
{ | ||
var actualMetrics = _fixture.AgentLog.GetMetrics(); | ||
|
||
Assert.Contains(actualMetrics, m => m.MetricSpec.Name.Equals("WebTransaction/MVC/WeatherForecast/Get")); | ||
} | ||
} | ||
} |