|
| 1 | +// Copyright 2020 New Relic, Inc. All rights reserved. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +using NewRelic.Agent.IntegrationTestHelpers; |
| 5 | +using Xunit.Abstractions; |
| 6 | +using Xunit; |
| 7 | +using NewRelic.Agent.ContainerIntegrationTests.ContainerFixtures; |
| 8 | +using System; |
| 9 | + |
| 10 | +namespace ContainerIntegrationTests |
| 11 | +{ |
| 12 | + /// <summary> |
| 13 | + /// This test is meant to prevent any regressions from occurring when profiler log lines containing |
| 14 | + /// character codes outside of the ascii range are written to log files. Older profiler versions |
| 15 | + /// could trigger an error or crash when this happened. Before the profiler change, no transactions |
| 16 | + /// would be created by the test application, with the profiler change, the test transaction should be |
| 17 | + /// created successfully. |
| 18 | + /// </summary> |
| 19 | + public class LinuxUnicodeLogFileTest : NewRelicIntegrationTest<DebianX64SmokeTestFixture> |
| 20 | + { |
| 21 | + private readonly DebianX64SmokeTestFixture _fixture; |
| 22 | + |
| 23 | + public LinuxUnicodeLogFileTest(DebianX64SmokeTestFixture fixture, ITestOutputHelper output) : base(fixture) |
| 24 | + { |
| 25 | + _fixture = fixture; |
| 26 | + _fixture.TestLogger = output; |
| 27 | + |
| 28 | + _fixture.Actions(setupConfiguration: () => |
| 29 | + { |
| 30 | + var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath); |
| 31 | + configModifier.ConfigureFasterMetricsHarvestCycle(10); |
| 32 | + // The original problem only seemed to occur with some of the finest level log lines |
| 33 | + // and it did not occur with console logs. |
| 34 | + configModifier.SetLogLevel("finest"); |
| 35 | + }, |
| 36 | + exerciseApplication: () => |
| 37 | + { |
| 38 | + _fixture.ExerciseApplication(); |
| 39 | + |
| 40 | + _fixture.Delay(11); // wait long enough to ensure a metric harvest occurs after we exercise the app |
| 41 | + _fixture.AgentLog.WaitForLogLine(AgentLogBase.HarvestFinishedLogLineRegex, TimeSpan.FromSeconds(11)); |
| 42 | + |
| 43 | + // shut down the container and wait for the agent log to see it |
| 44 | + _fixture.ShutdownRemoteApplication(); |
| 45 | + _fixture.AgentLog.WaitForLogLine(AgentLogBase.ShutdownLogLineRegex, TimeSpan.FromSeconds(10)); |
| 46 | + }); |
| 47 | + |
| 48 | + _fixture.Initialize(); |
| 49 | + } |
| 50 | + |
| 51 | + [Fact] |
| 52 | + public void Test() |
| 53 | + { |
| 54 | + var actualMetrics = _fixture.AgentLog.GetMetrics(); |
| 55 | + |
| 56 | + Assert.Contains(actualMetrics, m => m.MetricSpec.Name.Equals("WebTransaction/MVC/WeatherForecast/Get")); |
| 57 | + } |
| 58 | + } |
| 59 | +} |
0 commit comments