Skip to content

Commit

Permalink
test: Eliminate firewall pop-ups when running integration tests local…
Browse files Browse the repository at this point in the history
…ly (#2075)
  • Loading branch information
tippmar-nr authored Nov 16, 2023
1 parent 0249582 commit 1439e10
Show file tree
Hide file tree
Showing 67 changed files with 271 additions and 250 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void Main(string[] args)
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls($@"http://localhost:{_port}/")
.UseUrls($@"http://127.0.0.1:{_port}/")
.Build();

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void Main(string[] args)
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls(string.Format(@"http://localhost:{0}/", _port))
.UseUrls(string.Format(@"http://127.0.0.1:{0}/", _port))
.Build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
{
webBuilder
.UseStartup<Startup>()
.UseUrls($@"http://localhost:{_port}/");
.UseUrls($@"http://127.0.0.1:{_port}/");
});

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void Main(string[] args)
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls($@"http://localhost:{_port}/")
.UseUrls($@"http://127.0.0.1:{_port}/")
.Build();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void Main(string[] args)
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls($@"http://localhost:{_port}/")
.UseUrls($@"http://127.0.0.1:{_port}/")
.Build();

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void Main(string[] args)
public static IWebHost BuildWebHost(string[] args, string port) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls($@"http://localhost:{port}/")
.UseUrls($@"http://127.0.0.1:{port}/")
.Build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static void CreatePidFile()
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls($@"http://localhost:{_port}/")
.UseUrls($@"http://127.0.0.1:{_port}/")
.Build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void Main(string[] args)
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls($@"http://localhost:{_port}/")
.UseUrls($@"http://127.0.0.1:{_port}/")
.Build();

private static void CreatePidFile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void Main(string[] args)
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls($@"http://localhost:{_port}/")
.UseUrls($@"http://127.0.0.1:{_port}/")
.Build();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void Main(string[] args)
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls(string.Format(@"http://localhost:{0}/", _port))
.UseUrls(string.Format(@"http://127.0.0.1:{0}/", _port))
.Build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ await context.Response.WriteAsync(JsonSerializer.Serialize(subscriptions,
}));
});


app.Urls.Add($"http://*:{_port}");
app.Urls.Add($"http://127.0.0.1:{_port}");

var task = app.RunAsync(ct.Token);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static void Main(string[] args)

private void RealMain()
{
var baseAddress = string.Format(@"http://*:{0}/", Port);
var baseAddress = string.Format(@"http://127.0.0.1:{0}/", Port);
using (WebApp.Start<Startup>(baseAddress))
{
using (var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static void Main(string[] args)

private void RealMain()
{
var baseAddress = string.Format(@"http://*:{0}/", Port);
var baseAddress = string.Format(@"http://127.0.0.1:{0}/", Port);
using (WebApp.Start<Startup>(baseAddress))
{
using (var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static void Main(string[] args)

private void RealMain()
{
var baseAddress = string.Format(@"http://*:{0}/", Port);
var baseAddress = string.Format(@"http://127.0.0.1:{0}/", Port);
using (WebApp.Start<Startup>(baseAddress))
{
using (var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static void Main(string[] args)

private void RealMain()
{
var baseAddress = string.Format(@"http://*:{0}/", Port);
var baseAddress = string.Format(@"http://127.0.0.1:{0}/", Port);
using (WebApp.Start<Startup>(baseAddress))
{
var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "app_server_wait_for_all_request_done_" + Port.ToString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public class RemoteController : ApiController
[Route("GetObjectTcp")]
public string GetObjectTcp()
{
var myMarshalByRefClassObj = (MyMarshalByRefClass)Activator.GetObject(typeof(MyMarshalByRefClass), "tcp://localhost:7878/GetObject");
var myMarshalByRefClassObj = (MyMarshalByRefClass)Activator.GetObject(typeof(MyMarshalByRefClass), "tcp://127.0.0.1:7878/GetObject");
return GetObject(myMarshalByRefClassObj);
}

[Route("GetObjectHttp")]
public string GetObjectHttp()
{
var myMarshalByRefClassObj = (MyMarshalByRefClass)Activator.GetObject(typeof(MyMarshalByRefClass), "http://localhost:7879/GetObject");
var myMarshalByRefClassObj = (MyMarshalByRefClass)Activator.GetObject(typeof(MyMarshalByRefClass), "http://127.0.0.1:7879/GetObject");
return GetObject(myMarshalByRefClassObj);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static void Main(string[] args)

private void RealMain()
{
var baseAddress = string.Format(@"http://*:{0}/", Port);
var baseAddress = string.Format(@"http://127.0.0.1:{0}/", Port);
using (WebApp.Start<Startup>(baseAddress))
{
using (var eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,16 @@ static void Main(string[] args)

private void RealMain()
{
var serverProviderTcp = new BinaryServerFormatterSinkProvider();
serverProviderTcp.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
var serverProviderTcp = new BinaryServerFormatterSinkProvider { TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full };
var clientProviderTcp = new BinaryClientFormatterSinkProvider();
var propertiesTcp = new System.Collections.Hashtable();
propertiesTcp["port"] = 7878;
var propertiesTcp = new System.Collections.Hashtable { ["port"] = 7878, ["bindTo"] = "127.0.0.1" };

var tcpChannel = new TcpChannel(propertiesTcp, clientProviderTcp, serverProviderTcp);
ChannelServices.RegisterChannel(tcpChannel, false);

var serverProviderHttp = new SoapServerFormatterSinkProvider();
serverProviderHttp.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
var serverProviderHttp = new SoapServerFormatterSinkProvider { TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full };
var clientProviderHttp = new SoapClientFormatterSinkProvider();
var propertiesHttp = new System.Collections.Hashtable();
propertiesHttp["port"] = 7879;
var propertiesHttp = new System.Collections.Hashtable { ["port"] = 7879, ["bindTo"] = "127.0.0.1" };

var httpChannel = new HttpChannel(propertiesHttp, clientProviderHttp, serverProviderHttp);
ChannelServices.RegisterChannel(httpChannel, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void Main(string[] args)
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls($@"http://localhost:{_port}/")
.UseUrls($@"http://127.0.0.1:{_port}/")
.Build();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override void Configure(Container container)
// This plugin attempts to serialize everything in HttpContext using ServiceStack.Text
// It tests that we do not reintroduce a StackOverflow issue that can crash apps.
// We don't formally take responsibility over this but we do our best to do no harm.
Plugins.Add(new SeqRequestLogsFeature { SeqUrl = "http://localhost:5341" });
Plugins.Add(new SeqRequestLogsFeature { SeqUrl = "http://127.0.0.1:5341" });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public string UniqueFolderName

public int Port => _port ?? (_port = RandomPortGenerator.NextPort()).Value;

public readonly string DestinationServerName = Dns.GetHostName().ToLower();
public static readonly string DestinationServerName = "127.0.0.1";

private NewRelicConfigModifier _newRelicConfigModifier;
public NewRelicConfigModifier NewRelicConfig => _newRelicConfigModifier ?? (_newRelicConfigModifier = new NewRelicConfigModifier(DestinationNewRelicConfigFilePath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private void SetSitePortInApplicationHostConfig()
};
var attributes = new[]
{
new KeyValuePair<string, string>("bindingInformation", string.Format(@"*:{0}:", Port)),
new KeyValuePair<string, string>("bindingInformation", string.Format(@"127.0.0.1:{0}:", Port)),
};
XmlUtils.ModifyOrCreateXmlAttributes(DestinationApplicationHostConfigFilePath, string.Empty, nodes, attributes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Net.Http.Headers;
using NewRelic.Agent.IntegrationTestHelpers;
using NewRelic.Agent.IntegrationTestHelpers.Models;
using NewRelic.Agent.IntegrationTestHelpers.RemoteServiceFixtures;
using NewRelic.Agent.IntegrationTests.CatInbound;
using NewRelic.Testing.Assertions;
using Xunit;
Expand Down Expand Up @@ -62,15 +63,15 @@ public void Test()
{
new Assertions.ExpectedMetric { metricName = @"External/all", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"External/allWeb", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"External/{_fixture.RemoteApplication.DestinationServerName}/all", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"External/{_fixture.RemoteApplication.DestinationServerName}/Stream/GET", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"External/{_fixture.RemoteApplication.DestinationServerName}/Stream/GET", metricScope = @"WebTransaction/MVC/DefaultController/ChainedWebRequest", callCount = 1 }
new Assertions.ExpectedMetric { metricName = $@"External/{RemoteApplication.DestinationServerName}/all", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"External/{RemoteApplication.DestinationServerName}/Stream/GET", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"External/{RemoteApplication.DestinationServerName}/Stream/GET", metricScope = @"WebTransaction/MVC/DefaultController/ChainedWebRequest", callCount = 1 }
};
var unexpectedMetrics = new List<Assertions.ExpectedMetric>
{
new Assertions.ExpectedMetric { metricName = $@"ExternalApp/{_fixture.RemoteApplication.DestinationServerName}/{crossProcessId}/all", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"ExternalTransaction/{_fixture.RemoteApplication.DestinationServerName}/{crossProcessId}/WebTransaction/MVC/DefaultController/Index" },
new Assertions.ExpectedMetric { metricName = $@"ExternalTransaction/{_fixture.RemoteApplication.DestinationServerName}/{crossProcessId}/WebTransaction/MVC/DefaultController/Index", metricScope = @"WebTransaction/MVC/DefaultController/ChainedWebRequest" },
new Assertions.ExpectedMetric { metricName = $@"ExternalApp/{RemoteApplication.DestinationServerName}/{crossProcessId}/all", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"ExternalTransaction/{RemoteApplication.DestinationServerName}/{crossProcessId}/WebTransaction/MVC/DefaultController/Index" },
new Assertions.ExpectedMetric { metricName = $@"ExternalTransaction/{RemoteApplication.DestinationServerName}/{crossProcessId}/WebTransaction/MVC/DefaultController/Index", metricScope = @"WebTransaction/MVC/DefaultController/ChainedWebRequest" },
new Assertions.ExpectedMetric { metricName = @"ClientApplication/[^/]+/all", IsRegexName = true }
};
var expectedCallerTraceSegmentRegexes = new List<string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Net.Http.Headers;
using NewRelic.Agent.IntegrationTestHelpers;
using NewRelic.Agent.IntegrationTestHelpers.Models;
using NewRelic.Agent.IntegrationTestHelpers.RemoteServiceFixtures;
using NewRelic.Testing.Assertions;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -75,7 +76,7 @@ public void Test()
var unexpectedMetrics = new List<Assertions.ExpectedMetric>
{
// This scoped metric should be superceded by the ExternalTransaction metric above
new Assertions.ExpectedMetric { metricName = $@"External/{_fixture.RemoteApplication.DestinationServerName}/Stream/GET", metricScope = @"WebTransaction/MVC/RestSharpController/AsyncAwaitClient" }
new Assertions.ExpectedMetric { metricName = $@"External/{RemoteApplication.DestinationServerName}/Stream/GET", metricScope = @"WebTransaction/MVC/RestSharpController/AsyncAwaitClient" }
};

// Note: we are checking the attributes attached to the *Callee's* transaction, not the caller's transaction. The attributes attached to the caller's transaction are already fully vetted in the CatInbound tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Net.Http.Headers;
using NewRelic.Agent.IntegrationTestHelpers;
using NewRelic.Agent.IntegrationTestHelpers.Models;
using NewRelic.Agent.IntegrationTestHelpers.RemoteServiceFixtures;
using NewRelic.Testing.Assertions;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -67,17 +68,17 @@ public void Test()
{
new Assertions.ExpectedMetric { metricName = @"External/all", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"External/allWeb", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"External/{_fixture.RemoteApplication.DestinationServerName}/all", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"ExternalApp/{_fixture.RemoteApplication.DestinationServerName}/{crossProcessId}/all", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"ExternalTransaction/{_fixture.RemoteApplication.DestinationServerName}/{crossProcessId}/WebTransaction/MVC/DefaultController/Index", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"ExternalTransaction/{_fixture.RemoteApplication.DestinationServerName}/{crossProcessId}/WebTransaction/MVC/DefaultController/Index", metricScope = @"WebTransaction/MVC/DefaultController/ChainedHttpClient", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"External/{_fixture.RemoteApplication.DestinationServerName}/Stream/GET", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"External/{RemoteApplication.DestinationServerName}/all", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"ExternalApp/{RemoteApplication.DestinationServerName}/{crossProcessId}/all", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"ExternalTransaction/{RemoteApplication.DestinationServerName}/{crossProcessId}/WebTransaction/MVC/DefaultController/Index", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"ExternalTransaction/{RemoteApplication.DestinationServerName}/{crossProcessId}/WebTransaction/MVC/DefaultController/Index", metricScope = @"WebTransaction/MVC/DefaultController/ChainedHttpClient", callCount = 1 },
new Assertions.ExpectedMetric { metricName = $@"External/{RemoteApplication.DestinationServerName}/Stream/GET", callCount = 1 },
new Assertions.ExpectedMetric { metricName = @"ClientApplication/[^/]+/all", IsRegexName = true }
};
var unexpectedMetrics = new List<Assertions.ExpectedMetric>
{
// This scoped metric should be superceded by the ExternalTransaction metric above
new Assertions.ExpectedMetric { metricName = $@"External/{_fixture.RemoteApplication.DestinationServerName}/Stream/GET", metricScope = @"WebTransaction/MVC/DefaultController/ChainedHttpClient" }
new Assertions.ExpectedMetric { metricName = $@"External/{RemoteApplication.DestinationServerName}/Stream/GET", metricScope = @"WebTransaction/MVC/DefaultController/ChainedHttpClient" }
};
// Note: we are checking the attributes attached to the *Callee's* transaction, not the caller's transaction. The attributes attached to the caller's transaction are already fully vetted in the CatInbound tests.
var expectedTransactionEventIntrinsicAttributes1 = new List<string>
Expand Down
Loading

0 comments on commit 1439e10

Please sign in to comment.