-
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 1 commit
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
WIP: start working on CI configuration
- Loading branch information
commit 28629aec216504b7fff5f1861d48c1d62d44dd8a
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # TODO file name == pipeline name (/azp run android-grpc-client-tests ?) | ||
| # | ||
| # TODO description + instructions | ||
| # | ||
| # 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 # the test is independent of the changes to the main branch since the client code is in another repo | ||
|
|
||
| # TODO do we need those variables? | ||
| # variables: | ||
| # - template: /eng/pipelines/common/variables.yml | ||
|
|
||
| jobs: | ||
|
|
||
| # TODO we basically need to: | ||
| # | ||
| # 1) cd src/tests/src/tests/FunctionalTests/Android/Device_Emulator/gRPC/grpc-dotnet | ||
| # 2) docker build -t grpc-server -f testassets/InteropTestsWebsite . | ||
| # 3) docker run --name grpc-server -d -p 50052:50052 -p 80:80 grpc-server | ||
| # 4) adb reverse tcp:50052 tcp:50052; adb reverse tcp:80 tcp:80 | ||
| # 5) dotnet build -t:Run -p:Configuration=Release ../Android.Device_Emulator.gRPC.Test.csproj | ||
| # 6) ... expect the result to be 42 | ||
| # 7) docker stop grpc-server (if we care) | ||
| # | ||
| # so... 1-4) are helix pre-scripts, 5) is the main command, 7) is helix post-script? | ||
|
|
||
| # | ||
| # Android devices | ||
| # Build the whole product using Mono and run libraries tests | ||
| # | ||
| - template: /eng/pipelines/common/platform-matrix.yml | ||
| parameters: | ||
| # TODO which job template? | ||
| # jobTemplate: /eng/pipelines/common/global-build-job.yml | ||
| helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml | ||
| buildConfig: Release | ||
| runtimeFlavor: mono | ||
| platforms: | ||
| # - Android_arm TODO do we need/want it? | ||
| - Android_arm64 | ||
| jobParameters: | ||
| testGroup: innerloop | ||
| nameSuffix: AllSubsets_Mono # TODO ??? | ||
| # we don't want to build the whole .net | ||
| # buildArgs: -s mono+libs+host+packs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true $(_runSmokeTestsOnlyArg) /p:EnableAdditionalTimezoneChecks=true | ||
| timeoutInMinutes: 180 | ||
| # extra steps, run tests | ||
| extraStepsTemplate: /eng/pipelines/libraries/helix.yml | ||
| extraStepsParameters: | ||
| creator: dotnet-bot | ||
| testRunNamePrefixSuffix: Mono_$(_BuildConfig) | ||
|
|
||
| # TODO Android_x64, Android_x86 - do those queues have docker? | ||
14 changes: 14 additions & 0 deletions
14
...lTests/Android/Device_Emulator/gRPC/grpc-dotnet/testassets/InteropTestsWebsite/Dockerfile
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,14 @@ | ||
| FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env | ||
| WORKDIR /app | ||
|
|
||
| # Copy everything | ||
| COPY . ./ | ||
| RUN dotnet --info | ||
| RUN dotnet restore testassets/InteropTestsWebsite | ||
| RUN dotnet publish testassets/InteropTestsWebsite --framework net6.0 -c Release -o out -p:LatestFramework=true | ||
|
|
||
| # Build runtime image | ||
| FROM mcr.microsoft.com/dotnet/aspnet:6.0 | ||
| WORKDIR /app | ||
| COPY --from=build-env /app/out . | ||
| ENTRYPOINT ["dotnet", "InteropTestsWebsite.dll", "--port_http1", "80"] |
29 changes: 29 additions & 0 deletions
29
...evice_Emulator/gRPC/grpc-dotnet/testassets/InteropTestsWebsite/InteropTestsWebsite.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,29 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net6.0</TargetFramework> | ||
| <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> | ||
| <GenerateUserSecretsAttribute>false</GenerateUserSecretsAttribute> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
|
|
||
| <!-- 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> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="..\Shared\AsyncStreamExtensions.cs" Link="AsyncStreamExtensions.cs" /> | ||
|
|
||
| <Protobuf Include="..\Proto\grpc\testing\test.proto" GrpcServices="Server" Link="Protos\test.proto" /> | ||
| <Protobuf Include="..\Proto\grpc\testing\empty.proto" GrpcServices="None" Link="Protos\empty.proto" /> | ||
| <Protobuf Include="..\Proto\grpc\testing\messages.proto" GrpcServices="None" Link="Protos\messages.proto" /> | ||
|
|
||
| <None Include="..\Certs\InteropTests\*.*" LinkBase="Certs"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </None> | ||
|
|
||
| <PackageReference Include="Grpc.AspNetCore" Version="2.46.0" /> | ||
| <PackageReference Include="Grpc.AspNetCore.Web" Version="2.46.0" /> | ||
simonrozsival marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
79 changes: 79 additions & 0 deletions
79
...lTests/Android/Device_Emulator/gRPC/grpc-dotnet/testassets/InteropTestsWebsite/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,79 @@ | ||
| #region Copyright notice and license | ||
|
|
||
| // Copyright 2019 The gRPC Authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #endregion | ||
|
|
||
| using Microsoft.AspNetCore.Server.Kestrel.Core; | ||
|
|
||
| namespace InteropTestsWebsite | ||
| { | ||
| public class Program | ||
| { | ||
| private const LogLevel MinimumLogLevel = LogLevel.Debug; | ||
|
|
||
| public static void Main(string[] args) | ||
| { | ||
| CreateHostBuilder(args).Build().Run(); | ||
| } | ||
|
|
||
| public static IHostBuilder CreateHostBuilder(string[] args) => | ||
| Host.CreateDefaultBuilder(args) | ||
| .ConfigureServices(services => | ||
| { | ||
| services.AddLogging(builder => builder.SetMinimumLevel(MinimumLogLevel)); | ||
| }) | ||
| .ConfigureWebHostDefaults(webBuilder => | ||
| { | ||
| webBuilder.ConfigureKestrel((context, options) => | ||
| { | ||
| // Support --port and --use_tls cmdline arguments normally supported | ||
| // by gRPC interop servers. | ||
| var http2Port = context.Configuration.GetValue<int>("port", 50052); | ||
| var http1Port = context.Configuration.GetValue<int>("port_http1", -1); | ||
| var http3Port = context.Configuration.GetValue<int>("port_http3", -1); | ||
| var useTls = context.Configuration.GetValue<bool>("use_tls", false); | ||
|
|
||
| options.Limits.MinRequestBodyDataRate = null; | ||
| options.ListenAnyIP(http2Port, o => ConfigureEndpoint(o, useTls, HttpProtocols.Http2)); | ||
| if (http1Port != -1) | ||
| { | ||
| options.ListenAnyIP(http1Port, o => ConfigureEndpoint(o, useTls, HttpProtocols.Http1)); | ||
| } | ||
| if (http3Port != -1) | ||
| { | ||
| #pragma warning disable CA2252 // This API requires opting into preview features | ||
| options.ListenAnyIP(http3Port, o => ConfigureEndpoint(o, useTls, HttpProtocols.Http3)); | ||
| #pragma warning restore CA2252 // This API requires opting into preview features | ||
| } | ||
|
|
||
| void ConfigureEndpoint(ListenOptions listenOptions, bool useTls, HttpProtocols httpProtocols) | ||
| { | ||
| Console.WriteLine($"Enabling connection encryption: {useTls}"); | ||
|
|
||
| if (useTls) | ||
| { | ||
| var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location); | ||
| var certPath = Path.Combine(basePath!, "Certs", "server1.pfx"); | ||
|
|
||
| listenOptions.UseHttps(certPath, "1111"); | ||
| } | ||
| listenOptions.Protocols = httpProtocols; | ||
| } | ||
| }); | ||
| webBuilder.UseStartup<Startup>(); | ||
| }); | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
...droid/Device_Emulator/gRPC/grpc-dotnet/testassets/InteropTestsWebsite/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,27 @@ | ||
| Running Grpc.Core interop client against Grpc.AspNetCore.Server interop server. | ||
| Context: https://github.com/grpc/grpc/blob/master/doc/interop-test-descriptions.md | ||
|
|
||
| ## Start the InteropTestsWebsite | ||
|
|
||
| ``` | ||
| # From this directory | ||
| $ dotnet run | ||
| Now listening on: http://localhost:50052 | ||
| ``` | ||
|
|
||
| ## Build gRPC C# as a developer: | ||
| Follow https://github.com/grpc/grpc/tree/master/src/csharp | ||
| ``` | ||
| python tools/run_tests/run_tests.py -l csharp -c dbg --build_only | ||
| ``` | ||
|
|
||
| ## Running the interop client | ||
|
|
||
| ``` | ||
| cd src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/net45 | ||
|
|
||
| mono Grpc.IntegrationTesting.Client.exe --server_host=localhost --server_port=50052 --test_case=large_unary | ||
| ``` | ||
|
|
||
| NOTE: Currently the some tests will fail because not all the features are implemented | ||
| by Grpc.AspNetCore.Server |
54 changes: 54 additions & 0 deletions
54
...lTests/Android/Device_Emulator/gRPC/grpc-dotnet/testassets/InteropTestsWebsite/Startup.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,54 @@ | ||
| #region Copyright notice and license | ||
|
|
||
| // Copyright 2019 The gRPC Authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #endregion | ||
|
|
||
| using Grpc.Testing; | ||
|
|
||
| namespace InteropTestsWebsite | ||
| { | ||
| public class Startup | ||
| { | ||
| // This method gets called by the runtime. Use this method to add services to the container. | ||
| // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 | ||
| public void ConfigureServices(IServiceCollection services) | ||
| { | ||
| services.AddGrpc(); | ||
| services.AddCors(o => | ||
| { | ||
| o.AddPolicy("InteropTests", builder => | ||
| { | ||
| builder.AllowAnyOrigin(); | ||
| builder.AllowAnyMethod(); | ||
| builder.AllowAnyHeader(); | ||
| builder.WithExposedHeaders("Grpc-Status", "Grpc-Message", "Grpc-Encoding", "Grpc-Accept-Encoding", "x-grpc-test-echo-initial", "x-grpc-test-echo-trailing-bin"); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | ||
| public void Configure(IApplicationBuilder app) | ||
| { | ||
| app.UseRouting(); | ||
| app.UseCors(); | ||
| app.UseGrpcWeb(); | ||
| app.UseEndpoints(endpoints => | ||
| { | ||
| endpoints.MapGrpcService<TestServiceImpl>().RequireCors("InteropTests").EnableGrpcWeb(); | ||
| }); | ||
| } | ||
| } | ||
| } |
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.