blob: 183cfb430634651a1cb9e241e723370728cd1c39 [file] [log] [blame]
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001// Licensed to the Apache Software Foundation(ASF) under one
2// or more contributor license agreements.See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
Jens Geyer273607d2021-07-31 23:25:51 +020018#pragma warning disable IDE0066 // switch expression
19#pragma warning disable IDE0057 // substring
Jens Geyer71569402021-11-13 23:51:16 +010020#pragma warning disable CS1998 // no await in async method
Jens Geyer273607d2021-07-31 23:25:51 +020021
Jens Geyeraa0c8b32019-01-28 23:27:45 +010022using System;
23using System.Collections.Generic;
24using System.Diagnostics;
25using System.IO;
26using System.Linq;
27using System.Net;
28using System.Reflection;
29using System.Security.Authentication;
30using System.Security.Cryptography.X509Certificates;
31using System.ServiceModel;
32using System.Text;
33using System.Threading;
34using System.Threading.Tasks;
Jens Geyereacd1d42019-11-20 19:03:14 +010035using Thrift;
Jens Geyeraa0c8b32019-01-28 23:27:45 +010036using Thrift.Collections;
37using Thrift.Protocol;
38using Thrift.Transport;
39using Thrift.Transport.Client;
40
41namespace ThriftTest
42{
Jens Geyeradde44b2019-02-05 01:00:02 +010043 internal enum ProtocolChoice
44 {
45 Binary,
46 Compact,
47 Json
48 }
49
50 // it does not make much sense to use buffered when we already use framed
51 internal enum LayeredChoice
52 {
53 None,
54 Buffered,
55 Framed
56 }
57
Jens Geyeradde44b2019-02-05 01:00:02 +010058 internal enum TransportChoice
59 {
60 Socket,
61 TlsSocket,
Jens Geyer96c61132019-06-14 22:39:56 +020062 Http,
Jens Geyeradde44b2019-02-05 01:00:02 +010063 NamedPipe
64 }
65
Jens Geyeraa0c8b32019-01-28 23:27:45 +010066 public class TestClient
67 {
68 private class TestParams
69 {
70 public int numIterations = 1;
Jens Geyer22c412e2019-03-12 01:06:25 +010071 public string host = "localhost";
Jens Geyeraa0c8b32019-01-28 23:27:45 +010072 public int port = 9090;
73 public int numThreads = 1;
Jens Geyer98a23252022-01-09 16:50:52 +010074 public string url = string.Empty;
75 public string pipe = string.Empty;
Jens Geyeradde44b2019-02-05 01:00:02 +010076 public LayeredChoice layered = LayeredChoice.None;
77 public ProtocolChoice protocol = ProtocolChoice.Binary;
78 public TransportChoice transport = TransportChoice.Socket;
Jens Geyer98a23252022-01-09 16:50:52 +010079 private readonly TConfiguration Configuration = new();
Jens Geyeraa0c8b32019-01-28 23:27:45 +010080
Jens Geyerbd1a2732019-06-26 22:52:44 +020081 internal void Parse(List<string> args)
Jens Geyeraa0c8b32019-01-28 23:27:45 +010082 {
83 for (var i = 0; i < args.Count; ++i)
84 {
85 if (args[i] == "-u")
86 {
87 url = args[++i];
Jens Geyer96c61132019-06-14 22:39:56 +020088 transport = TransportChoice.Http;
Jens Geyeraa0c8b32019-01-28 23:27:45 +010089 }
90 else if (args[i] == "-n")
91 {
92 numIterations = Convert.ToInt32(args[++i]);
93 }
94 else if (args[i].StartsWith("--pipe="))
95 {
96 pipe = args[i].Substring(args[i].IndexOf("=") + 1);
Jens Geyeradde44b2019-02-05 01:00:02 +010097 transport = TransportChoice.NamedPipe;
Jens Geyeraa0c8b32019-01-28 23:27:45 +010098 }
99 else if (args[i].StartsWith("--host="))
100 {
101 // check there for ipaddress
Jens Geyer22c412e2019-03-12 01:06:25 +0100102 host = args[i].Substring(args[i].IndexOf("=") + 1);
Jens Geyeradde44b2019-02-05 01:00:02 +0100103 if (transport != TransportChoice.TlsSocket)
104 transport = TransportChoice.Socket;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100105 }
106 else if (args[i].StartsWith("--port="))
107 {
108 port = int.Parse(args[i].Substring(args[i].IndexOf("=") + 1));
Jens Geyeradde44b2019-02-05 01:00:02 +0100109 if (transport != TransportChoice.TlsSocket)
110 transport = TransportChoice.Socket;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100111 }
112 else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered")
113 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100114 layered = LayeredChoice.Buffered;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100115 }
116 else if (args[i] == "-f" || args[i] == "--framed" || args[i] == "--transport=framed")
117 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100118 layered = LayeredChoice.Framed;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100119 }
120 else if (args[i] == "-t")
121 {
122 numThreads = Convert.ToInt32(args[++i]);
123 }
124 else if (args[i] == "--binary" || args[i] == "--protocol=binary")
125 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100126 protocol = ProtocolChoice.Binary;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100127 }
128 else if (args[i] == "--compact" || args[i] == "--protocol=compact")
129 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100130 protocol = ProtocolChoice.Compact;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100131 }
132 else if (args[i] == "--json" || args[i] == "--protocol=json")
133 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100134 protocol = ProtocolChoice.Json;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100135 }
136 else if (args[i] == "--ssl")
137 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100138 transport = TransportChoice.TlsSocket;
139 }
140 else if (args[i] == "--help")
141 {
142 PrintOptionsHelp();
143 return;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100144 }
145 else
146 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100147 Console.WriteLine("Invalid argument: {0}", args[i]);
148 PrintOptionsHelp();
149 return;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100150 }
151 }
Jens Geyeradde44b2019-02-05 01:00:02 +0100152
153 switch (transport)
154 {
155 case TransportChoice.Socket:
156 Console.WriteLine("Using socket transport");
157 break;
158 case TransportChoice.TlsSocket:
159 Console.WriteLine("Using encrypted transport");
160 break;
Jens Geyer96c61132019-06-14 22:39:56 +0200161 case TransportChoice.Http:
162 Console.WriteLine("Using HTTP transport");
163 break;
Jens Geyeradde44b2019-02-05 01:00:02 +0100164 case TransportChoice.NamedPipe:
165 Console.WriteLine("Using named pipes transport");
166 break;
167 default: // unhandled case
168 Debug.Assert(false);
169 break;
170 }
171
172 switch (layered)
173 {
174 case LayeredChoice.Framed:
175 Console.WriteLine("Using framed transport");
176 break;
177 case LayeredChoice.Buffered:
178 Console.WriteLine("Using buffered transport");
179 break;
180 default: // unhandled case?
181 Debug.Assert(layered == LayeredChoice.None);
182 break;
183 }
184
185 switch (protocol)
186 {
187 case ProtocolChoice.Binary:
188 Console.WriteLine("Using binary protocol");
189 break;
190 case ProtocolChoice.Compact:
191 Console.WriteLine("Using compact protocol");
192 break;
193 case ProtocolChoice.Json:
194 Console.WriteLine("Using JSON protocol");
195 break;
196 default: // unhandled case?
197 Debug.Assert(false);
198 break;
199 }
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100200 }
201
202 private static X509Certificate2 GetClientCert()
203 {
204 var clientCertName = "client.p12";
205 var possiblePaths = new List<string>
206 {
207 "../../../keys/",
208 "../../keys/",
209 "../keys/",
210 "keys/",
211 };
212
Jens Geyer98a23252022-01-09 16:50:52 +0100213 var existingPath = string.Empty;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100214 foreach (var possiblePath in possiblePaths)
215 {
216 var path = Path.GetFullPath(possiblePath + clientCertName);
217 if (File.Exists(path))
218 {
219 existingPath = path;
220 break;
221 }
222 }
223
224 if (string.IsNullOrEmpty(existingPath))
225 {
226 throw new FileNotFoundException($"Cannot find file: {clientCertName}");
227 }
Jens Geyerbd1a2732019-06-26 22:52:44 +0200228
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100229 var cert = new X509Certificate2(existingPath, "thrift");
230
231 return cert;
232 }
Jens Geyerbd1a2732019-06-26 22:52:44 +0200233
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100234 public TTransport CreateTransport()
235 {
Jens Geyer96c61132019-06-14 22:39:56 +0200236 // endpoint transport
Jens Geyer98a23252022-01-09 16:50:52 +0100237 TTransport trans;
Jens Geyerbd1a2732019-06-26 22:52:44 +0200238 switch (transport)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100239 {
Jens Geyer96c61132019-06-14 22:39:56 +0200240 case TransportChoice.Http:
241 Debug.Assert(url != null);
Jens Geyereacd1d42019-11-20 19:03:14 +0100242 trans = new THttpTransport(new Uri(url), Configuration);
Jens Geyer96c61132019-06-14 22:39:56 +0200243 break;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100244
Jens Geyer96c61132019-06-14 22:39:56 +0200245 case TransportChoice.NamedPipe:
246 Debug.Assert(pipe != null);
Jens Geyereacd1d42019-11-20 19:03:14 +0100247 trans = new TNamedPipeTransport(pipe,Configuration);
Jens Geyer96c61132019-06-14 22:39:56 +0200248 break;
Jens Geyeradde44b2019-02-05 01:00:02 +0100249
Jens Geyer96c61132019-06-14 22:39:56 +0200250 case TransportChoice.TlsSocket:
251 var cert = GetClientCert();
252 if (cert == null || !cert.HasPrivateKey)
253 {
254 throw new InvalidOperationException("Certificate doesn't contain private key");
255 }
Jens Geyerbd1a2732019-06-26 22:52:44 +0200256
Jens Geyereacd1d42019-11-20 19:03:14 +0100257 trans = new TTlsSocketTransport(host, port, Configuration, 0,
258 cert,
Jens Geyer96c61132019-06-14 22:39:56 +0200259 (sender, certificate, chain, errors) => true,
Jens Geyer51fc54f2023-02-14 23:51:16 +0100260 null, SslProtocols.Tls12);
Jens Geyer96c61132019-06-14 22:39:56 +0200261 break;
Jens Geyeradde44b2019-02-05 01:00:02 +0100262
Jens Geyer96c61132019-06-14 22:39:56 +0200263 case TransportChoice.Socket:
264 default:
Jens Geyereacd1d42019-11-20 19:03:14 +0100265 trans = new TSocketTransport(host, port, Configuration);
Jens Geyer96c61132019-06-14 22:39:56 +0200266 break;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100267 }
268
Jens Geyer96c61132019-06-14 22:39:56 +0200269
270 // layered transport
Jens Geyerbd1a2732019-06-26 22:52:44 +0200271 switch (layered)
Jens Geyer96c61132019-06-14 22:39:56 +0200272 {
273 case LayeredChoice.Buffered:
274 trans = new TBufferedTransport(trans);
275 break;
276 case LayeredChoice.Framed:
277 trans = new TFramedTransport(trans);
278 break;
279 default:
280 Debug.Assert(layered == LayeredChoice.None);
281 break;
282 }
283
284 return trans;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100285 }
286
287 public TProtocol CreateProtocol(TTransport transport)
288 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100289 switch (protocol)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100290 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100291 case ProtocolChoice.Compact:
292 return new TCompactProtocol(transport);
293 case ProtocolChoice.Json:
294 return new TJsonProtocol(transport);
295 case ProtocolChoice.Binary:
296 default:
297 return new TBinaryProtocol(transport);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100298 }
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100299 }
300 }
301
302
303 private const int ErrorBaseTypes = 1;
304 private const int ErrorStructs = 2;
305 private const int ErrorContainers = 4;
306 private const int ErrorExceptions = 8;
307 private const int ErrorUnknown = 64;
308
309 private class ClientTest
310 {
311 private readonly TTransport transport;
312 private readonly ThriftTest.Client client;
313 private readonly int numIterations;
314 private bool done;
315
316 public int ReturnCode { get; set; }
317
318 public ClientTest(TestParams param)
319 {
320 transport = param.CreateTransport();
321 client = new ThriftTest.Client(param.CreateProtocol(transport));
322 numIterations = param.numIterations;
323 }
324
Jens Geyer71569402021-11-13 23:51:16 +0100325 public async Task Execute()
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100326 {
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100327 if (done)
328 {
329 Console.WriteLine("Execute called more than once");
330 throw new InvalidOperationException();
331 }
332
333 for (var i = 0; i < numIterations; i++)
334 {
335 try
336 {
337 if (!transport.IsOpen)
Jens Geyer71569402021-11-13 23:51:16 +0100338 await transport.OpenAsync(MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100339 }
340 catch (TTransportException ex)
341 {
342 Console.WriteLine("*** FAILED ***");
343 Console.WriteLine("Connect failed: " + ex.Message);
344 ReturnCode |= ErrorUnknown;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200345 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100346 continue;
347 }
348 catch (Exception ex)
349 {
350 Console.WriteLine("*** FAILED ***");
351 Console.WriteLine("Connect failed: " + ex.Message);
352 ReturnCode |= ErrorUnknown;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200353 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100354 continue;
355 }
356
357 try
358 {
Jens Geyer71569402021-11-13 23:51:16 +0100359 ReturnCode |= await ExecuteClientTest(client);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100360 }
361 catch (Exception ex)
362 {
363 Console.WriteLine("*** FAILED ***");
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200364 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100365 ReturnCode |= ErrorUnknown;
366 }
367 }
368 try
369 {
370 transport.Close();
371 }
372 catch (Exception ex)
373 {
374 Console.WriteLine("Error while closing transport");
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200375 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100376 }
377 done = true;
378 }
379 }
380
381 internal static void PrintOptionsHelp()
382 {
383 Console.WriteLine("Client options:");
384 Console.WriteLine(" -u <URL>");
385 Console.WriteLine(" -t <# of threads to run> default = 1");
386 Console.WriteLine(" -n <# of iterations> per thread");
387 Console.WriteLine(" --pipe=<pipe name>");
388 Console.WriteLine(" --host=<IP address>");
389 Console.WriteLine(" --port=<port number>");
390 Console.WriteLine(" --transport=<transport name> one of buffered,framed (defaults to none)");
391 Console.WriteLine(" --protocol=<protocol name> one of compact,json (defaults to binary)");
392 Console.WriteLine(" --ssl");
393 Console.WriteLine();
394 }
395
Jens Geyer71569402021-11-13 23:51:16 +0100396 public static async Task<int> Execute(List<string> args)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100397 {
398 try
399 {
400 var param = new TestParams();
401
402 try
403 {
404 param.Parse(args);
405 }
406 catch (Exception ex)
407 {
408 Console.WriteLine("*** FAILED ***");
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200409 Console.WriteLine("Error while parsing arguments");
Jens Geyer5e37d572022-09-08 23:07:11 +0200410 Console.WriteLine("{0} {1}\nStack:\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100411 return ErrorUnknown;
412 }
413
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100414 //issue tests on separate threads simultaneously
Jens Geyerd2c28b32022-02-10 23:03:02 +0100415 var nThreads = Math.Max(param.numThreads, 1);
416 Console.Write("Starting {0} test thread(s) ", nThreads);
417 var tasks = new Task[nThreads];
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100418 var start = DateTime.Now;
Jens Geyerd2c28b32022-02-10 23:03:02 +0100419 var retcode = 0;
420 for (var i = 0; i < tasks.Length; ++i)
421 {
422 Console.Write('.');
423 tasks[i] = Task.Run(async () =>
424 {
425 var test = new ClientTest(param);
426 await test.Execute();
427 lock (tasks)
428 retcode |= test.ReturnCode;
429 });
430 }
431 Console.WriteLine(" OK");
Jens Geyer71569402021-11-13 23:51:16 +0100432 Task.WaitAll(tasks);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100433 Console.WriteLine("Total time: " + (DateTime.Now - start));
434 Console.WriteLine();
Jens Geyerd2c28b32022-02-10 23:03:02 +0100435 return retcode;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100436 }
437 catch (Exception outerEx)
438 {
439 Console.WriteLine("*** FAILED ***");
440 Console.WriteLine("Unexpected error");
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200441 Console.WriteLine(outerEx.Message + "\n" + outerEx.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100442 return ErrorUnknown;
443 }
444 }
445
446 public static string BytesToHex(byte[] data)
447 {
448 return BitConverter.ToString(data).Replace("-", string.Empty);
449 }
450
Jens Geyerbd1a2732019-06-26 22:52:44 +0200451
452 public enum BinaryTestSize
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100453 {
Jens Geyerbd1a2732019-06-26 22:52:44 +0200454 Empty, // Edge case: the zero-length empty binary
455 Normal, // Fairly small array of usual size (256 bytes)
456 Large, // Large writes/reads may cause range check errors
457 PipeWriteLimit, // Windows Limit: Pipe write operations across a network are limited to 65,535 bytes per write.
Jens Geyer50806452019-11-23 01:55:58 +0100458 FifteenMB // that's quite a bit of data
Jens Geyerbd1a2732019-06-26 22:52:44 +0200459 };
460
461 public static byte[] PrepareTestData(bool randomDist, BinaryTestSize testcase)
462 {
Jens Geyer261cad32019-11-20 19:03:14 +0100463 int amount;
Jens Geyerbd1a2732019-06-26 22:52:44 +0200464 switch (testcase)
465 {
466 case BinaryTestSize.Empty:
467 amount = 0;
468 break;
469 case BinaryTestSize.Normal:
470 amount = 0x100;
471 break;
472 case BinaryTestSize.Large:
473 amount = 0x8000 + 128;
474 break;
475 case BinaryTestSize.PipeWriteLimit:
476 amount = 0xFFFF + 128;
477 break;
Jens Geyer50806452019-11-23 01:55:58 +0100478 case BinaryTestSize.FifteenMB:
479 amount = 15 * 1024 * 1024;
Jens Geyerbd1a2732019-06-26 22:52:44 +0200480 break;
481 default:
Jens Geyer2b2ea622021-04-09 22:55:11 +0200482 throw new ArgumentException("invalid argument",nameof(testcase));
Jens Geyerbd1a2732019-06-26 22:52:44 +0200483 }
484
485 var retval = new byte[amount];
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100486
487 // linear distribution, unless random is requested
488 if (!randomDist)
489 {
Jens Geyerbd1a2732019-06-26 22:52:44 +0200490 for (var i = 0; i < retval.Length; ++i)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100491 {
492 retval[i] = (byte)i;
493 }
494 return retval;
495 }
496
497 // random distribution
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100498 var rnd = new Random();
Jens Geyerbd1a2732019-06-26 22:52:44 +0200499 for (var i = 1; i < retval.Length; ++i)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100500 {
Jens Geyerbd1a2732019-06-26 22:52:44 +0200501 retval[i] = (byte)rnd.Next(0x100);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100502 }
503 return retval;
504 }
505
Jens Geyerd2c28b32022-02-10 23:03:02 +0100506 private static CancellationToken MakeTimeoutToken(int msec = 15_000)
Jens Geyer1b770f22019-03-12 01:19:43 +0100507 {
508 var token = new CancellationTokenSource(msec);
509 return token.Token;
510 }
511
Jens Geyer2b2ea622021-04-09 22:55:11 +0200512 public static async Task<int> ExecuteClientTest(ThriftTest.Client client)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100513 {
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100514 var returnCode = 0;
515
516 Console.Write("testVoid()");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200517 await client.testVoid(MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100518 Console.WriteLine(" = void");
519
520 Console.Write("testString(\"Test\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200521 var s = await client.testString("Test", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100522 Console.WriteLine(" = \"" + s + "\"");
523 if ("Test" != s)
524 {
525 Console.WriteLine("*** FAILED ***");
526 returnCode |= ErrorBaseTypes;
527 }
528
529 Console.Write("testBool(true)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200530 var t = await client.testBool((bool)true, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100531 Console.WriteLine(" = " + t);
532 if (!t)
533 {
534 Console.WriteLine("*** FAILED ***");
535 returnCode |= ErrorBaseTypes;
536 }
537 Console.Write("testBool(false)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200538 var f = await client.testBool((bool)false, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100539 Console.WriteLine(" = " + f);
540 if (f)
541 {
542 Console.WriteLine("*** FAILED ***");
543 returnCode |= ErrorBaseTypes;
544 }
545
546 Console.Write("testByte(1)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200547 var i8 = await client.testByte((sbyte)1, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100548 Console.WriteLine(" = " + i8);
549 if (1 != i8)
550 {
551 Console.WriteLine("*** FAILED ***");
552 returnCode |= ErrorBaseTypes;
553 }
554
555 Console.Write("testI32(-1)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200556 var i32 = await client.testI32(-1, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100557 Console.WriteLine(" = " + i32);
558 if (-1 != i32)
559 {
560 Console.WriteLine("*** FAILED ***");
561 returnCode |= ErrorBaseTypes;
562 }
563
564 Console.Write("testI64(-34359738368)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200565 var i64 = await client.testI64(-34359738368, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100566 Console.WriteLine(" = " + i64);
567 if (-34359738368 != i64)
568 {
569 Console.WriteLine("*** FAILED ***");
570 returnCode |= ErrorBaseTypes;
571 }
572
573 // TODO: Validate received message
574 Console.Write("testDouble(5.325098235)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200575 var dub = await client.testDouble(5.325098235, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100576 Console.WriteLine(" = " + dub);
577 if (5.325098235 != dub)
578 {
579 Console.WriteLine("*** FAILED ***");
580 returnCode |= ErrorBaseTypes;
581 }
582 Console.Write("testDouble(-0.000341012439638598279)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200583 dub = await client.testDouble(-0.000341012439638598279, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100584 Console.WriteLine(" = " + dub);
585 if (-0.000341012439638598279 != dub)
586 {
587 Console.WriteLine("*** FAILED ***");
588 returnCode |= ErrorBaseTypes;
589 }
590
Jens Geyer62445c12022-06-29 00:00:00 +0200591 // testUuid()
592 var uuidOut = new Guid("{00112233-4455-6677-8899-AABBCCDDEEFF}");
593 Console.Write("testUuid({0})", uuidOut);
594 try
595 {
596 var uuidIn = await client.testUuid(uuidOut, MakeTimeoutToken());
597 Console.WriteLine(" = {0}", uuidIn);
598 if (!uuidIn.Equals(uuidOut))
599 {
600 Console.WriteLine("*** FAILED ***");
601 returnCode |= ErrorBaseTypes;
602 }
603 }
604 catch (Thrift.TApplicationException ex)
605 {
606 Console.WriteLine("*** FAILED ***");
607 returnCode |= ErrorBaseTypes;
608 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
609 }
610
Jens Geyerbd1a2732019-06-26 22:52:44 +0200611 // testBinary()
Jens Geyer62445c12022-06-29 00:00:00 +0200612 foreach (BinaryTestSize binTestCase in Enum.GetValues(typeof(BinaryTestSize)))
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100613 {
Jens Geyerbd1a2732019-06-26 22:52:44 +0200614 var binOut = PrepareTestData(true, binTestCase);
615
616 Console.Write("testBinary({0} bytes)", binOut.Length);
617 try
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100618 {
Jens Geyer2b2ea622021-04-09 22:55:11 +0200619 var binIn = await client.testBinary(binOut, MakeTimeoutToken());
Jens Geyerbd1a2732019-06-26 22:52:44 +0200620 Console.WriteLine(" = {0} bytes", binIn.Length);
621 if (binIn.Length != binOut.Length)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100622 {
623 Console.WriteLine("*** FAILED ***");
624 returnCode |= ErrorBaseTypes;
625 }
Jens Geyerbd1a2732019-06-26 22:52:44 +0200626 for (var ofs = 0; ofs < Math.Min(binIn.Length, binOut.Length); ++ofs)
627 {
628 if (binIn[ofs] != binOut[ofs])
629 {
630 Console.WriteLine("*** FAILED ***");
631 returnCode |= ErrorBaseTypes;
632 }
633 }
634 }
635 catch (Thrift.TApplicationException ex)
636 {
637 Console.WriteLine("*** FAILED ***");
638 returnCode |= ErrorBaseTypes;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200639 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyerbd1a2732019-06-26 22:52:44 +0200640 }
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100641 }
642
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200643 // CrazyNesting
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100644 Console.WriteLine("Test CrazyNesting");
645 var one = new CrazyNesting();
646 var two = new CrazyNesting();
647 one.String_field = "crazy";
648 two.String_field = "crazy";
649 one.Binary_field = new byte[] { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF };
650 two.Binary_field = new byte[10] { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF };
651 if (typeof(CrazyNesting).GetMethod("Equals")?.DeclaringType == typeof(CrazyNesting))
652 {
653 if (!one.Equals(two))
654 {
655 Console.WriteLine("*** FAILED ***");
656 returnCode |= ErrorContainers;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100657 }
658 }
659
660 // TODO: Validate received message
661 Console.Write("testStruct({\"Zero\", 1, -3, -5})");
Jens Geyer261cad32019-11-20 19:03:14 +0100662 var o = new Xtruct
663 {
664 String_thing = "Zero",
665 Byte_thing = (sbyte)1,
666 I32_thing = -3,
667 I64_thing = -5
668 };
Jens Geyer2b2ea622021-04-09 22:55:11 +0200669 var i = await client.testStruct(o, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100670 Console.WriteLine(" = {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}");
671
672 // TODO: Validate received message
673 Console.Write("testNest({1, {\"Zero\", 1, -3, -5}, 5})");
Jens Geyer261cad32019-11-20 19:03:14 +0100674 var o2 = new Xtruct2
675 {
676 Byte_thing = (sbyte)1,
677 Struct_thing = o,
678 I32_thing = 5
679 };
Jens Geyer3cac3202022-01-31 18:04:35 +0100680 Xtruct2 i2 = await client.testNest(o2, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100681 i = i2.Struct_thing;
Jens Geyer3cac3202022-01-31 18:04:35 +0100682 Console.WriteLine(" = {" + i2.Byte_thing + ", {\""
683 + (i?.String_thing ?? "<null>") + "\", "
684 + (i?.Byte_thing ?? 0) + ", "
685 + (i?.I32_thing ?? 0) + ", "
686 + (i?.I64_thing ?? 0) + "}, "
687 + i2.I32_thing + "}");
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100688
689 var mapout = new Dictionary<int, int>();
690 for (var j = 0; j < 5; j++)
691 {
692 mapout[j] = j - 10;
693 }
694 Console.Write("testMap({");
Jens Geyer71569402021-11-13 23:51:16 +0100695 Console.Write(string.Join(", ", mapout.Select((pair) => { return pair.Key + " => " + pair.Value; })));
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100696 Console.Write("})");
697
Jens Geyer2b2ea622021-04-09 22:55:11 +0200698 var mapin = await client.testMap(mapout, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100699
700 Console.Write(" = {");
Jens Geyer71569402021-11-13 23:51:16 +0100701 Console.Write(string.Join(", ", mapin.Select((pair) => { return pair.Key + " => " + pair.Value; })));
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100702 Console.WriteLine("}");
703
704 // TODO: Validate received message
705 var listout = new List<int>();
706 for (var j = -2; j < 3; j++)
707 {
708 listout.Add(j);
709 }
710 Console.Write("testList({");
Jens Geyer71569402021-11-13 23:51:16 +0100711 Console.Write(string.Join(", ", listout));
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100712 Console.Write("})");
713
Jens Geyer2b2ea622021-04-09 22:55:11 +0200714 var listin = await client.testList(listout, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100715
716 Console.Write(" = {");
Jens Geyer71569402021-11-13 23:51:16 +0100717 Console.Write(string.Join(", ", listin));
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100718 Console.WriteLine("}");
719
720 //set
721 // TODO: Validate received message
Jens Geyer3cac3202022-01-31 18:04:35 +0100722 var setout = new HashSet<int>();
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100723 for (var j = -2; j < 3; j++)
724 {
725 setout.Add(j);
726 }
727 Console.Write("testSet({");
Jens Geyer71569402021-11-13 23:51:16 +0100728 Console.Write(string.Join(", ", setout));
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100729 Console.Write("})");
730
Jens Geyer2b2ea622021-04-09 22:55:11 +0200731 var setin = await client.testSet(setout, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100732
733 Console.Write(" = {");
Jens Geyer71569402021-11-13 23:51:16 +0100734 Console.Write(string.Join(", ", setin));
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100735 Console.WriteLine("}");
736
737
738 Console.Write("testEnum(ONE)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200739 var ret = await client.testEnum(Numberz.ONE, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100740 Console.WriteLine(" = " + ret);
741 if (Numberz.ONE != ret)
742 {
743 Console.WriteLine("*** FAILED ***");
744 returnCode |= ErrorStructs;
745 }
746
747 Console.Write("testEnum(TWO)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200748 ret = await client.testEnum(Numberz.TWO, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100749 Console.WriteLine(" = " + ret);
750 if (Numberz.TWO != ret)
751 {
752 Console.WriteLine("*** FAILED ***");
753 returnCode |= ErrorStructs;
754 }
755
756 Console.Write("testEnum(THREE)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200757 ret = await client.testEnum(Numberz.THREE, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100758 Console.WriteLine(" = " + ret);
759 if (Numberz.THREE != ret)
760 {
761 Console.WriteLine("*** FAILED ***");
762 returnCode |= ErrorStructs;
763 }
764
765 Console.Write("testEnum(FIVE)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200766 ret = await client.testEnum(Numberz.FIVE, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100767 Console.WriteLine(" = " + ret);
768 if (Numberz.FIVE != ret)
769 {
770 Console.WriteLine("*** FAILED ***");
771 returnCode |= ErrorStructs;
772 }
773
774 Console.Write("testEnum(EIGHT)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200775 ret = await client.testEnum(Numberz.EIGHT, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100776 Console.WriteLine(" = " + ret);
777 if (Numberz.EIGHT != ret)
778 {
779 Console.WriteLine("*** FAILED ***");
780 returnCode |= ErrorStructs;
781 }
782
783 Console.Write("testTypedef(309858235082523)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200784 var uid = await client.testTypedef(309858235082523L, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100785 Console.WriteLine(" = " + uid);
786 if (309858235082523L != uid)
787 {
788 Console.WriteLine("*** FAILED ***");
789 returnCode |= ErrorStructs;
790 }
791
792 // TODO: Validate received message
793 Console.Write("testMapMap(1)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200794 var mm = await client.testMapMap(1, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100795 Console.Write(" = {");
796 foreach (var key in mm.Keys)
797 {
798 Console.Write(key + " => {");
799 var m2 = mm[key];
800 foreach (var k2 in m2.Keys)
801 {
802 Console.Write(k2 + " => " + m2[k2] + ", ");
803 }
804 Console.Write("}, ");
805 }
806 Console.WriteLine("}");
807
808 // TODO: Validate received message
Jens Geyer261cad32019-11-20 19:03:14 +0100809 var insane = new Insanity
810 {
811 UserMap = new Dictionary<Numberz, long>
812 {
813 [Numberz.FIVE] = 5000L
814 }
815 };
816 var truck = new Xtruct
817 {
818 String_thing = "Truck",
819 Byte_thing = (sbyte)8,
820 I32_thing = 8,
821 I64_thing = 8
822 };
823 insane.Xtructs = new List<Xtruct>
824 {
825 truck
826 };
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100827 Console.Write("testInsanity()");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200828 var whoa = await client.testInsanity(insane, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100829 Console.Write(" = {");
830 foreach (var key in whoa.Keys)
831 {
832 var val = whoa[key];
833 Console.Write(key + " => {");
834
835 foreach (var k2 in val.Keys)
836 {
837 var v2 = val[k2];
838
839 Console.Write(k2 + " => {");
840 var userMap = v2.UserMap;
841
842 Console.Write("{");
843 if (userMap != null)
844 {
845 foreach (var k3 in userMap.Keys)
846 {
847 Console.Write(k3 + " => " + userMap[k3] + ", ");
848 }
849 }
850 else
851 {
852 Console.Write("null");
853 }
854 Console.Write("}, ");
855
856 var xtructs = v2.Xtructs;
857
858 Console.Write("{");
859 if (xtructs != null)
860 {
861 foreach (var x in xtructs)
862 {
863 Console.Write("{\"" + x.String_thing + "\", " + x.Byte_thing + ", " + x.I32_thing + ", " + x.I32_thing + "}, ");
864 }
865 }
866 else
867 {
868 Console.Write("null");
869 }
870 Console.Write("}");
871
872 Console.Write("}, ");
873 }
874 Console.Write("}, ");
875 }
876 Console.WriteLine("}");
877
878 sbyte arg0 = 1;
879 var arg1 = 2;
880 var arg2 = long.MaxValue;
Jens Geyer261cad32019-11-20 19:03:14 +0100881 var multiDict = new Dictionary<short, string>
882 {
883 [1] = "one"
884 };
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100885
886 var tmpMultiDict = new List<string>();
887 foreach (var pair in multiDict)
888 tmpMultiDict.Add(pair.Key +" => "+ pair.Value);
889
890 var arg4 = Numberz.FIVE;
891 long arg5 = 5000000;
892 Console.Write("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + ",{" + string.Join(",", tmpMultiDict) + "}," + arg4 + "," + arg5 + ")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200893 var multiResponse = await client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100894 Console.Write(" = Xtruct(byte_thing:" + multiResponse.Byte_thing + ",String_thing:" + multiResponse.String_thing
895 + ",i32_thing:" + multiResponse.I32_thing + ",i64_thing:" + multiResponse.I64_thing + ")\n");
896
897 try
898 {
899 Console.WriteLine("testException(\"Xception\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200900 await client.testException("Xception", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100901 Console.WriteLine("*** FAILED ***");
902 returnCode |= ErrorExceptions;
903 }
904 catch (Xception ex)
905 {
906 if (ex.ErrorCode != 1001 || ex.Message != "Xception")
907 {
908 Console.WriteLine("*** FAILED ***");
909 returnCode |= ErrorExceptions;
910 }
911 }
912 catch (Exception ex)
913 {
914 Console.WriteLine("*** FAILED ***");
915 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200916 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100917 }
918 try
919 {
920 Console.WriteLine("testException(\"TException\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200921 await client.testException("TException", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100922 Console.WriteLine("*** FAILED ***");
923 returnCode |= ErrorExceptions;
924 }
925 catch (Thrift.TException)
926 {
927 // OK
928 }
929 catch (Exception ex)
930 {
931 Console.WriteLine("*** FAILED ***");
932 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200933 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100934 }
935 try
936 {
937 Console.WriteLine("testException(\"ok\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200938 await client.testException("ok", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100939 // OK
940 }
941 catch (Exception ex)
942 {
943 Console.WriteLine("*** FAILED ***");
944 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200945 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100946 }
947
948 try
949 {
950 Console.WriteLine("testMultiException(\"Xception\", ...)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200951 await client.testMultiException("Xception", "ignore", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100952 Console.WriteLine("*** FAILED ***");
953 returnCode |= ErrorExceptions;
954 }
955 catch (Xception ex)
956 {
957 if (ex.ErrorCode != 1001 || ex.Message != "This is an Xception")
958 {
959 Console.WriteLine("*** FAILED ***");
960 returnCode |= ErrorExceptions;
961 }
962 }
963 catch (Exception ex)
964 {
965 Console.WriteLine("*** FAILED ***");
966 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200967 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100968 }
969 try
970 {
971 Console.WriteLine("testMultiException(\"Xception2\", ...)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200972 await client.testMultiException("Xception2", "ignore", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100973 Console.WriteLine("*** FAILED ***");
974 returnCode |= ErrorExceptions;
975 }
976 catch (Xception2 ex)
977 {
Jens Geyer3cac3202022-01-31 18:04:35 +0100978 if (ex.ErrorCode != 2002 || ex.Struct_thing?.String_thing != "This is an Xception2")
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100979 {
980 Console.WriteLine("*** FAILED ***");
981 returnCode |= ErrorExceptions;
982 }
983 }
984 catch (Exception ex)
985 {
986 Console.WriteLine("*** FAILED ***");
987 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200988 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100989 }
990 try
991 {
992 Console.WriteLine("testMultiException(\"success\", \"OK\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200993 if ("OK" != (await client.testMultiException("success", "OK", MakeTimeoutToken())).String_thing)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100994 {
995 Console.WriteLine("*** FAILED ***");
996 returnCode |= ErrorExceptions;
997 }
998 }
999 catch (Exception ex)
1000 {
1001 Console.WriteLine("*** FAILED ***");
1002 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +02001003 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001004 }
1005
Jens Geyerb11f63c2019-03-14 21:12:38 +01001006 Console.WriteLine("Test Oneway(1)");
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001007 var sw = new Stopwatch();
1008 sw.Start();
Jens Geyer2b2ea622021-04-09 22:55:11 +02001009 await client.testOneway(1, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001010 sw.Stop();
1011 if (sw.ElapsedMilliseconds > 1000)
1012 {
1013 Console.WriteLine("*** FAILED ***");
1014 returnCode |= ErrorBaseTypes;
1015 }
1016
1017 Console.Write("Test Calltime()");
1018 var times = 50;
1019 sw.Reset();
1020 sw.Start();
Jens Geyer1b770f22019-03-12 01:19:43 +01001021 var token = MakeTimeoutToken(20000);
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001022 for (var k = 0; k < times; ++k)
Jens Geyer2b2ea622021-04-09 22:55:11 +02001023 await client.testVoid(token);
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001024 sw.Stop();
1025 Console.WriteLine(" = {0} ms a testVoid() call", sw.ElapsedMilliseconds / times);
1026 return returnCode;
1027 }
1028 }
1029}