Merge pull request #7671 from jtattermusch/coreclr_commandlineparser

Use CommandLineParser that supports CoreCLR
pull/7728/head
Jan Tattermusch 8 years ago committed by GitHub
commit 92b9d21f83
  1. 6
      src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj
  2. 38
      src/csharp/Grpc.IntegrationTesting/InteropClient.cs
  3. 32
      src/csharp/Grpc.IntegrationTesting/InteropServer.cs
  4. 30
      src/csharp/Grpc.IntegrationTesting/QpsWorker.cs
  5. 51
      src/csharp/Grpc.IntegrationTesting/StressTestClient.cs
  6. 2
      src/csharp/Grpc.IntegrationTesting/packages.config
  7. 2
      src/csharp/Grpc.IntegrationTesting/project.json
  8. 2
      templates/src/csharp/Grpc.IntegrationTesting/project.json.template

@ -38,9 +38,6 @@
<AssemblyOriginatorKeyFile>..\keys\Grpc.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLine">
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
</Reference>
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
</Reference>
@ -75,6 +72,9 @@
<Reference Include="Google.Apis.Auth.PlatformServices">
<HintPath>..\packages\Google.Apis.Auth.1.15.0\lib\net45\Google.Apis.Auth.PlatformServices.dll</HintPath>
</Reference>
<Reference Include="CommandLineParser.Unofficial">
<HintPath>..\packages\CommandLineParser.Unofficial.2.0.275\lib\net45\CommandLineParser.Unofficial.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\Grpc.Core\Version.cs">

@ -56,24 +56,24 @@ namespace Grpc.IntegrationTesting
{
private class ClientOptions
{
[Option("server_host", DefaultValue = "127.0.0.1")]
[Option("server_host", Default = "127.0.0.1")]
public string ServerHost { get; set; }
[Option("server_host_override", DefaultValue = TestCredentials.DefaultHostOverride)]
[Option("server_host_override", Default = TestCredentials.DefaultHostOverride)]
public string ServerHostOverride { get; set; }
[Option("server_port", Required = true)]
public int ServerPort { get; set; }
[Option("test_case", DefaultValue = "large_unary")]
[Option("test_case", Default = "large_unary")]
public string TestCase { get; set; }
// Deliberately using nullable bool type to allow --use_tls=true syntax (as opposed to --use_tls)
[Option("use_tls", DefaultValue = false)]
[Option("use_tls", Default = false)]
public bool? UseTls { get; set; }
// Deliberately using nullable bool type to allow --use_test_ca=true syntax (as opposed to --use_test_ca)
[Option("use_test_ca", DefaultValue = false)]
[Option("use_test_ca", Default = false)]
public bool? UseTestCa { get; set; }
[Option("default_service_account", Required = false)]
@ -84,19 +84,6 @@ namespace Grpc.IntegrationTesting
[Option("service_account_key_file", Required = false)]
public string ServiceAccountKeyFile { get; set; }
[HelpOption]
public string GetUsage()
{
var help = new HelpText
{
Heading = "gRPC C# interop testing client",
AddDashesToOption = true
};
help.AddPreOptionsLine("Usage:");
help.AddOptions(this);
return help;
}
}
ClientOptions options;
@ -108,14 +95,13 @@ namespace Grpc.IntegrationTesting
public static void Run(string[] args)
{
var options = new ClientOptions();
if (!Parser.Default.ParseArguments(args, options))
{
Environment.Exit(1);
}
var interopClient = new InteropClient(options);
interopClient.Run().Wait();
var parserResult = Parser.Default.ParseArguments<ClientOptions>(args)
.WithNotParsed(errors => Environment.Exit(1))
.WithParsed(options =>
{
var interopClient = new InteropClient(options);
interopClient.Run().Wait();
});
}
private async Task Run()

@ -51,25 +51,12 @@ namespace Grpc.IntegrationTesting
{
private class ServerOptions
{
[Option("port", DefaultValue = 8070)]
[Option("port", Default = 8070)]
public int Port { get; set; }
// Deliberately using nullable bool type to allow --use_tls=true syntax (as opposed to --use_tls)
[Option("use_tls", DefaultValue = false)]
[Option("use_tls", Default = false)]
public bool? UseTls { get; set; }
[HelpOption]
public string GetUsage()
{
var help = new HelpText
{
Heading = "gRPC C# interop testing server",
AddDashesToOption = true
};
help.AddPreOptionsLine("Usage:");
help.AddOptions(this);
return help;
}
}
ServerOptions options;
@ -81,14 +68,13 @@ namespace Grpc.IntegrationTesting
public static void Run(string[] args)
{
var options = new ServerOptions();
if (!Parser.Default.ParseArguments(args, options))
{
Environment.Exit(1);
}
var interopServer = new InteropServer(options);
interopServer.Run();
var parserResult = Parser.Default.ParseArguments<ServerOptions>(args)
.WithNotParsed(errors => Environment.Exit(1))
.WithParsed(options =>
{
var interopServer = new InteropServer(options);
interopServer.Run();
});
}
private void Run()

@ -52,21 +52,8 @@ namespace Grpc.IntegrationTesting
{
private class ServerOptions
{
[Option("driver_port", DefaultValue = 0)]
[Option("driver_port", Default = 0)]
public int DriverPort { get; set; }
[HelpOption]
public string GetUsage()
{
var help = new HelpText
{
Heading = "gRPC C# performance testing worker",
AddDashesToOption = true
};
help.AddPreOptionsLine("Usage:");
help.AddOptions(this);
return help;
}
}
ServerOptions options;
@ -78,14 +65,13 @@ namespace Grpc.IntegrationTesting
public static void Run(string[] args)
{
var options = new ServerOptions();
if (!Parser.Default.ParseArguments(args, options))
{
Environment.Exit(1);
}
var workerServer = new QpsWorker(options);
workerServer.RunAsync().Wait();
var parserResult = Parser.Default.ParseArguments<ServerOptions>(args)
.WithNotParsed((x) => Environment.Exit(1))
.WithParsed(options =>
{
var workerServer = new QpsWorker(options);
workerServer.RunAsync().Wait();
});
}
private async Task RunAsync()

@ -54,36 +54,23 @@ namespace Grpc.IntegrationTesting
private class ClientOptions
{
[Option("server_addresses", DefaultValue = "localhost:8080")]
[Option("server_addresses", Default = "localhost:8080")]
public string ServerAddresses { get; set; }
[Option("test_cases", DefaultValue = "large_unary:100")]
[Option("test_cases", Default = "large_unary:100")]
public string TestCases { get; set; }
[Option("test_duration_secs", DefaultValue = -1)]
[Option("test_duration_secs", Default = -1)]
public int TestDurationSecs { get; set; }
[Option("num_channels_per_server", DefaultValue = 1)]
[Option("num_channels_per_server", Default = 1)]
public int NumChannelsPerServer { get; set; }
[Option("num_stubs_per_channel", DefaultValue = 1)]
[Option("num_stubs_per_channel", Default = 1)]
public int NumStubsPerChannel { get; set; }
[Option("metrics_port", DefaultValue = 8081)]
[Option("metrics_port", Default = 8081)]
public int MetricsPort { get; set; }
[HelpOption]
public string GetUsage()
{
var help = new HelpText
{
Heading = "gRPC C# stress test client",
AddDashesToOption = true
};
help.AddPreOptionsLine("Usage:");
help.AddOptions(this);
return help;
}
}
ClientOptions options;
@ -105,23 +92,21 @@ namespace Grpc.IntegrationTesting
public static void Run(string[] args)
{
var options = new ClientOptions();
if (!Parser.Default.ParseArguments(args, options))
{
Environment.Exit(1);
}
GrpcPreconditions.CheckArgument(options.NumChannelsPerServer > 0);
GrpcPreconditions.CheckArgument(options.NumStubsPerChannel > 0);
var parserResult = Parser.Default.ParseArguments<ClientOptions>(args)
.WithNotParsed((x) => Environment.Exit(1))
.WithParsed(options => {
GrpcPreconditions.CheckArgument(options.NumChannelsPerServer > 0);
GrpcPreconditions.CheckArgument(options.NumStubsPerChannel > 0);
var serverAddresses = options.ServerAddresses.Split(',');
GrpcPreconditions.CheckArgument(serverAddresses.Length > 0, "You need to provide at least one server address");
var serverAddresses = options.ServerAddresses.Split(',');
GrpcPreconditions.CheckArgument(serverAddresses.Length > 0, "You need to provide at least one server address");
var testCases = ParseWeightedTestCases(options.TestCases);
GrpcPreconditions.CheckArgument(testCases.Count > 0, "You need to provide at least one test case");
var testCases = ParseWeightedTestCases(options.TestCases);
GrpcPreconditions.CheckArgument(testCases.Count > 0, "You need to provide at least one test case");
var interopClient = new StressTestClient(options, serverAddresses.ToList(), testCases);
interopClient.Run().Wait();
var interopClient = new StressTestClient(options, serverAddresses.ToList(), testCases);
interopClient.Run().Wait();
});
}
async Task Run()

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle" version="1.7.0" targetFramework="net45" />
<package id="CommandLineParser" version="1.9.71" targetFramework="net45" />
<package id="CommandLineParser.Unofficial" version="2.0.275" targetFramework="net45" />
<package id="Google.Apis.Auth" version="1.15.0" targetFramework="net45" />
<package id="Google.Apis.Core" version="1.15.0" targetFramework="net45" />
<package id="Google.Protobuf" version="3.0.0-beta3" targetFramework="net45" />

@ -58,7 +58,7 @@
"target": "project"
},
"Google.Protobuf": "3.0.0-beta3",
"CommandLineParser": "1.9.71",
"CommandLineParser.Unofficial": "2.0.275",
"NUnit": "3.2.0",
"NUnitLite": "3.2.0-*"
},

@ -10,7 +10,7 @@
"target": "project"
},
"Google.Protobuf": "3.0.0-beta3",
"CommandLineParser": "1.9.71",
"CommandLineParser.Unofficial": "2.0.275",
"NUnit": "3.2.0",
"NUnitLite": "3.2.0-*"
},

Loading…
Cancel
Save