protected RejitChangeAttributeValueBase(TFixture fixture, ITestOutputHelper output) : base(fixture)
        {
            _fixture = fixture;

            var changeAttributeFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.ChangeAttributeTest.xml";

            _fixture.TestLogger = output;
            _fixture.Actions(
                setupConfiguration: () =>
            {
                var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath);
                configModifier.SetLogLevel("finest");
                configModifier.AutoInstrumentBrowserMonitoring(false);

                CommonUtils.AddCustomInstrumentation(changeAttributeFilePath, "AspNetCoreMvcRejitApplication", "RejitMvcApplication.Controllers.RejitController", "CustomMethodDefaultWrapperChangeAttributeValue", "NewRelic.Agent.Core.Wrapper.DefaultWrapper", "MyCustomChangeMetricName", 7);
            },
                exerciseApplication: () =>
            {
                _fixture.InitializeApp();

                _fixture.TestChangeAttributeValue();
                CommonUtils.ModifyOrCreateXmlAttribute(changeAttributeFilePath, "urn:newrelic-extension", new[] { "extension", "instrumentation", "tracerFactory" }, "metricName", "MyCustomRenamedMetricName");
                _fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1));
                _fixture.TestChangeAttributeValue();
            });

            _fixture.Initialize();
        }
Exemplo n.º 2
0
        protected RejitAddNodeBase(TFixture fixture, ITestOutputHelper output) : base(fixture)
        {
            _fixture = fixture;

            var addNodeFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.AddNodeTest.xml";

            _fixture.TestLogger = output;
            _fixture.Actions(
                setupConfiguration: () =>
            {
                var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath);
                configModifier.SetLogLevel("finest");
                configModifier.AutoInstrumentBrowserMonitoring(false);

                CommonUtils.CreateEmptyInstrumentationFile(addNodeFilePath);
            },
                exerciseApplication: () =>
            {
                _fixture.InitializeApp();

                _fixture.TestAddNode(1);     // this will cause this method require a full rejit (differnet profiler code)
                var document = CommonUtils.AddCustomInstrumentation(addNodeFilePath, "AspNetCoreMvcRejitApplication", "RejitMvcApplication.Controllers.RejitController", "CustomMethodDefaultWrapperAddNode", "NewRelic.Agent.Core.Wrapper.DefaultWrapper", "MyCustomAddMetricName", 7, false);
                CommonUtils.AddXmlNode(addNodeFilePath, "urn:newrelic-extension", new[] { "extension", "instrumentation", "tracerFactory", "match" }, "exactMethodMatcher", string.Empty, "methodName", "CustomMethodDefaultWrapperAddNode1", false, document);
                // Potential future addition: Adding a test for new match element.  not adding now since it would require a second app to test really well.
                document.Save(addNodeFilePath);
                _fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1));
                _fixture.TestAddNode(0);
                _fixture.TestAddNode(1);
            });

            _fixture.Initialize();
        }
        protected RejitDeleteFileBase(TFixture fixture, ITestOutputHelper output) : base(fixture)
        {
            _fixture = fixture;

            var deleteFileFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.DeleteXmlFileTest.xml";

            _fixture.TestLogger = output;
            _fixture.Actions(
                setupConfiguration: () =>
            {
                var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath);
                configModifier.SetLogLevel("finest");
                configModifier.AutoInstrumentBrowserMonitoring(false);

                CommonUtils.AddCustomInstrumentation(deleteFileFilePath, "AspNetCoreMvcRejitApplication", "RejitMvcApplication.Controllers.RejitController", "CustomMethodDefaultWrapperDeleteFile", "NewRelic.Agent.Core.Wrapper.DefaultWrapper", "MyCustomDeleteMetricName", 7);
            },
                exerciseApplication: () =>
            {
                _fixture.InitializeApp();

                _fixture.TestDeleteFile();
                CommonUtils.DeleteFile(deleteFileFilePath, TimeSpan.FromSeconds(5));
                _fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1));
                _fixture.TestDeleteFile();
            });

            _fixture.Initialize();
        }
        protected RejitDeleteNodeBase(TFixture fixture, ITestOutputHelper output) : base(fixture)
        {
            _fixture = fixture;

            var deleteNodeFilePath = _fixture.RemoteApplication.DestinationExtensionsDirectoryPath + @"\Integration.Testing.DeleteNodeTest.xml";

            _fixture.TestLogger = output;
            _fixture.Actions(
                setupConfiguration: () =>
            {
                var configModifier = new NewRelicConfigModifier(_fixture.DestinationNewRelicConfigFilePath);
                configModifier.SetLogLevel("finest");
                configModifier.AutoInstrumentBrowserMonitoring(false);

                var document = CommonUtils.AddCustomInstrumentation(deleteNodeFilePath, "AspNetCoreMvcRejitApplication", "RejitMvcApplication.Controllers.RejitController", "CustomMethodDefaultWrapperDeleteNode", "NewRelic.Agent.Core.Wrapper.DefaultWrapper", "MyCustomDeleteMetricName", 7, false);
                CommonUtils.AddXmlNode(deleteNodeFilePath, "urn:newrelic-extension", new[] { "extension", "instrumentation", "tracerFactory", "match" }, "exactMethodMatcher", string.Empty, "methodName", "CustomMethodDefaultWrapperDeleteNode1", true, document);
            },
                exerciseApplication: () =>
            {
                _fixture.InitializeApp();

                _fixture.TestDeleteNode(0);
                _fixture.TestDeleteNode(1);
                CommonUtils.DeleteXmlNode(deleteNodeFilePath, "urn:newrelic-extension",
                                          new[] { "extension", "instrumentation", "tracerFactory", "match" }, "exactMethodMatcher"); // deletes first one (CustomMethodDefaultWrapperDeleteNode)
                _fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1));
                _fixture.TestDeleteNode(0);
                _fixture.TestDeleteNode(1);


                // Uncommenting the following lines lead to odd metric counts. Manual testing of this scenario does not seem
                // to indicate a problem. For now, just chalking it up to timing issue with how our tests are run...

                //CommonUtils.DeleteXmlNode(_deleteNodeFilePath, "urn:newrelic-extension",
                //	new[] { "extension", "instrumentation" }, "tracerFactory");
                //_fixture.AgentLog.WaitForLogLine(AgentLogBase.InstrumentationRefreshFileWatcherComplete, TimeSpan.FromMinutes(1));
                //_fixture.TestDeleteNode(0);
                //_fixture.TestDeleteNode(1);
            });

            _fixture.Initialize();
        }