update to the newest CommandLineParser API

pull/7671/head
Jan Tattermusch 8 years ago
parent 678ec90119
commit 90cbde88c9
  1. 6
      src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj
  2. 22
      src/csharp/Grpc.IntegrationTesting/InteropClient.cs
  3. 22
      src/csharp/Grpc.IntegrationTesting/InteropServer.cs
  4. 22
      src/csharp/Grpc.IntegrationTesting/QpsWorker.cs
  5. 23
      src/csharp/Grpc.IntegrationTesting/StressTestClient.cs
  6. 2
      src/csharp/Grpc.IntegrationTesting/packages.config

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

@ -84,19 +84,6 @@ namespace Grpc.IntegrationTesting
[Option("service_account_key_file", Required = false)] [Option("service_account_key_file", Required = false)]
public string ServiceAccountKeyFile { get; set; } 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; ClientOptions options;
@ -108,14 +95,13 @@ namespace Grpc.IntegrationTesting
public static void Run(string[] args) public static void Run(string[] args)
{ {
var options = new ClientOptions(); var parserResult = Parser.Default.ParseArguments<ClientOptions>(args)
if (!Parser.Default.ParseArguments(args, options)) .WithNotParsed(errors => Environment.Exit(1))
.WithParsed(options =>
{ {
Environment.Exit(1);
}
var interopClient = new InteropClient(options); var interopClient = new InteropClient(options);
interopClient.Run().Wait(); interopClient.Run().Wait();
});
} }
private async Task Run() private async Task Run()

@ -57,19 +57,6 @@ namespace Grpc.IntegrationTesting
// Deliberately using nullable bool type to allow --use_tls=true syntax (as opposed to --use_tls) // Deliberately using nullable bool type to allow --use_tls=true syntax (as opposed to --use_tls)
[Option("use_tls", Default = false)] [Option("use_tls", Default = false)]
public bool? UseTls { get; set; } 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; ServerOptions options;
@ -81,14 +68,13 @@ namespace Grpc.IntegrationTesting
public static void Run(string[] args) public static void Run(string[] args)
{ {
var options = new ServerOptions(); var parserResult = Parser.Default.ParseArguments<ServerOptions>(args)
if (!Parser.Default.ParseArguments(args, options)) .WithNotParsed(errors => Environment.Exit(1))
.WithParsed(options =>
{ {
Environment.Exit(1);
}
var interopServer = new InteropServer(options); var interopServer = new InteropServer(options);
interopServer.Run(); interopServer.Run();
});
} }
private void Run() private void Run()

@ -54,19 +54,6 @@ namespace Grpc.IntegrationTesting
{ {
[Option("driver_port", Default = 0)] [Option("driver_port", Default = 0)]
public int DriverPort { get; set; } 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; ServerOptions options;
@ -78,14 +65,13 @@ namespace Grpc.IntegrationTesting
public static void Run(string[] args) public static void Run(string[] args)
{ {
var options = new ServerOptions(); var parserResult = Parser.Default.ParseArguments<ServerOptions>(args)
if (!Parser.Default.ParseArguments(args, options)) .WithNotParsed((x) => Environment.Exit(1))
.WithParsed(options =>
{ {
Environment.Exit(1);
}
var workerServer = new QpsWorker(options); var workerServer = new QpsWorker(options);
workerServer.RunAsync().Wait(); workerServer.RunAsync().Wait();
});
} }
private async Task RunAsync() private async Task RunAsync()

@ -71,19 +71,6 @@ namespace Grpc.IntegrationTesting
[Option("metrics_port", Default = 8081)] [Option("metrics_port", Default = 8081)]
public int MetricsPort { get; set; } 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; ClientOptions options;
@ -105,12 +92,9 @@ namespace Grpc.IntegrationTesting
public static void Run(string[] args) public static void Run(string[] args)
{ {
var options = new ClientOptions(); var parserResult = Parser.Default.ParseArguments<ClientOptions>(args)
if (!Parser.Default.ParseArguments(args, options)) .WithNotParsed((x) => Environment.Exit(1))
{ .WithParsed(options => {
Environment.Exit(1);
}
GrpcPreconditions.CheckArgument(options.NumChannelsPerServer > 0); GrpcPreconditions.CheckArgument(options.NumChannelsPerServer > 0);
GrpcPreconditions.CheckArgument(options.NumStubsPerChannel > 0); GrpcPreconditions.CheckArgument(options.NumStubsPerChannel > 0);
@ -122,6 +106,7 @@ namespace Grpc.IntegrationTesting
var interopClient = new StressTestClient(options, serverAddresses.ToList(), testCases); var interopClient = new StressTestClient(options, serverAddresses.ToList(), testCases);
interopClient.Run().Wait(); interopClient.Run().Wait();
});
} }
async Task Run() async Task Run()

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

Loading…
Cancel
Save