Пример #1
0
        public RejitAddNode(AspNetFrameworkReJitMvcApplicationFixture 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.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, "RejitMvcApplication", "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();
        }
        private void ConfigureASPNetCompatibilityMode(bool enabled)
        {
            //Clean out any bindings that are in the Web.Config
            CommonUtils.DeleteXmlNode(_hostedWebCore.WebConfigPath, "",
                                      new[] { "configuration", "system.serviceModel" }, "serviceHostingEnvironment");

            CommonUtils.AddXmlNode(_hostedWebCore.WebConfigPath, "",
                                   new[] { "configuration", "system.serviceModel" }, "serviceHostingEnvironment", string.Empty);

            CommonUtils.ModifyOrCreateXmlAttribute(_hostedWebCore.WebConfigPath, "",
                                                   new[] { "configuration", "system.serviceModel", "serviceHostingEnvironment" },
                                                   "aspNetCompatibilityEnabled", enabled.ToString().ToLower());

            CommonUtils.ModifyOrCreateXmlAttribute(_hostedWebCore.WebConfigPath, "",
                                                   new[] { "configuration", "system.serviceModel", "serviceHostingEnvironment" },
                                                   "multipleSiteBindingsEnabled", true.ToString().ToLower());
        }
        private void ConfigureBinding(WCFBindingType bindingType, string relativePath, int port)
        {
            //	<services>
            //		<service name="NewRelic.Agent.IntegrationTestHelpers.ApplicationLibraries.Wcf.WcfService">
            //			<endpoint address="___relativePath___" contract="IWcfService" binding="___bindingType___">
            //			</endpoint>
            //	 </service>
            //	</services>

            //Clean out any bindings that are in the Web.Config
            CommonUtils.DeleteXmlNode(_hostedWebCore.WebConfigPath, "",
                                      new[] { "configuration", "system.serviceModel" }, "services");

            //services node
            CommonUtils.AddXmlNode(_hostedWebCore.WebConfigPath, "",
                                   new[] { "configuration", "system.serviceModel" }, "services", string.Empty);

            //services/service/Name
            CommonUtils.ModifyOrCreateXmlAttribute(_hostedWebCore.WebConfigPath, "",
                                                   new[] { "configuration", "system.serviceModel", "services", "service" },
                                                   "name", "NewRelic.Agent.IntegrationTestHelpers.ApplicationLibraries.Wcf.WcfService");

            //services/service/endpoint - Address
            CommonUtils.ModifyOrCreateXmlAttribute(_hostedWebCore.WebConfigPath, "",
                                                   new[] { "configuration", "system.serviceModel", "services", "service", "endpoint" },
                                                   "address", relativePath);

            //services/service/endpoint - contract
            CommonUtils.ModifyOrCreateXmlAttribute(_hostedWebCore.WebConfigPath, "",
                                                   new[] { "configuration", "system.serviceModel", "services", "service", "endpoint" },
                                                   "contract", "IWcfService");

            //services/service/endpoint - binding
            CommonUtils.ModifyOrCreateXmlAttribute(_hostedWebCore.WebConfigPath, "",
                                                   new[] { "configuration", "system.serviceModel", "services", "service", "endpoint" },
                                                   "binding", _bindingTypeNames[bindingType]);

            if (bindingType == WCFBindingType.WebHttp)
            {
                CommonUtils.ModifyOrCreateXmlAttribute(_hostedWebCore.WebConfigPath, "",
                                                       new[] { "configuration", "system.serviceModel", "services", "service", "endpoint" },
                                                       "behaviorConfiguration", "webHttpBehavior");
            }
        }
        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();
        }