Use InMemory channel in functional tests (#1204)

* Use InMemooryChannel for predictable flush and minor improvements

* and web funs

* clean up

* Docker container recreation fixes
This commit is contained in:
Liudmila Molkova 2019-05-23 12:55:51 -07:00 коммит произвёл GitHub
Родитель c6d332157f
Коммит 0047cd1df3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 53 добавлений и 41 удалений

Просмотреть файл

@ -74,12 +74,13 @@ namespace E2ETests
GetDockerCompose();
Trace.WriteLine("Getting docker-compose.exe completed.");
//DockerUtils.RemoveDockerImage(Apps[AppNameBeingTested].imageName, true);
//DockerUtils.RemoveDockerContainer(Apps[AppNameBeingTested].containerName, true);
DockerUtils.RemoveDockerImage(Apps[AppNameBeingTested].imageName, true);
DockerUtils.RemoveDockerContainer(Apps[AppNameBeingTested].containerName, true);
// Deploy the docker cluster using Docker-Compose
//DockerUtils.ExecuteDockerComposeCommand("up -d --force-recreate --build", DockerComposeFileName);
DockerUtils.ExecuteDockerComposeCommand("up -d --build", DockerComposeFileName);
DockerUtils.ExecuteDockerComposeCommand("up -d --force-recreate --build", DockerComposeFileName);
//DockerUtils.ExecuteDockerComposeCommand("up -d --build", DockerComposeFileName);
Thread.Sleep(5000);
DockerUtils.PrintDockerProcessStats("Docker-Compose -build");

Просмотреть файл

@ -7,8 +7,8 @@ namespace E2ETests.net471
[TestClass]
public class Test452OnNet471 : Test452Base
{
private static string VersionPrefix;
private static string VersionPrefixSql;
private const string VersionPrefix = "rdddsd";
private const string VersionPrefixSql = "rddf";
public TestContext TestContext { get; set; }
@ -18,9 +18,6 @@ namespace E2ETests.net471
DockerComposeFileName = "docker-compose452AppOn471.yml";
AppNameBeingTested = TestConstants.WebAppName;
VersionPrefix = "rdddsd";
VersionPrefixSql = "rddf";
if (!Apps.ContainsKey(AppNameBeingTested))
{
Apps.Add(AppNameBeingTested, new DeployedApp

Просмотреть файл

@ -79,7 +79,7 @@
<IncludedTypes>Event</IncludedTypes>
</Add>
</TelemetryProcessors>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel">
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.InMemoryChannel, Microsoft.ApplicationInsights">
<EndpointAddress>http://e2etests_ingestionservice_1/api/Data/PushItem</EndpointAddress>
<DeveloperMode>true</DeveloperMode>
</TelemetryChannel>

Просмотреть файл

@ -98,7 +98,7 @@
<IncludedTypes>Event</IncludedTypes>
</Add>
</TelemetryProcessors>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel">
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.InMemoryChannel, Microsoft.ApplicationInsights">
<EndpointAddress>http://e2etests_ingestionservice_1/api/Data/PushItem</EndpointAddress>
<DeveloperMode>true</DeveloperMode>
</TelemetryChannel>

Просмотреть файл

@ -12,7 +12,6 @@ namespace E2ETestAppCore20.Controllers
[Route("external/calls")]
public class ExternalCallsController : Controller
{
private const string UrlWithNonexistentHostName = "http://abcdefzzzzeeeeadadad.com";
private const string UrlTestWebApiGetCallTemplate = "http://{0}:80/api/values";
public const string UrlWhichReturns500Format = "http://{0}:80/api/values/999";
@ -49,12 +48,14 @@ namespace E2ETestAppCore20.Controllers
/// </summary>
private const string QueryToExecuteLabel = "Query Executed:";
private readonly TelemetryConfiguration telemetryConfiguration;
private string GetQueryValue(string valueKey)
{
return Request.Query[valueKey].ToString();
}
public ExternalCallsController(IOptions<AppInsightsOptions> options)
public ExternalCallsController(IOptions<AppInsightsOptions> options, TelemetryConfiguration telemetryConfiguration)
{
if (string.IsNullOrEmpty(ConnectionString))
{
@ -64,6 +65,7 @@ namespace E2ETestAppCore20.Controllers
var webApiHostName = options.Value.Webapihostname;
UrlTestWebApiGetCall = string.Format(UrlTestWebApiGetCallTemplate, webApiHostName);
UrlWhichReturns500 = string.Format(UrlWhichReturns500Format, webApiHostName);
this.telemetryConfiguration = telemetryConfiguration;
}
// GET external/calls
@ -89,7 +91,7 @@ namespace E2ETestAppCore20.Controllers
{
case "flush":
title = response = "Flushed telemetry channel";
TelemetryConfiguration.Active.TelemetryChannel.Flush();
telemetryConfiguration.TelemetryChannel.Flush();
break;
case "setsqlserverinstance":
string sqlServerInstance = GetQueryValue("server");
@ -108,8 +110,8 @@ namespace E2ETestAppCore20.Controllers
string endPoint = GetQueryValue("endpoint");
if (!string.IsNullOrEmpty(endPoint))
{
TelemetryConfiguration.Active.TelemetryChannel.EndpointAddress = string.Format(Program.EndPointAddressFormat, endPoint);
title = response = "Update Endpoint to: " + TelemetryConfiguration.Active.TelemetryChannel.EndpointAddress;
telemetryConfiguration.TelemetryChannel.EndpointAddress = string.Format(Program.EndPointAddressFormat, endPoint);
title = response = "Update Endpoint to: " + telemetryConfiguration.TelemetryChannel.EndpointAddress;
}
else
{

Просмотреть файл

@ -27,24 +27,36 @@ namespace E2ETestAppCore20
{
services.Configure<AppInsightsOptions>(Configuration);
services.AddMvc();
services.AddSingleton(provider =>
{
var options = provider.GetService<IOptions<AppInsightsOptions>>();
var telemetryConfiguration = new TelemetryConfiguration("fafa4b10-03d3-4bb0-98f4-364f0bdf5df8")
{
TelemetryChannel =
{
DeveloperMode = true,
EndpointAddress = string.Format(Program.EndPointAddressFormat, options.Value.EndPoint)
}
};
return telemetryConfiguration;
});
services.AddSingleton<DependencyTrackingTelemetryModule>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IOptions<AppInsightsOptions> options)
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory,
IOptions<AppInsightsOptions> options,
TelemetryConfiguration configuration,
DependencyTrackingTelemetryModule module)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseMvc();
var teleConfig = TelemetryConfiguration.Active;
teleConfig.TelemetryChannel.DeveloperMode = true;
// Fake endpoint.
teleConfig.TelemetryChannel.EndpointAddress = string.Format(Program.EndPointAddressFormat, options.Value.EndPoint);
teleConfig.InstrumentationKey = "fafa4b10-03d3-4bb0-98f4-364f0bdf5df8";
new DependencyTrackingTelemetryModule().Initialize(TelemetryConfiguration.Active);
module.Initialize(configuration);
}
}
}

Просмотреть файл

@ -42,9 +42,9 @@
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.FirstChanceExceptionStatisticsTelemetryModule, Microsoft.AI.WindowsServer"/>
</TelemetryModules>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel">
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.InMemoryChannel, Microsoft.ApplicationInsights">
<EndpointAddress>http://localhost:4000/v2/track</EndpointAddress>
<MaxTelemetryBufferDelay>0:00:01</MaxTelemetryBufferDelay>
<DeveloperMode>true</DeveloperMode>
</TelemetryChannel>
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>

Просмотреть файл

@ -38,9 +38,9 @@
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.Web.AspNetDiagnosticTelemetryModule, Microsoft.AI.Web"/>
</TelemetryModules>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel">
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.InMemoryChannel, Microsoft.ApplicationInsights">
<EndpointAddress>http://localhost:4001/v2/track</EndpointAddress>
<MaxTelemetryBufferDelay>0:00:01</MaxTelemetryBufferDelay>
<DeveloperMode>true</DeveloperMode>
</TelemetryChannel>
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>

Просмотреть файл

@ -15,8 +15,9 @@
<Add Type="Microsoft.ApplicationInsights.WindowsServer.BuildInfoConfigComponentVersionTelemetryInitializer, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.DeviceTelemetryInitializer, Microsoft.AI.WindowsServer"/>
</TelemetryInitializers>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel">
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.InMemoryChannel, Microsoft.ApplicationInsights">
<EndpointAddress>http://LocalHost:4002/v2/track</EndpointAddress>
<DeveloperMode>true</DeveloperMode>
</TelemetryChannel>
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>

Просмотреть файл

@ -41,9 +41,9 @@
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.Web.AspNetDiagnosticTelemetryModule, Microsoft.AI.Web"/>
</TelemetryModules>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel">
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.InMemoryChannel, Microsoft.ApplicationInsights">
<EndpointAddress>http://localhost:4004/v2/track</EndpointAddress>
<MaxTelemetryBufferDelay>0:00:01</MaxTelemetryBufferDelay>
<DeveloperMode>true</DeveloperMode>
</TelemetryChannel>
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">

Просмотреть файл

@ -37,9 +37,9 @@
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.Web.AspNetDiagnosticTelemetryModule, Microsoft.AI.Web"/>
</TelemetryModules>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel">
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.InMemoryChannel, Microsoft.ApplicationInsights">
<EndpointAddress>http://localhost:4005/v2/track</EndpointAddress>
<MaxTelemetryBufferDelay>0:00:01</MaxTelemetryBufferDelay>
<DeveloperMode>true</DeveloperMode>
</TelemetryChannel>
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>

Просмотреть файл

@ -40,9 +40,9 @@
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.Web.AspNetDiagnosticTelemetryModule, Microsoft.AI.Web"/>
</TelemetryModules>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel">
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.InMemoryChannel, Microsoft.ApplicationInsights">
<EndpointAddress>http://LocalHost:4006/v2/track</EndpointAddress>
<MaxTelemetryBufferDelay>0:00:01</MaxTelemetryBufferDelay>
<DeveloperMode>true</DeveloperMode>
</TelemetryChannel>
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>

Просмотреть файл

@ -42,7 +42,7 @@
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.FirstChanceExceptionStatisticsTelemetryModule, Microsoft.AI.WindowsServer"/>
</TelemetryModules>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel">
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.InMemoryChannel, Microsoft.ApplicationInsights">
<EndpointAddress>http://LocalHost:4017/v2/track</EndpointAddress>
<DeveloperMode>true</DeveloperMode>
</TelemetryChannel>

Просмотреть файл

@ -42,10 +42,9 @@
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.FirstChanceExceptionStatisticsTelemetryModule, Microsoft.AI.WindowsServer"/>
</TelemetryModules>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel">
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.InMemoryChannel, Microsoft.ApplicationInsights">
<EndpointAddress>http://LocalHost:4008/v2/track</EndpointAddress>
<DeveloperMode>false</DeveloperMode>
<MaxTelemetryBufferDelay>0:00:01</MaxTelemetryBufferDelay>
<DeveloperMode>true</DeveloperMode>
</TelemetryChannel>
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>