Skip to content

Commit

Permalink
Merge pull request #554 from Azure/integration-tests
Browse files Browse the repository at this point in the history
Change integration tests + Git searching
  • Loading branch information
waelkdouh authored May 24, 2024
2 parents 0e83e7f + b2eccb8 commit b280c0c
Show file tree
Hide file tree
Showing 38 changed files with 4,855 additions and 1,952 deletions.
15 changes: 15 additions & 0 deletions tools/code/aspire/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Aspire.Hosting;
using Projects;

internal static class Program
{
private static void Main(string[] args)
{
var builder = DistributedApplication.CreateBuilder(args);

builder.AddProject<integration_tests>("integration-tests");
//.WithEnvironment("CSCHECK_SEED", "0000KOIPe036");

builder.Build().Run();
}
}
31 changes: 31 additions & 0 deletions tools/code/aspire/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17016;http://localhost:15029",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21043",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22139",
"ASPIRE_ALLOW_UNSECURED_TRANSPORT": "true"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15029",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19296",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20230",
"ASPIRE_ALLOW_UNSECURED_TRANSPORT": "true"
}
}
}
}
8 changes: 8 additions & 0 deletions tools/code/aspire/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
19 changes: 19 additions & 0 deletions tools/code/aspire/aspire.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>6ce9dc18-ea0d-4d82-8f1a-e63877f35b88</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\integration.tests\integration.tests.csproj" />
</ItemGroup>

</Project>
16 changes: 11 additions & 5 deletions tools/code/code.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "publisher", "publisher\publ
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "common.tests", "common.tests\common.tests.csproj", "{D1ED4FC5-8C52-4380-8520-BC46F475A4F8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "integration.tests", "integration.tests\integration.tests.csproj", "{76339A55-86A2-4CBE-991B-515DED712804}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "integration.tests", "integration.tests\integration.tests.csproj", "{05923D65-3595-445A-8EB3-5ECC1F99A727}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aspire", "aspire\aspire.csproj", "{C0AD9089-77B8-4E2F-ADD3-1F0846B8D370}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -35,10 +37,14 @@ Global
{D1ED4FC5-8C52-4380-8520-BC46F475A4F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1ED4FC5-8C52-4380-8520-BC46F475A4F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1ED4FC5-8C52-4380-8520-BC46F475A4F8}.Release|Any CPU.Build.0 = Release|Any CPU
{76339A55-86A2-4CBE-991B-515DED712804}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76339A55-86A2-4CBE-991B-515DED712804}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76339A55-86A2-4CBE-991B-515DED712804}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76339A55-86A2-4CBE-991B-515DED712804}.Release|Any CPU.Build.0 = Release|Any CPU
{05923D65-3595-445A-8EB3-5ECC1F99A727}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{05923D65-3595-445A-8EB3-5ECC1F99A727}.Debug|Any CPU.Build.0 = Debug|Any CPU
{05923D65-3595-445A-8EB3-5ECC1F99A727}.Release|Any CPU.ActiveCfg = Release|Any CPU
{05923D65-3595-445A-8EB3-5ECC1F99A727}.Release|Any CPU.Build.0 = Release|Any CPU
{C0AD9089-77B8-4E2F-ADD3-1F0846B8D370}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0AD9089-77B8-4E2F-ADD3-1F0846B8D370}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0AD9089-77B8-4E2F-ADD3-1F0846B8D370}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0AD9089-77B8-4E2F-ADD3-1F0846B8D370}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 3 additions & 2 deletions tools/code/common.tests/common.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisLevel>latest-all</AnalysisLevel>
<AnalysisLevel>8-all</AnalysisLevel>
<WarningsNotAsErrors>CA1034,CA1062,CA1724,CA2007,CA1848,CA1716</WarningsNotAsErrors>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus" Version="35.5.1" />
<PackageReference Include="CsCheck" Version="3.2.0" />
<PackageReference Include="CsCheck" Version="3.2.2" />
</ItemGroup>

<ItemGroup>
Expand Down
42 changes: 42 additions & 0 deletions tools/code/common/OpenTelemetry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OpenTelemetry.Instrumentation.Http;
using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
using System.Diagnostics;

namespace common;

public static class OpenTelemetryServices
{
public static void Configure(IServiceCollection services)
{
var sourceName = services.BuildServiceProvider().GetService<ActivitySource>()?.Name ?? "ApiOps.*";

services.AddOpenTelemetry()
.WithMetrics(metrics => metrics.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation()
.AddMeter("Azure.*"))
.WithTracing(tracing => tracing.AddHttpClientInstrumentation(ConfigureHttpClientTraceInstrumentationOptions)
.AddSource("Azure.*")
.AddSource(sourceName)
.SetSampler<AlwaysOnSampler>());

var configuration = services.BuildServiceProvider().GetRequiredService<IConfiguration>();
configuration.TryGetValue("OTEL_EXPORTER_OTLP_ENDPOINT")
.Iter(_ =>
{
services.AddLogging(builder => builder.AddOpenTelemetry());
services.Configure<OpenTelemetryLoggerOptions>(logging => logging.AddOtlpExporter())
.ConfigureOpenTelemetryMeterProvider(metrics => metrics.AddOtlpExporter())
.ConfigureOpenTelemetryTracerProvider(tracing => tracing.AddOtlpExporter());
});
}

private static void ConfigureHttpClientTraceInstrumentationOptions(HttpClientTraceInstrumentationOptions options)
{
options.FilterHttpRequestMessage = (_) => Activity.Current?.Parent?.Source?.Name != "Azure.Core.Http";
}
}
13 changes: 9 additions & 4 deletions tools/code/common/common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisLevel>latest-all</AnalysisLevel>
<AnalysisLevel>8-all</AnalysisLevel>
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
<WarningsNotAsErrors>CA1034,CA1062,CA1724,CA2007,CA1848</WarningsNotAsErrors>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -16,12 +17,16 @@
<PackageReference Include="LanguageExt.Core" Version="4.4.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.4.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.5.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.5.1" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.5.2" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.6.14" />
<PackageReference Include="Nito.Comparers" Version="6.2.2" />
<PackageReference Include="Polly" Version="8.3.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.1" />
<PackageReference Include="Polly" Version="8.4.0" />
<PackageReference Include="System.Interactive.Async" Version="6.0.1" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="Yaml2JsonNode" Version="2.1.0" />
Expand Down
6 changes: 6 additions & 0 deletions tools/code/extractor/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.JsonWebTokens;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;

Expand All @@ -20,6 +21,7 @@ internal static class CommonServices
{
public static void Configure(IServiceCollection services)
{
services.AddSingleton(GetActivitySource);
services.AddSingleton(GetAzureEnvironment);
services.AddSingleton(GetTokenCredential);
services.AddSingleton(GetHttpPipeline);
Expand All @@ -28,8 +30,12 @@ public static void Configure(IServiceCollection services)
services.AddSingleton(GetManagementServiceDirectory);
services.AddSingleton(GetConfigurationJson);
services.AddSingleton<ShouldExtractFactory>();
OpenTelemetryServices.Configure(services);
}

private static ActivitySource GetActivitySource(IServiceProvider provider) =>
new("ApiOps.Extractor");

private static AzureEnvironment GetAzureEnvironment(IServiceProvider provider)
{
var configuration = provider.GetRequiredService<IConfiguration>();
Expand Down
3 changes: 2 additions & 1 deletion tools/code/extractor/extractor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisLevel>latest-all</AnalysisLevel>
<AnalysisLevel>8-all</AnalysisLevel>
<WarningsNotAsErrors>CA1708,CA1724,CA1812,CA1848,CA2007,CA1034,CA1062</WarningsNotAsErrors>
<UserSecretsId>6ce9dc18-ea0d-4d82-8f1a-e63877f35b88</UserSecretsId>
<OutputType>Exe</OutputType>
Expand Down
Loading

0 comments on commit b280c0c

Please sign in to comment.