Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d2dbd2b
WIP: add gRPC tests
simonrozsival Jun 8, 2022
ea8b368
Merge branch 'main' of https://github.com/dotnet/runtime into android…
simonrozsival Jun 9, 2022
1dcf0e8
Fix AOT and trimming
simonrozsival Jun 9, 2022
2941f15
WIP
simonrozsival Jun 23, 2022
66b2939
Implement IncludeNetworkSecurityConfig
simonrozsival Jun 27, 2022
6ef8d85
Use IncludeNetworkSecurityConfig
simonrozsival Jun 27, 2022
5740a9b
Fix gRPC test
simonrozsival Jun 27, 2022
b99fc44
Avoid git checkout
simonrozsival Jun 27, 2022
be51a78
Remove unnecessary code
simonrozsival Jun 27, 2022
0d4837c
Merge branch 'main' of https://github.com/dotnet/runtime into android…
simonrozsival Jul 20, 2022
28629ae
WIP: start working on CI configuration
simonrozsival Jul 20, 2022
85eb854
Remove WinHttpHandler
simonrozsival Jul 29, 2022
b4b2d09
Fix problem with SSL
simonrozsival Jul 29, 2022
9dac1c4
Change server host
simonrozsival Jul 29, 2022
3a8908f
Setup CI (#1)
directhex Jul 29, 2022
3276d50
Use tls
simonrozsival Jul 29, 2022
b7b40e7
Update yml
simonrozsival Jul 29, 2022
44bd21c
Revert changes to the mono Android sample app
simonrozsival Jul 29, 2022
805790e
Merge branch 'main' of github.com:dotnet/runtime into simonrozsival/a…
simonrozsival Aug 9, 2022
6e7f96e
Bump android image version
simonrozsival Aug 9, 2022
41d80a2
Bump image version
simonrozsival Aug 10, 2022
124ed66
Enable TLS
simonrozsival Aug 10, 2022
39f4009
Remove hardcoded package versions
simonrozsival Aug 12, 2022
a11e4a8
Update package versions
simonrozsival Aug 12, 2022
764f745
Update package versions
simonrozsival Aug 12, 2022
e996d02
Rename pipeline
simonrozsival Aug 24, 2022
09c67c3
Move interop tests website dependencies versions to Versions.props
simonrozsival Aug 24, 2022
c1bb0dd
Add cred scan supression for the interop test server private key
simonrozsival Aug 24, 2022
b9a02d8
Fix licenses
simonrozsival Aug 24, 2022
6691bc0
Remove dependencies
simonrozsival Aug 24, 2022
0722991
Merge branch 'main' into simonrozsival/android-grpc-client-tests
simonrozsival Aug 24, 2022
32034ad
Fix path to Versions.props
simonrozsival Aug 24, 2022
785ba5e
Merge branch 'simonrozsival/android-grpc-client-tests' of github.com:…
simonrozsival Aug 24, 2022
d2ac3d8
Remove unnecessary dependency version
simonrozsival Aug 24, 2022
3bb36bf
Fix building docker image
simonrozsival Aug 24, 2022
2cf9df9
Change pfx password
simonrozsival Aug 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
WIP: add gRPC tests
  • Loading branch information
simonrozsival committed Jun 8, 2022
commit d2dbd2b35164ef161ba3c40e53dcac35c175d692
3 changes: 3 additions & 0 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@
<!-- Crashes on CI (possibly flakey) -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Private.Xml/tests/Misc/System.Xml.Misc.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Dynamic.Runtime/tests/System.Dynamic.Runtime.Tests.csproj"/>

<!-- gRPC tests should be run only manually -->
<ProjectExclusions Include="$(RepoRoot)\src\tests\FunctionalTests\Android\Device_Emulator\gRPC\Android.Device_Emulator.gRPC.Test.csproj" />
</ItemGroup>

<ItemGroup Condition="('$(TargetOS)' == 'Android' or '$(TargetsLinuxBionic)' == 'true') and '$(TargetArchitecture)' == 'arm64' and '$(RunDisabledAndroidTests)' != 'true'">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
grpc-dotnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>

<TestRuntime>true</TestRuntime>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<MainLibraryFileName>Android.Device_Emulator.gRPC.Test.dll</MainLibraryFileName>
<ExpectedExitCode>42</ExpectedExitCode>

<MonoForceInterpreter>false</MonoForceInterpreter>
<RunAOTCompilation>true</RunAOTCompilation>
<ForceAOT>true</ForceAOT>
<AOTWithLibraryFiles>true</AOTWithLibraryFiles>

<PublishTrimmed>true</PublishTrimmed>
<EnableAggressiveTrimming>true</EnableAggressiveTrimming>

<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- Disable CS8981 because the generated code from the protobuf files contains classes with lowercase names -->
<!-- Disable IL2026 because of trim analysis errors related to XML serialization -->
<!-- Disable IL2035 because of HttpClientHandler.AnyMobile.InvokeNativeHandler.cs referencing Mono.Android in DynamicDependencyAttribute which is fine -->
<!-- Disable IL2087 because of a trim analysis error in Grpc.Shared.TestAssets.InteropClient.CreateClient<TClient>(IChannelWrapper) -->
<!-- Disable IL2104 because of trim warnings in the following assemblies: Google.Apis.Core.dll, Google.Apis.dll, Google.Protobuf.dll, Microsoft.Extensions.Configuration.Binder.dll, Microsoft.Extensions.DependencyInjection.Abstractions.dll, Microsoft.Extensions.DependencyInjection.dll, Microsoft.Extensions.Logging.Configuration.dll, Microsoft.Extensions.Logging.dll, Microsoft.Extensions.Options.dll -->
<!-- Disable SYSLIB0039 because the tests intentionally use TLS 1.0 and 1.1 -->
<!-- <NoWarn>CS8981;IL2026;IL2035;IL2104;SYSLIB0039</NoWarn> -->
<NoWarn>CS8981;SYSLIB0039</NoWarn>
<!-- The destination for the code of the grpc/grpc-dotnet repo -->
<GrpcDotnetBasePath>$(MSBuildProjectDirectory)\grpc-dotnet</GrpcDotnetBasePath>
<!-- We pretend to be Blazor WASM so that we don't have to modify the code of grpc-dotnet -->
<!-- The pieces of code that Android needs to skips are the same as WASM -->
<DefineConstants>BLAZOR_WASM</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>

<Import Project="$(GrpcDotnetBasePath)\build\dependencies.props"/>

<!-- Based on grpc-dotnet's testassets/InteropTestsClient/InteropTestsClient.csproj -->
<ItemGroup>
<!-- Required for QUIC & HTTP/3 in .NET 6 - https://github.com/dotnet/runtime/pull/55332 -->
<RuntimeHostConfigurationOption Include="System.Net.SocketsHttpHandler.Http3Support" Value="true" />

<Compile Include="$(GrpcDotnetBasePath)\testassets\Shared\Assert.cs" Link="Assert.cs" />
<Compile Include="$(GrpcDotnetBasePath)\testassets\Shared\AsyncStreamExtensions.cs" Link="AsyncStreamExtensions.cs" />
<Compile Include="$(GrpcDotnetBasePath)\testassets\Shared\ExceptionAssert.cs" Link="ExceptionAssert.cs" />
<Compile Include="$(GrpcDotnetBasePath)\testassets\Shared\IChannelWrapper.cs" Link="IChannelWrapper.cs" />
<Compile Include="$(GrpcDotnetBasePath)\testassets\Shared\InteropClient.cs" Link="InteropClient.cs" />
<Compile Include="$(GrpcDotnetBasePath)\testassets\Shared\TestCredentials.cs" Link="TestCredentials.cs" />
<Compile Include="$(GrpcDotnetBasePath)\test\Shared\HttpEventSourceListener.cs" Link="HttpEventSourceListener.cs" />

<Protobuf Include="$(GrpcDotnetBasePath)\testassets\Proto\grpc\testing\test.proto" GrpcServices="Client" Link="Protos\test.proto" ProtoRoot="$(GrpcDotnetBasePath)\testassets\Proto\grpc\testing\" />
<Protobuf Include="$(GrpcDotnetBasePath)\testassets\Proto\grpc\testing\empty.proto" GrpcServices="None" Link="Protos\empty.proto" ProtoRoot="$(GrpcDotnetBasePath)\testassets\Proto\grpc\testing\" />
<Protobuf Include="$(GrpcDotnetBasePath)\testassets\Proto\grpc\testing\messages.proto" GrpcServices="None" Link="Protos\messages.proto" ProtoRoot="$(GrpcDotnetBasePath)\testassets\Proto\grpc\testing\" />

<None Include="$(GrpcDotnetBasePath)\testassets\Certs\InteropTests\*.*" LinkBase="Certs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

<PackageReference Include="Grpc.Auth" Version="$(GrpcPackageVersion)" />
<PackageReference Include="Grpc.Net.Client" Version="$(GrpcPackageVersion)" />
<PackageReference Include="Grpc.Net.Client.Web" Version="$(GrpcPackageVersion)" />

<PackageReference Include="Google.Protobuf" Version="$(GoogleProtobufPackageVersion)" />
<PackageReference Include="Grpc.Core" Version="$(GrpcPackageVersion)" PrivateAssets="All" />
<PackageReference Include="Grpc.Tools" Version="$(GrpcPackageVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsPackageVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
<PackageReference Include="System.CommandLine" Version="$(SystemCommandLinePackageVersion)" />
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="$(SystemNetHttpWinHttpHandlerPackageVersion)" />
</ItemGroup>

<!-- <Target Name="_GitCloneGrpcDotnet" BeforeTargets="Restore">
<RemoveDir Directories="$(GrpcDotnetBasePath)" />
<Exec Command="git clone depth 1 https://github.com/grpc/grpc-dotnet.git $(GrpcDotnetBasePath)"
WorkingDirectory="$(MSBuildProjectDirectory )"
IgnoreStandardErrorWarningFormat="true" />
</Target> -->
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
78 changes: 78 additions & 0 deletions src/tests/FunctionalTests/Android/Device_Emulator/gRPC/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

// The code of the tests is cloned from https://github.com/grpc/grpc-dotnet
using Grpc.Shared.TestAssets;

int failedTests = 0;
var skippedTests = new[]
{
"compute_engine_creds",
"jwt_token_creds",
"oauth2_auth_token",
"per_rpc_creds",
"client_compressed_streaming", // flaky test
};

var configurations = new[]
{
new ClientOptions
{
ServerHost = "grpc.rozsival.com", // TODO
ServerPort = 443,
UseTls = true,
},
};

// var services = new ServiceCollection();
// services.AddLogging(configure =>
// {
// configure.SetMinimumLevel(LogLevel.Trace);
// configure.AddConsole(loggerOptions => loggerOptions.IncludeScopes = true);
// });

// using var serviceProvider = services.BuildServiceProvider();
// var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
var loggerFactory = Microsoft.Extensions.Logging.Abstractions.NullLoggerFactory.Instance;

foreach (var options in configurations) {
Console.WriteLine($$"""
gRPC client options
-------------------
ClientType: {options.ClientType}
ServerHost: {options.ServerHost}
ServerHostOverride: {options.ServerHostOverride}
ServerPort: {options.ServerPort}
UseTls: {options.UseTls}
UseTestCa: {options.UseTestCa}
DefaultServiceAccount: {options.DefaultServiceAccount}
OAuthScope: {options.OAuthScope}
ServiceAccountKeyFile: {options.ServiceAccountKeyFile}
GrpcWebMode: {options.GrpcWebMode}
UseWinHttp: {options.UseWinHttp}
UseHttp3: {options.UseHttp3}
""");

foreach (var testName in InteropClient.TestNames) {
if (skippedTests.Contains(testName)) {
Console.WriteLine($"TestCase: {testName} ... FAILED");
continue;
}

options.TestCase = testName;
var client = new InteropClient(options, loggerFactory);

try {
Console.WriteLine($"TestCase: {testName} ... STARTED");
await client.Run();
Console.WriteLine($"TestCase: {testName} ... PASSED");
} catch (Exception e) {
Console.WriteLine($"TestCase: {testName} ... FAILED");
Console.Error.WriteLine(e);
failedTests++;
}
}
}

return 42 + failedTests;