forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] gRPC client tests (dotnet#73060)
* WIP: add gRPC tests * Fix AOT and trimming * WIP * Implement IncludeNetworkSecurityConfig * Use IncludeNetworkSecurityConfig * Fix gRPC test * Avoid git checkout * Remove unnecessary code * WIP: start working on CI configuration * Remove WinHttpHandler * Fix problem with SSL * Change server host * Setup CI (#1) * Get Docker container building & exported via test build * Changes * Add missing pfx certificate * changes * cleanup Co-authored-by: Simon Rozsival <[email protected]> * Use tls * Update yml * Revert changes to the mono Android sample app * Bump android image version * Bump image version * Enable TLS * Remove hardcoded package versions * Update package versions * Update package versions * Rename pipeline * Move interop tests website dependencies versions to Versions.props * Add cred scan supression for the interop test server private key * Fix licenses * Remove dependencies * Fix path to Versions.props * Remove unnecessary dependency version * Fix building docker image * Change pfx password Co-authored-by: Jo Shields <[email protected]>
- Loading branch information
1 parent
79e3cd0
commit 7a4b0af
Showing
36 changed files
with
2,185 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# We run this pipeline on a schedule and also developers can run it | ||
# via /azp run command on PRs. | ||
# | ||
# Setting batch to true, triggers one build at a time. | ||
# if there is a push while a build in progress, it will wait, | ||
# until the running build finishes, and produce a build with all the changes | ||
# that happened during the last build. | ||
trigger: none | ||
|
||
schedules: | ||
- cron: "0 9,21 * * *" # run at 9:00 and 21:00 (UTC) which is 1:00 and 13:00 (PST). | ||
displayName: grpc-dotnet Android client test schedule | ||
branches: | ||
include: | ||
- main | ||
always: true | ||
|
||
variables: | ||
- template: /eng/pipelines/common/variables.yml | ||
|
||
jobs: | ||
|
||
# | ||
# Android emulators | ||
# Build the whole product using Mono and run libraries tests | ||
# | ||
- template: /eng/pipelines/common/platform-matrix.yml | ||
parameters: | ||
jobTemplate: /eng/pipelines/common/global-build-job.yml | ||
helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml | ||
buildConfig: Release | ||
runtimeFlavor: mono | ||
platforms: | ||
- Android_x64 | ||
jobParameters: | ||
testGroup: innerloop | ||
nameSuffix: AllSubsets_Mono_gRPC | ||
buildArgs: -s mono+libs+host+packs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:RunGrpcTestsOnly=true /p:BuildGrpcServerDockerImage=true | ||
timeoutInMinutes: 180 | ||
# extra steps, run tests | ||
extraStepsTemplate: /eng/pipelines/libraries/helix.yml | ||
extraStepsParameters: | ||
creator: dotnet-bot | ||
extraHelixArguments: /p:RunGrpcTestsOnly=true /p:BuildGrpcServerDockerImage=true | ||
testRunNamePrefixSuffix: Mono_$(_BuildConfig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...sts/FunctionalTests/Android/Device_Emulator/gRPC/Android.Device_Emulator.gRPC.Test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<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 SYSLIB0039 because the tests intentionally use TLS 1.0 and 1.1 --> | ||
<NoWarn>CS8981;SYSLIB0039</NoWarn> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<IncludeNetworkSecurityConfig>true</IncludeNetworkSecurityConfig> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
|
||
<None Include="$(MSBuildProjectDirectory)\res\**\*"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<!-- 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="$(MSBuildProjectDirectory)\grpc-dotnet\testassets\Shared\*.cs" /> | ||
<Compile Include="$(MSBuildProjectDirectory)\grpc-dotnet\test\Shared\HttpEventSourceListener.cs" /> | ||
|
||
<Protobuf | ||
Include="$(MSBuildProjectDirectory)\grpc-dotnet\testassets\Proto\grpc\testing\*.proto" | ||
ProtoRoot="$(MSBuildProjectDirectory)\grpc-dotnet\testassets\Proto\grpc\testing\" | ||
GrpcServices="Client" /> | ||
|
||
<PackageReference Include="Google.Protobuf" Version="$(GoogleProtobufVersion)" /> | ||
<PackageReference Include="Grpc.Auth" Version="$(GrpcAuthVersion)" /> | ||
<PackageReference Include="Grpc.Core" Version="$(GrpcCoreVersion)" PrivateAssets="All" /> | ||
<PackageReference Include="Grpc.Net.Client" Version="$(GrpcDotnetClientVersion)" /> | ||
<PackageReference Include="Grpc.Tools" Version="$(GrpcToolsVersion)" PrivateAssets="All" /> | ||
</ItemGroup> | ||
|
||
<Target Name="BuildServerDockerImage" AfterTargets="Build" Condition="'$(BuildGrpcServerDockerImage)' == 'true'"> | ||
<Exec Command="cp $(RepoRoot)eng/Versions.props grpc-dotnet/testassets/InteropTestsWebsite/" /> | ||
<Exec Command="docker build -t grpc-server:latest grpc-dotnet/testassets/" /> | ||
<Exec Command="mkdir -p $(ArtifactsObjDir)/grpcserver/docker/" /> | ||
<Exec Command="docker save -o $(ArtifactsObjDir)/grpcserver/docker/grpcserver.tar grpc-server:latest" /> | ||
</Target> | ||
</Project> |
91 changes: 91 additions & 0 deletions
91
src/tests/FunctionalTests/Android/Device_Emulator/gRPC/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
// The code of the tests is cloned from https://github.com/grpc/grpc-dotnet | ||
using Grpc.Shared.TestAssets; | ||
|
||
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 = "10.0.2.2", | ||
ServerPort = 50052, | ||
UseTls = true, | ||
}, | ||
}; | ||
|
||
int failedTests = 0; | ||
|
||
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} | ||
UseHttp3: {options.UseHttp3} | ||
--- | ||
"""); | ||
|
||
foreach (var testName in InteropClient.TestNames) | ||
{ | ||
if (skippedTests.Contains(testName)) | ||
{ | ||
Log(testName, "SKIPPED"); | ||
continue; | ||
} | ||
|
||
options.TestCase = testName; | ||
var client = new InteropClientWrapper(options); | ||
|
||
try | ||
{ | ||
Log(testName, "STARTED"); | ||
await client.Run(); | ||
Log(testName, "PASSED"); | ||
} catch (Exception e) { | ||
Log(testName, "FAILED"); | ||
Console.Error.WriteLine(e); | ||
failedTests++; | ||
} | ||
} | ||
} | ||
|
||
return 42 + failedTests; | ||
|
||
void Log(string testName, string status) | ||
=> Console.WriteLine($"TestCase: {testName} ... {status}"); | ||
|
||
sealed class InteropClientWrapper | ||
{ | ||
private readonly InteropClient _interopClient; | ||
|
||
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "Grpc.Testing.TestService.TestServiceClient", "Android.Device_Emulator.gRPC.Test")] | ||
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "Grpc.Testing.UnimplementedService.UnimplementedServiceClient", "Android.Device_Emulator.gRPC.Test")] | ||
public InteropClientWrapper(ClientOptions options) | ||
{ | ||
_interopClient = new InteropClient(options); | ||
} | ||
|
||
public Task Run() | ||
=> _interopClient.Run(); | ||
} |
2 changes: 2 additions & 0 deletions
2
src/tests/FunctionalTests/Android/Device_Emulator/gRPC/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
res - Android resource folder containing self-signed certificates and Android network configuration | ||
dotnet-grpc - copied from https://github.com/grpc/grpc-dotnet |
Oops, something went wrong.