-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[Android] gRPC client tests #73060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[Android] gRPC client tests #73060
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
d2dbd2b
WIP: add gRPC tests
simonrozsival ea8b368
Merge branch 'main' of https://github.com/dotnet/runtime into android…
simonrozsival 1dcf0e8
Fix AOT and trimming
simonrozsival 2941f15
WIP
simonrozsival 66b2939
Implement IncludeNetworkSecurityConfig
simonrozsival 6ef8d85
Use IncludeNetworkSecurityConfig
simonrozsival 5740a9b
Fix gRPC test
simonrozsival b99fc44
Avoid git checkout
simonrozsival be51a78
Remove unnecessary code
simonrozsival 0d4837c
Merge branch 'main' of https://github.com/dotnet/runtime into android…
simonrozsival 28629ae
WIP: start working on CI configuration
simonrozsival 85eb854
Remove WinHttpHandler
simonrozsival b4b2d09
Fix problem with SSL
simonrozsival 9dac1c4
Change server host
simonrozsival 3a8908f
Setup CI (#1)
directhex 3276d50
Use tls
simonrozsival b7b40e7
Update yml
simonrozsival 44bd21c
Revert changes to the mono Android sample app
simonrozsival 805790e
Merge branch 'main' of github.com:dotnet/runtime into simonrozsival/a…
simonrozsival 6e7f96e
Bump android image version
simonrozsival 41d80a2
Bump image version
simonrozsival 124ed66
Enable TLS
simonrozsival 39f4009
Remove hardcoded package versions
simonrozsival a11e4a8
Update package versions
simonrozsival 764f745
Update package versions
simonrozsival e996d02
Rename pipeline
simonrozsival 09c67c3
Move interop tests website dependencies versions to Versions.props
simonrozsival c1bb0dd
Add cred scan supression for the interop test server private key
simonrozsival b9a02d8
Fix licenses
simonrozsival 6691bc0
Remove dependencies
simonrozsival 0722991
Merge branch 'main' into simonrozsival/android-grpc-client-tests
simonrozsival 32034ad
Fix path to Versions.props
simonrozsival 785ba5e
Merge branch 'simonrozsival/android-grpc-client-tests' of github.com:…
simonrozsival d2ac3d8
Remove unnecessary dependency version
simonrozsival 3bb36bf
Fix building docker image
simonrozsival 2cf9df9
Change pfx password
simonrozsival File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.