Merge pull request #18697 from jtattermusch/csharp_improved_distribtest

Improved C# distribtests
pull/20192/head
Jan Tattermusch 5 years ago committed by GitHub
commit d2f0e17d3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      test/distrib/csharp/DistribTest/DistribTest.csproj
  2. 12
      test/distrib/csharp/DistribTest/DistribTestDotNet.csproj
  3. 46
      test/distrib/csharp/DistribTest/Program.cs
  4. 4
      test/distrib/csharp/DistribTest/packages.config
  5. 2
      test/distrib/csharp/DistribTest/testcodegen.proto
  6. 3
      test/distrib/csharp/run_distrib_test.sh
  7. 6
      test/distrib/csharp/run_distrib_test_dotnetcli.sh
  8. 38
      test/distrib/csharp/test_codegen/test_codegen.sh
  9. 29
      test/distrib/csharp/test_codegen/testcodegen.proto
  10. 2
      test/distrib/csharp/update_version.sh
  11. 31
      tools/dockerfile/distribtest/csharp_stretch_x64/Dockerfile
  12. 10
      tools/dockerfile/distribtest/csharp_ubuntu1604_x64/Dockerfile
  13. 5
      tools/run_tests/artifacts/distribtest_targets.py

@ -68,8 +68,14 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath>
<Reference Include="System.Buffers">
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard1.1\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Memory">
<HintPath>..\packages\System.Memory.4.5.3\lib\netstandard1.1\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp1.0;net45</TargetFrameworks>
<TargetFrameworks>net45;netcoreapp2.1</TargetFrameworks>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
@ -23,10 +23,8 @@
<Protobuf Include="**\*.proto" />
</ItemGroup>
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<!-- Workaround for https://github.com/dotnet/sdk/issues/335 -->
<FrameworkPathOverride Condition="Exists('/usr/lib/mono/4.5-api')">/usr/lib/mono/4.5-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="Exists('/usr/local/lib/mono/4.5-api')">/usr/local/lib/mono/4.5-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="Exists('/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5-api')">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5-api</FrameworkPathOverride>
</PropertyGroup>
<!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0-preview.2" PrivateAssets="All" />
</ItemGroup>
</Project>

@ -16,8 +16,11 @@
#endregion
using System;
using System;
using System.Linq;
using System.Threading.Tasks;
using Grpc.Core;
using Helloworld;
namespace TestGrpcPackage
{
@ -25,14 +28,39 @@ namespace TestGrpcPackage
{
public static void Main(string[] args)
{
// test codegen works
var reply = new Testcodegen.HelloReply();
// This code doesn't do much but makes sure the native extension is loaded
// which is what we are testing here.
Channel c = new Channel("127.0.0.1:1000", ChannelCredentials.Insecure);
c.ShutdownAsync().Wait();
Console.WriteLine("Success!");
// Disable SO_REUSEPORT to prevent https://github.com/grpc/grpc/issues/10755
Server server = new Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) })
{
Services = { Greeter.BindService(new GreeterImpl()) },
Ports = { new ServerPort("localhost", ServerPort.PickUnused, ServerCredentials.Insecure) }
};
server.Start();
Channel channel = new Channel("localhost", server.Ports.Single().BoundPort, ChannelCredentials.Insecure);
try
{
var client = new Greeter.GreeterClient(channel);
String user = "you";
var reply = client.SayHello(new HelloRequest { Name = user });
Console.WriteLine("Greeting: " + reply.Message);
Console.WriteLine("Success!");
}
finally
{
channel.ShutdownAsync().Wait();
server.ShutdownAsync().Wait();
}
}
}
class GreeterImpl : Greeter.GreeterBase
{
// Server side handler of the SayHello RPC
public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
{
return Task.FromResult(new HelloReply { Message = "Hello " + request.Name });
}
}
}

@ -9,6 +9,8 @@
<package id="Grpc.Core.Api" version="__GRPC_NUGET_VERSION__" targetFramework="net45" />
<package id="Grpc.Tools" version="__GRPC_NUGET_VERSION__" targetFramework="net45" />
<package id="Google.Protobuf" version="3.7.0" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="System.Buffers" version="4.4.0" targetFramework="net45" />
<package id="System.Memory" version="4.5.3" targetFramework="net45" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net45" />
</packages>

@ -14,7 +14,7 @@
syntax = "proto3";
package testcodegen;
package helloworld;
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply) {}

@ -27,6 +27,3 @@ nuget restore || nuget restore || nuget restore
msbuild DistribTest.sln
mono DistribTest/bin/Debug/DistribTest.exe
# test that codegen work
test_codegen/test_codegen.sh

@ -28,7 +28,7 @@ cd DistribTest
dotnet restore DistribTestDotNet.csproj
dotnet build DistribTestDotNet.csproj
dotnet publish -f netcoreapp1.0 DistribTestDotNet.csproj
dotnet publish -f netcoreapp2.1 DistribTestDotNet.csproj
dotnet publish -f net45 DistribTestDotNet.csproj
ls -R bin
@ -40,7 +40,7 @@ mono bin/Debug/net45/publish/DistribTestDotNet.exe
mono bin/Debug/net45/publish/DistribTestDotNet.exe
# .NET Core target after dotnet build
dotnet exec bin/Debug/netcoreapp1.0/DistribTestDotNet.dll
dotnet exec bin/Debug/netcoreapp2.1/DistribTestDotNet.dll
# .NET Core target after dotnet publish
dotnet exec bin/Debug/netcoreapp1.0/publish/DistribTestDotNet.dll
dotnet exec bin/Debug/netcoreapp2.1/publish/DistribTestDotNet.dll

@ -1,38 +0,0 @@
#!/bin/bash
# Copyright 2018 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.
set -ex
cd "$(dirname "$0")"
ls -lR "../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools"
PLATFORM_ARCH=linux_x64
if [ "$(uname)" == "Darwin" ]
then
PLATFORM_ARCH=macosx_x64
elif [ "$(getconf LONG_BIT)" == "32" ]
then
PLATFORM_ARCH=linux_x86
fi
PROTOC=../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools/${PLATFORM_ARCH}/protoc
PLUGIN=../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools/${PLATFORM_ARCH}/grpc_csharp_plugin
"${PROTOC}" --plugin="protoc-gen-grpc=${PLUGIN}" --csharp_out=. --grpc_out=. -I . testcodegen.proto
ls ./*.cs
echo 'Code generation works.'

@ -1,29 +0,0 @@
// Copyright 2018 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.
syntax = "proto3";
package testcodegen;
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}

@ -28,4 +28,4 @@ then
fi
# Replaces version placeholder with value provided as first argument.
sed -ibak "s/__GRPC_NUGET_VERSION__/${CSHARP_VERSION}/g" DistribTest/packages.config DistribTest/DistribTest.csproj DistribTest/DistribTestDotNet.csproj test_codegen/test_codegen.sh
sed -ibak "s/__GRPC_NUGET_VERSION__/${CSHARP_VERSION}/g" DistribTest/packages.config DistribTest/DistribTest.csproj DistribTest/DistribTestDotNet.csproj

@ -1,4 +1,4 @@
# Copyright 2015 gRPC authors.
# 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.
@ -12,32 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:14.04
FROM debian:stretch
RUN apt-get update && apt-get install -y apt-transport-https && apt-get clean
RUN apt-get update && apt-get install -y apt-transport-https dirmngr gnupg ca-certificates && apt-get clean
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-trusty main" | tee /etc/apt/sources.list.d/mono-official-stable.list
RUN echo "deb https://download.mono-project.com/repo/debian stable-stretch main" | tee /etc/apt/sources.list.d/mono-official-stable.list
RUN apt-get update && apt-get install -y \
mono-devel \
nuget \
&& apt-get clean
RUN apt-get update && apt-get install -y unzip && apt-get clean
RUN apt-get update && apt-get install -y curl && apt-get clean
# Install dotnet CLI
RUN apt-get install -y apt-transport-https
RUN sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
RUN apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
RUN apt-get update && apt-get install -y dotnet-dev-1.0.4
# Trigger the population of the local package cache for dotnet CLI
RUN mkdir warmup \
&& cd warmup \
&& dotnet new \
&& cd .. \
&& rm -rf warmup
# Install dotnet SDK
ENV DOTNET_SDK_VERSION 2.1.500
RUN curl -sSL -o dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \
&& mkdir -p /usr/share/dotnet \
&& tar -zxf dotnet.tar.gz -C /usr/share/dotnet \
&& rm dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
RUN apt-get update && apt-get install -y unzip && apt-get clean
# Make sure the mono certificate store is up-to-date to prevent issues with nuget restore
RUN apt-get update && apt-get install -y curl && apt-get clean

@ -24,6 +24,16 @@ RUN apt-get update && apt-get install -y \
nuget \
&& apt-get clean
RUN apt-get update && apt-get install -y curl && apt-get clean
# Install dotnet SDK
ENV DOTNET_SDK_VERSION 2.1.500
RUN curl -sSL -o dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \
&& mkdir -p /usr/share/dotnet \
&& tar -zxf dotnet.tar.gz -C /usr/share/dotnet \
&& rm dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
RUN apt-get update && apt-get install -y unzip && apt-get clean
# Make sure the mono certificate store is up-to-date to prevent issues with nuget restore

@ -305,10 +305,11 @@ def targets():
CppDistribTest('windows', 'x86', testcase='cmake_as_externalproject'),
CSharpDistribTest('linux', 'x64', 'jessie'),
CSharpDistribTest('linux', 'x86', 'jessie'),
CSharpDistribTest('linux', 'x64', 'stretch'),
CSharpDistribTest('linux', 'x64', 'stretch', use_dotnet_cli=True),
CSharpDistribTest('linux', 'x64', 'centos7'),
CSharpDistribTest('linux', 'x64', 'ubuntu1404'),
CSharpDistribTest('linux', 'x64', 'ubuntu1604'),
CSharpDistribTest('linux', 'x64', 'ubuntu1404', use_dotnet_cli=True),
CSharpDistribTest('linux', 'x64', 'ubuntu1604', use_dotnet_cli=True),
CSharpDistribTest('macos', 'x86'),
CSharpDistribTest('windows', 'x86'),
CSharpDistribTest('windows', 'x64'),

Loading…
Cancel
Save