blob: 74867122951ba332268e6d59de52bc5dfb49a49f [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
20
Jens Geyeraa0c8b32019-01-28 23:27:45 +010021using System;
22using System.Collections.Generic;
23using System.Diagnostics;
24using System.IO;
25using System.Linq;
26using System.Net;
27using System.Reflection;
28using System.Security.Authentication;
29using System.Security.Cryptography.X509Certificates;
30using System.ServiceModel;
31using System.Text;
32using System.Threading;
33using System.Threading.Tasks;
Jens Geyereacd1d42019-11-20 19:03:14 +010034using Thrift;
Jens Geyeraa0c8b32019-01-28 23:27:45 +010035using Thrift.Collections;
36using Thrift.Protocol;
37using Thrift.Transport;
38using Thrift.Transport.Client;
39
40namespace ThriftTest
41{
Jens Geyeradde44b2019-02-05 01:00:02 +010042 internal enum ProtocolChoice
43 {
44 Binary,
45 Compact,
46 Json
47 }
48
49 // it does not make much sense to use buffered when we already use framed
50 internal enum LayeredChoice
51 {
52 None,
53 Buffered,
54 Framed
55 }
56
Jens Geyeradde44b2019-02-05 01:00:02 +010057 internal enum TransportChoice
58 {
59 Socket,
60 TlsSocket,
Jens Geyer96c61132019-06-14 22:39:56 +020061 Http,
Jens Geyeradde44b2019-02-05 01:00:02 +010062 NamedPipe
63 }
64
Jens Geyeraa0c8b32019-01-28 23:27:45 +010065 public class TestClient
66 {
67 private class TestParams
68 {
69 public int numIterations = 1;
Jens Geyer22c412e2019-03-12 01:06:25 +010070 public string host = "localhost";
Jens Geyeraa0c8b32019-01-28 23:27:45 +010071 public int port = 9090;
72 public int numThreads = 1;
Jens Geyer98a23252022-01-09 16:50:52 +010073 public string url = string.Empty;
74 public string pipe = string.Empty;
Jens Geyeradde44b2019-02-05 01:00:02 +010075 public LayeredChoice layered = LayeredChoice.None;
76 public ProtocolChoice protocol = ProtocolChoice.Binary;
77 public TransportChoice transport = TransportChoice.Socket;
Jens Geyer98a23252022-01-09 16:50:52 +010078 private readonly TConfiguration Configuration = new();
Jens Geyeraa0c8b32019-01-28 23:27:45 +010079
Jens Geyerbd1a2732019-06-26 22:52:44 +020080 internal void Parse(List<string> args)
Jens Geyeraa0c8b32019-01-28 23:27:45 +010081 {
82 for (var i = 0; i < args.Count; ++i)
83 {
84 if (args[i] == "-u")
85 {
86 url = args[++i];
Jens Geyer96c61132019-06-14 22:39:56 +020087 transport = TransportChoice.Http;
Jens Geyeraa0c8b32019-01-28 23:27:45 +010088 }
89 else if (args[i] == "-n")
90 {
91 numIterations = Convert.ToInt32(args[++i]);
92 }
93 else if (args[i].StartsWith("--pipe="))
94 {
Jens Geyer4115e952023-11-21 23:00:01 +010095 pipe = args[i].Substring(args[i].IndexOf('=') + 1);
Jens Geyeradde44b2019-02-05 01:00:02 +010096 transport = TransportChoice.NamedPipe;
Jens Geyeraa0c8b32019-01-28 23:27:45 +010097 }
98 else if (args[i].StartsWith("--host="))
99 {
100 // check there for ipaddress
Jens Geyer4115e952023-11-21 23:00:01 +0100101 host = args[i].Substring(args[i].IndexOf('=') + 1);
Jens Geyeradde44b2019-02-05 01:00:02 +0100102 if (transport != TransportChoice.TlsSocket)
103 transport = TransportChoice.Socket;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100104 }
105 else if (args[i].StartsWith("--port="))
106 {
Jens Geyer4115e952023-11-21 23:00:01 +0100107 port = int.Parse(args[i].Substring(args[i].IndexOf('=') + 1));
Jens Geyeradde44b2019-02-05 01:00:02 +0100108 if (transport != TransportChoice.TlsSocket)
109 transport = TransportChoice.Socket;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100110 }
111 else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered")
112 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100113 layered = LayeredChoice.Buffered;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100114 }
115 else if (args[i] == "-f" || args[i] == "--framed" || args[i] == "--transport=framed")
116 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100117 layered = LayeredChoice.Framed;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100118 }
119 else if (args[i] == "-t")
120 {
121 numThreads = Convert.ToInt32(args[++i]);
122 }
123 else if (args[i] == "--binary" || args[i] == "--protocol=binary")
124 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100125 protocol = ProtocolChoice.Binary;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100126 }
127 else if (args[i] == "--compact" || args[i] == "--protocol=compact")
128 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100129 protocol = ProtocolChoice.Compact;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100130 }
131 else if (args[i] == "--json" || args[i] == "--protocol=json")
132 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100133 protocol = ProtocolChoice.Json;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100134 }
135 else if (args[i] == "--ssl")
136 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100137 transport = TransportChoice.TlsSocket;
138 }
139 else if (args[i] == "--help")
140 {
141 PrintOptionsHelp();
142 return;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100143 }
144 else
145 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100146 Console.WriteLine("Invalid argument: {0}", args[i]);
147 PrintOptionsHelp();
148 return;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100149 }
150 }
Jens Geyeradde44b2019-02-05 01:00:02 +0100151
152 switch (transport)
153 {
154 case TransportChoice.Socket:
155 Console.WriteLine("Using socket transport");
156 break;
157 case TransportChoice.TlsSocket:
158 Console.WriteLine("Using encrypted transport");
159 break;
Jens Geyer96c61132019-06-14 22:39:56 +0200160 case TransportChoice.Http:
161 Console.WriteLine("Using HTTP transport");
162 break;
Jens Geyeradde44b2019-02-05 01:00:02 +0100163 case TransportChoice.NamedPipe:
164 Console.WriteLine("Using named pipes transport");
165 break;
166 default: // unhandled case
167 Debug.Assert(false);
168 break;
169 }
170
171 switch (layered)
172 {
173 case LayeredChoice.Framed:
174 Console.WriteLine("Using framed transport");
175 break;
176 case LayeredChoice.Buffered:
177 Console.WriteLine("Using buffered transport");
178 break;
179 default: // unhandled case?
180 Debug.Assert(layered == LayeredChoice.None);
181 break;
182 }
183
184 switch (protocol)
185 {
186 case ProtocolChoice.Binary:
187 Console.WriteLine("Using binary protocol");
188 break;
189 case ProtocolChoice.Compact:
190 Console.WriteLine("Using compact protocol");
191 break;
192 case ProtocolChoice.Json:
193 Console.WriteLine("Using JSON protocol");
194 break;
195 default: // unhandled case?
196 Debug.Assert(false);
197 break;
198 }
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100199 }
200
201 private static X509Certificate2 GetClientCert()
202 {
203 var clientCertName = "client.p12";
204 var possiblePaths = new List<string>
205 {
206 "../../../keys/",
207 "../../keys/",
208 "../keys/",
209 "keys/",
210 };
211
Jens Geyer98a23252022-01-09 16:50:52 +0100212 var existingPath = string.Empty;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100213 foreach (var possiblePath in possiblePaths)
214 {
215 var path = Path.GetFullPath(possiblePath + clientCertName);
216 if (File.Exists(path))
217 {
218 existingPath = path;
219 break;
220 }
221 }
222
223 if (string.IsNullOrEmpty(existingPath))
224 {
225 throw new FileNotFoundException($"Cannot find file: {clientCertName}");
226 }
Jens Geyerbd1a2732019-06-26 22:52:44 +0200227
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100228 var cert = new X509Certificate2(existingPath, "thrift");
229
230 return cert;
231 }
Jens Geyerbd1a2732019-06-26 22:52:44 +0200232
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100233 public TTransport CreateTransport()
234 {
Jens Geyer96c61132019-06-14 22:39:56 +0200235 // endpoint transport
Jens Geyer98a23252022-01-09 16:50:52 +0100236 TTransport trans;
Jens Geyerbd1a2732019-06-26 22:52:44 +0200237 switch (transport)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100238 {
Jens Geyer96c61132019-06-14 22:39:56 +0200239 case TransportChoice.Http:
240 Debug.Assert(url != null);
Jens Geyereacd1d42019-11-20 19:03:14 +0100241 trans = new THttpTransport(new Uri(url), Configuration);
Jens Geyer96c61132019-06-14 22:39:56 +0200242 break;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100243
Jens Geyer96c61132019-06-14 22:39:56 +0200244 case TransportChoice.NamedPipe:
245 Debug.Assert(pipe != null);
Jens Geyereacd1d42019-11-20 19:03:14 +0100246 trans = new TNamedPipeTransport(pipe,Configuration);
Jens Geyer96c61132019-06-14 22:39:56 +0200247 break;
Jens Geyeradde44b2019-02-05 01:00:02 +0100248
Jens Geyer96c61132019-06-14 22:39:56 +0200249 case TransportChoice.TlsSocket:
250 var cert = GetClientCert();
251 if (cert == null || !cert.HasPrivateKey)
252 {
253 throw new InvalidOperationException("Certificate doesn't contain private key");
254 }
Jens Geyerbd1a2732019-06-26 22:52:44 +0200255
Jens Geyereacd1d42019-11-20 19:03:14 +0100256 trans = new TTlsSocketTransport(host, port, Configuration, 0,
257 cert,
Jens Geyer96c61132019-06-14 22:39:56 +0200258 (sender, certificate, chain, errors) => true,
Jens Geyera06eedc2023-11-16 23:23:04 +0100259 null);
Jens Geyer96c61132019-06-14 22:39:56 +0200260 break;
Jens Geyeradde44b2019-02-05 01:00:02 +0100261
Jens Geyer96c61132019-06-14 22:39:56 +0200262 case TransportChoice.Socket:
263 default:
Jens Geyereacd1d42019-11-20 19:03:14 +0100264 trans = new TSocketTransport(host, port, Configuration);
Jens Geyer96c61132019-06-14 22:39:56 +0200265 break;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100266 }
267
Jens Geyer96c61132019-06-14 22:39:56 +0200268
269 // layered transport
Jens Geyerbd1a2732019-06-26 22:52:44 +0200270 switch (layered)
Jens Geyer96c61132019-06-14 22:39:56 +0200271 {
272 case LayeredChoice.Buffered:
273 trans = new TBufferedTransport(trans);
274 break;
275 case LayeredChoice.Framed:
276 trans = new TFramedTransport(trans);
277 break;
278 default:
279 Debug.Assert(layered == LayeredChoice.None);
280 break;
281 }
282
283 return trans;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100284 }
285
286 public TProtocol CreateProtocol(TTransport transport)
287 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100288 switch (protocol)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100289 {
Jens Geyeradde44b2019-02-05 01:00:02 +0100290 case ProtocolChoice.Compact:
291 return new TCompactProtocol(transport);
292 case ProtocolChoice.Json:
293 return new TJsonProtocol(transport);
294 case ProtocolChoice.Binary:
295 default:
296 return new TBinaryProtocol(transport);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100297 }
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100298 }
299 }
300
301
302 private const int ErrorBaseTypes = 1;
303 private const int ErrorStructs = 2;
304 private const int ErrorContainers = 4;
305 private const int ErrorExceptions = 8;
306 private const int ErrorUnknown = 64;
307
308 private class ClientTest
309 {
310 private readonly TTransport transport;
311 private readonly ThriftTest.Client client;
312 private readonly int numIterations;
313 private bool done;
314
315 public int ReturnCode { get; set; }
316
317 public ClientTest(TestParams param)
318 {
319 transport = param.CreateTransport();
320 client = new ThriftTest.Client(param.CreateProtocol(transport));
321 numIterations = param.numIterations;
322 }
323
Jens Geyer71569402021-11-13 23:51:16 +0100324 public async Task Execute()
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100325 {
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100326 if (done)
327 {
328 Console.WriteLine("Execute called more than once");
329 throw new InvalidOperationException();
330 }
331
332 for (var i = 0; i < numIterations; i++)
333 {
334 try
335 {
336 if (!transport.IsOpen)
Jens Geyer71569402021-11-13 23:51:16 +0100337 await transport.OpenAsync(MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100338 }
339 catch (TTransportException ex)
340 {
341 Console.WriteLine("*** FAILED ***");
342 Console.WriteLine("Connect failed: " + ex.Message);
343 ReturnCode |= ErrorUnknown;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200344 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100345 continue;
346 }
347 catch (Exception ex)
348 {
349 Console.WriteLine("*** FAILED ***");
350 Console.WriteLine("Connect failed: " + ex.Message);
351 ReturnCode |= ErrorUnknown;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200352 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100353 continue;
354 }
355
356 try
357 {
Jens Geyer71569402021-11-13 23:51:16 +0100358 ReturnCode |= await ExecuteClientTest(client);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100359 }
360 catch (Exception ex)
361 {
362 Console.WriteLine("*** FAILED ***");
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200363 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100364 ReturnCode |= ErrorUnknown;
365 }
366 }
367 try
368 {
369 transport.Close();
370 }
371 catch (Exception ex)
372 {
373 Console.WriteLine("Error while closing transport");
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200374 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100375 }
376 done = true;
377 }
378 }
379
380 internal static void PrintOptionsHelp()
381 {
382 Console.WriteLine("Client options:");
383 Console.WriteLine(" -u <URL>");
384 Console.WriteLine(" -t <# of threads to run> default = 1");
385 Console.WriteLine(" -n <# of iterations> per thread");
386 Console.WriteLine(" --pipe=<pipe name>");
387 Console.WriteLine(" --host=<IP address>");
388 Console.WriteLine(" --port=<port number>");
389 Console.WriteLine(" --transport=<transport name> one of buffered,framed (defaults to none)");
390 Console.WriteLine(" --protocol=<protocol name> one of compact,json (defaults to binary)");
391 Console.WriteLine(" --ssl");
392 Console.WriteLine();
393 }
394
Jens Geyer4115e952023-11-21 23:00:01 +0100395 public static Task<int> Execute(List<string> args)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100396 {
397 try
398 {
399 var param = new TestParams();
400
401 try
402 {
403 param.Parse(args);
404 }
405 catch (Exception ex)
406 {
407 Console.WriteLine("*** FAILED ***");
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200408 Console.WriteLine("Error while parsing arguments");
Jens Geyer5e37d572022-09-08 23:07:11 +0200409 Console.WriteLine("{0} {1}\nStack:\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
Jens Geyer4115e952023-11-21 23:00:01 +0100410 return Task.FromResult(ErrorUnknown);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100411 }
412
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100413 //issue tests on separate threads simultaneously
Jens Geyerd2c28b32022-02-10 23:03:02 +0100414 var nThreads = Math.Max(param.numThreads, 1);
415 Console.Write("Starting {0} test thread(s) ", nThreads);
416 var tasks = new Task[nThreads];
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100417 var start = DateTime.Now;
Jens Geyerd2c28b32022-02-10 23:03:02 +0100418 var retcode = 0;
419 for (var i = 0; i < tasks.Length; ++i)
420 {
421 Console.Write('.');
422 tasks[i] = Task.Run(async () =>
423 {
424 var test = new ClientTest(param);
425 await test.Execute();
426 lock (tasks)
427 retcode |= test.ReturnCode;
428 });
429 }
430 Console.WriteLine(" OK");
Jens Geyer71569402021-11-13 23:51:16 +0100431 Task.WaitAll(tasks);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100432 Console.WriteLine("Total time: " + (DateTime.Now - start));
433 Console.WriteLine();
Jens Geyer4115e952023-11-21 23:00:01 +0100434 return Task.FromResult(retcode);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100435 }
436 catch (Exception outerEx)
437 {
438 Console.WriteLine("*** FAILED ***");
439 Console.WriteLine("Unexpected error");
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200440 Console.WriteLine(outerEx.Message + "\n" + outerEx.StackTrace);
Jens Geyer4115e952023-11-21 23:00:01 +0100441 return Task.FromResult(ErrorUnknown);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100442 }
443 }
444
445 public static string BytesToHex(byte[] data)
446 {
447 return BitConverter.ToString(data).Replace("-", string.Empty);
448 }
449
Jens Geyerbd1a2732019-06-26 22:52:44 +0200450
451 public enum BinaryTestSize
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100452 {
Jens Geyerbd1a2732019-06-26 22:52:44 +0200453 Empty, // Edge case: the zero-length empty binary
454 Normal, // Fairly small array of usual size (256 bytes)
455 Large, // Large writes/reads may cause range check errors
456 PipeWriteLimit, // Windows Limit: Pipe write operations across a network are limited to 65,535 bytes per write.
Jens Geyer50806452019-11-23 01:55:58 +0100457 FifteenMB // that's quite a bit of data
Jens Geyerbd1a2732019-06-26 22:52:44 +0200458 };
459
460 public static byte[] PrepareTestData(bool randomDist, BinaryTestSize testcase)
461 {
Jens Geyer261cad32019-11-20 19:03:14 +0100462 int amount;
Jens Geyerbd1a2732019-06-26 22:52:44 +0200463 switch (testcase)
464 {
465 case BinaryTestSize.Empty:
466 amount = 0;
467 break;
468 case BinaryTestSize.Normal:
469 amount = 0x100;
470 break;
471 case BinaryTestSize.Large:
472 amount = 0x8000 + 128;
473 break;
474 case BinaryTestSize.PipeWriteLimit:
475 amount = 0xFFFF + 128;
476 break;
Jens Geyer50806452019-11-23 01:55:58 +0100477 case BinaryTestSize.FifteenMB:
478 amount = 15 * 1024 * 1024;
Jens Geyerbd1a2732019-06-26 22:52:44 +0200479 break;
480 default:
Jens Geyer2b2ea622021-04-09 22:55:11 +0200481 throw new ArgumentException("invalid argument",nameof(testcase));
Jens Geyerbd1a2732019-06-26 22:52:44 +0200482 }
483
484 var retval = new byte[amount];
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100485
486 // linear distribution, unless random is requested
487 if (!randomDist)
488 {
Jens Geyerbd1a2732019-06-26 22:52:44 +0200489 for (var i = 0; i < retval.Length; ++i)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100490 {
491 retval[i] = (byte)i;
492 }
493 return retval;
494 }
495
496 // random distribution
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100497 var rnd = new Random();
Jens Geyerbd1a2732019-06-26 22:52:44 +0200498 for (var i = 1; i < retval.Length; ++i)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100499 {
Jens Geyerbd1a2732019-06-26 22:52:44 +0200500 retval[i] = (byte)rnd.Next(0x100);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100501 }
502 return retval;
503 }
504
Jens Geyerd2c28b32022-02-10 23:03:02 +0100505 private static CancellationToken MakeTimeoutToken(int msec = 15_000)
Jens Geyer1b770f22019-03-12 01:19:43 +0100506 {
507 var token = new CancellationTokenSource(msec);
508 return token.Token;
509 }
510
Jens Geyer2b2ea622021-04-09 22:55:11 +0200511 public static async Task<int> ExecuteClientTest(ThriftTest.Client client)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100512 {
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100513 var returnCode = 0;
514
515 Console.Write("testVoid()");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200516 await client.testVoid(MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100517 Console.WriteLine(" = void");
518
519 Console.Write("testString(\"Test\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200520 var s = await client.testString("Test", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100521 Console.WriteLine(" = \"" + s + "\"");
522 if ("Test" != s)
523 {
524 Console.WriteLine("*** FAILED ***");
525 returnCode |= ErrorBaseTypes;
526 }
527
528 Console.Write("testBool(true)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200529 var t = await client.testBool((bool)true, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100530 Console.WriteLine(" = " + t);
531 if (!t)
532 {
533 Console.WriteLine("*** FAILED ***");
534 returnCode |= ErrorBaseTypes;
535 }
536 Console.Write("testBool(false)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200537 var f = await client.testBool((bool)false, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100538 Console.WriteLine(" = " + f);
539 if (f)
540 {
541 Console.WriteLine("*** FAILED ***");
542 returnCode |= ErrorBaseTypes;
543 }
544
545 Console.Write("testByte(1)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200546 var i8 = await client.testByte((sbyte)1, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100547 Console.WriteLine(" = " + i8);
548 if (1 != i8)
549 {
550 Console.WriteLine("*** FAILED ***");
551 returnCode |= ErrorBaseTypes;
552 }
553
554 Console.Write("testI32(-1)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200555 var i32 = await client.testI32(-1, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100556 Console.WriteLine(" = " + i32);
557 if (-1 != i32)
558 {
559 Console.WriteLine("*** FAILED ***");
560 returnCode |= ErrorBaseTypes;
561 }
562
563 Console.Write("testI64(-34359738368)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200564 var i64 = await client.testI64(-34359738368, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100565 Console.WriteLine(" = " + i64);
566 if (-34359738368 != i64)
567 {
568 Console.WriteLine("*** FAILED ***");
569 returnCode |= ErrorBaseTypes;
570 }
571
572 // TODO: Validate received message
573 Console.Write("testDouble(5.325098235)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200574 var dub = await client.testDouble(5.325098235, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100575 Console.WriteLine(" = " + dub);
576 if (5.325098235 != dub)
577 {
578 Console.WriteLine("*** FAILED ***");
579 returnCode |= ErrorBaseTypes;
580 }
581 Console.Write("testDouble(-0.000341012439638598279)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200582 dub = await client.testDouble(-0.000341012439638598279, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100583 Console.WriteLine(" = " + dub);
584 if (-0.000341012439638598279 != dub)
585 {
586 Console.WriteLine("*** FAILED ***");
587 returnCode |= ErrorBaseTypes;
588 }
589
Jens Geyer62445c12022-06-29 00:00:00 +0200590 // testUuid()
591 var uuidOut = new Guid("{00112233-4455-6677-8899-AABBCCDDEEFF}");
592 Console.Write("testUuid({0})", uuidOut);
593 try
594 {
595 var uuidIn = await client.testUuid(uuidOut, MakeTimeoutToken());
596 Console.WriteLine(" = {0}", uuidIn);
597 if (!uuidIn.Equals(uuidOut))
598 {
599 Console.WriteLine("*** FAILED ***");
600 returnCode |= ErrorBaseTypes;
601 }
602 }
603 catch (Thrift.TApplicationException ex)
604 {
605 Console.WriteLine("*** FAILED ***");
606 returnCode |= ErrorBaseTypes;
607 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
608 }
609
Jens Geyerbd1a2732019-06-26 22:52:44 +0200610 // testBinary()
Jens Geyer62445c12022-06-29 00:00:00 +0200611 foreach (BinaryTestSize binTestCase in Enum.GetValues(typeof(BinaryTestSize)))
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100612 {
Jens Geyerbd1a2732019-06-26 22:52:44 +0200613 var binOut = PrepareTestData(true, binTestCase);
614
615 Console.Write("testBinary({0} bytes)", binOut.Length);
616 try
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100617 {
Jens Geyer2b2ea622021-04-09 22:55:11 +0200618 var binIn = await client.testBinary(binOut, MakeTimeoutToken());
Jens Geyerbd1a2732019-06-26 22:52:44 +0200619 Console.WriteLine(" = {0} bytes", binIn.Length);
620 if (binIn.Length != binOut.Length)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100621 {
622 Console.WriteLine("*** FAILED ***");
623 returnCode |= ErrorBaseTypes;
624 }
Jens Geyerbd1a2732019-06-26 22:52:44 +0200625 for (var ofs = 0; ofs < Math.Min(binIn.Length, binOut.Length); ++ofs)
626 {
627 if (binIn[ofs] != binOut[ofs])
628 {
629 Console.WriteLine("*** FAILED ***");
630 returnCode |= ErrorBaseTypes;
631 }
632 }
633 }
634 catch (Thrift.TApplicationException ex)
635 {
636 Console.WriteLine("*** FAILED ***");
637 returnCode |= ErrorBaseTypes;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200638 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyerbd1a2732019-06-26 22:52:44 +0200639 }
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100640 }
641
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200642 // CrazyNesting
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100643 Console.WriteLine("Test CrazyNesting");
644 var one = new CrazyNesting();
645 var two = new CrazyNesting();
646 one.String_field = "crazy";
647 two.String_field = "crazy";
Jens Geyer4115e952023-11-21 23:00:01 +0100648 one.Binary_field = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF];
649 two.Binary_field = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF];
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100650 if (typeof(CrazyNesting).GetMethod("Equals")?.DeclaringType == typeof(CrazyNesting))
651 {
652 if (!one.Equals(two))
653 {
654 Console.WriteLine("*** FAILED ***");
655 returnCode |= ErrorContainers;
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100656 }
657 }
658
659 // TODO: Validate received message
660 Console.Write("testStruct({\"Zero\", 1, -3, -5})");
Jens Geyer261cad32019-11-20 19:03:14 +0100661 var o = new Xtruct
662 {
663 String_thing = "Zero",
664 Byte_thing = (sbyte)1,
665 I32_thing = -3,
666 I64_thing = -5
667 };
Jens Geyer2b2ea622021-04-09 22:55:11 +0200668 var i = await client.testStruct(o, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100669 Console.WriteLine(" = {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}");
670
671 // TODO: Validate received message
672 Console.Write("testNest({1, {\"Zero\", 1, -3, -5}, 5})");
Jens Geyer261cad32019-11-20 19:03:14 +0100673 var o2 = new Xtruct2
674 {
675 Byte_thing = (sbyte)1,
676 Struct_thing = o,
677 I32_thing = 5
678 };
Jens Geyer3cac3202022-01-31 18:04:35 +0100679 Xtruct2 i2 = await client.testNest(o2, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100680 i = i2.Struct_thing;
Jens Geyer3cac3202022-01-31 18:04:35 +0100681 Console.WriteLine(" = {" + i2.Byte_thing + ", {\""
682 + (i?.String_thing ?? "<null>") + "\", "
683 + (i?.Byte_thing ?? 0) + ", "
684 + (i?.I32_thing ?? 0) + ", "
685 + (i?.I64_thing ?? 0) + "}, "
686 + i2.I32_thing + "}");
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100687
688 var mapout = new Dictionary<int, int>();
689 for (var j = 0; j < 5; j++)
690 {
691 mapout[j] = j - 10;
692 }
693 Console.Write("testMap({");
Jens Geyer71569402021-11-13 23:51:16 +0100694 Console.Write(string.Join(", ", mapout.Select((pair) => { return pair.Key + " => " + pair.Value; })));
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100695 Console.Write("})");
696
Jens Geyer2b2ea622021-04-09 22:55:11 +0200697 var mapin = await client.testMap(mapout, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100698
699 Console.Write(" = {");
Jens Geyer71569402021-11-13 23:51:16 +0100700 Console.Write(string.Join(", ", mapin.Select((pair) => { return pair.Key + " => " + pair.Value; })));
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100701 Console.WriteLine("}");
702
703 // TODO: Validate received message
704 var listout = new List<int>();
705 for (var j = -2; j < 3; j++)
706 {
707 listout.Add(j);
708 }
709 Console.Write("testList({");
Jens Geyer71569402021-11-13 23:51:16 +0100710 Console.Write(string.Join(", ", listout));
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100711 Console.Write("})");
712
Jens Geyer2b2ea622021-04-09 22:55:11 +0200713 var listin = await client.testList(listout, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100714
715 Console.Write(" = {");
Jens Geyer71569402021-11-13 23:51:16 +0100716 Console.Write(string.Join(", ", listin));
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100717 Console.WriteLine("}");
718
719 //set
720 // TODO: Validate received message
Jens Geyer3cac3202022-01-31 18:04:35 +0100721 var setout = new HashSet<int>();
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100722 for (var j = -2; j < 3; j++)
723 {
724 setout.Add(j);
725 }
726 Console.Write("testSet({");
Jens Geyer71569402021-11-13 23:51:16 +0100727 Console.Write(string.Join(", ", setout));
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100728 Console.Write("})");
729
Jens Geyer2b2ea622021-04-09 22:55:11 +0200730 var setin = await client.testSet(setout, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100731
732 Console.Write(" = {");
Jens Geyer71569402021-11-13 23:51:16 +0100733 Console.Write(string.Join(", ", setin));
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100734 Console.WriteLine("}");
735
736
737 Console.Write("testEnum(ONE)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200738 var ret = await client.testEnum(Numberz.ONE, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100739 Console.WriteLine(" = " + ret);
740 if (Numberz.ONE != ret)
741 {
742 Console.WriteLine("*** FAILED ***");
743 returnCode |= ErrorStructs;
744 }
745
746 Console.Write("testEnum(TWO)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200747 ret = await client.testEnum(Numberz.TWO, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100748 Console.WriteLine(" = " + ret);
749 if (Numberz.TWO != ret)
750 {
751 Console.WriteLine("*** FAILED ***");
752 returnCode |= ErrorStructs;
753 }
754
755 Console.Write("testEnum(THREE)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200756 ret = await client.testEnum(Numberz.THREE, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100757 Console.WriteLine(" = " + ret);
758 if (Numberz.THREE != ret)
759 {
760 Console.WriteLine("*** FAILED ***");
761 returnCode |= ErrorStructs;
762 }
763
764 Console.Write("testEnum(FIVE)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200765 ret = await client.testEnum(Numberz.FIVE, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100766 Console.WriteLine(" = " + ret);
767 if (Numberz.FIVE != ret)
768 {
769 Console.WriteLine("*** FAILED ***");
770 returnCode |= ErrorStructs;
771 }
772
773 Console.Write("testEnum(EIGHT)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200774 ret = await client.testEnum(Numberz.EIGHT, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100775 Console.WriteLine(" = " + ret);
776 if (Numberz.EIGHT != ret)
777 {
778 Console.WriteLine("*** FAILED ***");
779 returnCode |= ErrorStructs;
780 }
781
782 Console.Write("testTypedef(309858235082523)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200783 var uid = await client.testTypedef(309858235082523L, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100784 Console.WriteLine(" = " + uid);
785 if (309858235082523L != uid)
786 {
787 Console.WriteLine("*** FAILED ***");
788 returnCode |= ErrorStructs;
789 }
790
791 // TODO: Validate received message
792 Console.Write("testMapMap(1)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200793 var mm = await client.testMapMap(1, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100794 Console.Write(" = {");
795 foreach (var key in mm.Keys)
796 {
797 Console.Write(key + " => {");
798 var m2 = mm[key];
799 foreach (var k2 in m2.Keys)
800 {
801 Console.Write(k2 + " => " + m2[k2] + ", ");
802 }
803 Console.Write("}, ");
804 }
805 Console.WriteLine("}");
806
807 // TODO: Validate received message
Jens Geyer261cad32019-11-20 19:03:14 +0100808 var insane = new Insanity
809 {
810 UserMap = new Dictionary<Numberz, long>
811 {
812 [Numberz.FIVE] = 5000L
813 }
814 };
815 var truck = new Xtruct
816 {
817 String_thing = "Truck",
818 Byte_thing = (sbyte)8,
819 I32_thing = 8,
820 I64_thing = 8
821 };
Jens Geyer4115e952023-11-21 23:00:01 +0100822 insane.Xtructs = [ truck ];
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100823 Console.Write("testInsanity()");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200824 var whoa = await client.testInsanity(insane, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100825 Console.Write(" = {");
826 foreach (var key in whoa.Keys)
827 {
828 var val = whoa[key];
829 Console.Write(key + " => {");
830
831 foreach (var k2 in val.Keys)
832 {
833 var v2 = val[k2];
834
835 Console.Write(k2 + " => {");
836 var userMap = v2.UserMap;
837
838 Console.Write("{");
839 if (userMap != null)
840 {
841 foreach (var k3 in userMap.Keys)
842 {
843 Console.Write(k3 + " => " + userMap[k3] + ", ");
844 }
845 }
846 else
847 {
848 Console.Write("null");
849 }
850 Console.Write("}, ");
851
852 var xtructs = v2.Xtructs;
853
854 Console.Write("{");
855 if (xtructs != null)
856 {
857 foreach (var x in xtructs)
858 {
859 Console.Write("{\"" + x.String_thing + "\", " + x.Byte_thing + ", " + x.I32_thing + ", " + x.I32_thing + "}, ");
860 }
861 }
862 else
863 {
864 Console.Write("null");
865 }
866 Console.Write("}");
867
868 Console.Write("}, ");
869 }
870 Console.Write("}, ");
871 }
872 Console.WriteLine("}");
873
874 sbyte arg0 = 1;
875 var arg1 = 2;
876 var arg2 = long.MaxValue;
Jens Geyer261cad32019-11-20 19:03:14 +0100877 var multiDict = new Dictionary<short, string>
878 {
879 [1] = "one"
880 };
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100881
882 var tmpMultiDict = new List<string>();
883 foreach (var pair in multiDict)
884 tmpMultiDict.Add(pair.Key +" => "+ pair.Value);
885
886 var arg4 = Numberz.FIVE;
887 long arg5 = 5000000;
888 Console.Write("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + ",{" + string.Join(",", tmpMultiDict) + "}," + arg4 + "," + arg5 + ")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200889 var multiResponse = await client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100890 Console.Write(" = Xtruct(byte_thing:" + multiResponse.Byte_thing + ",String_thing:" + multiResponse.String_thing
891 + ",i32_thing:" + multiResponse.I32_thing + ",i64_thing:" + multiResponse.I64_thing + ")\n");
892
893 try
894 {
895 Console.WriteLine("testException(\"Xception\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200896 await client.testException("Xception", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100897 Console.WriteLine("*** FAILED ***");
898 returnCode |= ErrorExceptions;
899 }
900 catch (Xception ex)
901 {
902 if (ex.ErrorCode != 1001 || ex.Message != "Xception")
903 {
904 Console.WriteLine("*** FAILED ***");
905 returnCode |= ErrorExceptions;
906 }
907 }
908 catch (Exception ex)
909 {
910 Console.WriteLine("*** FAILED ***");
911 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200912 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100913 }
914 try
915 {
916 Console.WriteLine("testException(\"TException\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200917 await client.testException("TException", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100918 Console.WriteLine("*** FAILED ***");
919 returnCode |= ErrorExceptions;
920 }
921 catch (Thrift.TException)
922 {
923 // OK
924 }
925 catch (Exception ex)
926 {
927 Console.WriteLine("*** FAILED ***");
928 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200929 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100930 }
931 try
932 {
933 Console.WriteLine("testException(\"ok\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200934 await client.testException("ok", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100935 // OK
936 }
937 catch (Exception ex)
938 {
939 Console.WriteLine("*** FAILED ***");
940 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200941 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100942 }
943
944 try
945 {
946 Console.WriteLine("testMultiException(\"Xception\", ...)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200947 await client.testMultiException("Xception", "ignore", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100948 Console.WriteLine("*** FAILED ***");
949 returnCode |= ErrorExceptions;
950 }
951 catch (Xception ex)
952 {
953 if (ex.ErrorCode != 1001 || ex.Message != "This is an Xception")
954 {
955 Console.WriteLine("*** FAILED ***");
956 returnCode |= ErrorExceptions;
957 }
958 }
959 catch (Exception ex)
960 {
961 Console.WriteLine("*** FAILED ***");
962 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200963 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100964 }
965 try
966 {
967 Console.WriteLine("testMultiException(\"Xception2\", ...)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200968 await client.testMultiException("Xception2", "ignore", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100969 Console.WriteLine("*** FAILED ***");
970 returnCode |= ErrorExceptions;
971 }
972 catch (Xception2 ex)
973 {
Jens Geyer3cac3202022-01-31 18:04:35 +0100974 if (ex.ErrorCode != 2002 || ex.Struct_thing?.String_thing != "This is an Xception2")
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100975 {
976 Console.WriteLine("*** FAILED ***");
977 returnCode |= ErrorExceptions;
978 }
979 }
980 catch (Exception ex)
981 {
982 Console.WriteLine("*** FAILED ***");
983 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200984 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100985 }
986 try
987 {
988 Console.WriteLine("testMultiException(\"success\", \"OK\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200989 if ("OK" != (await client.testMultiException("success", "OK", MakeTimeoutToken())).String_thing)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100990 {
991 Console.WriteLine("*** FAILED ***");
992 returnCode |= ErrorExceptions;
993 }
994 }
995 catch (Exception ex)
996 {
997 Console.WriteLine("*** FAILED ***");
998 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200999 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001000 }
1001
Jens Geyerb11f63c2019-03-14 21:12:38 +01001002 Console.WriteLine("Test Oneway(1)");
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001003 var sw = new Stopwatch();
1004 sw.Start();
Jens Geyer2b2ea622021-04-09 22:55:11 +02001005 await client.testOneway(1, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001006 sw.Stop();
1007 if (sw.ElapsedMilliseconds > 1000)
1008 {
1009 Console.WriteLine("*** FAILED ***");
1010 returnCode |= ErrorBaseTypes;
1011 }
1012
1013 Console.Write("Test Calltime()");
1014 var times = 50;
1015 sw.Reset();
1016 sw.Start();
Jens Geyer1b770f22019-03-12 01:19:43 +01001017 var token = MakeTimeoutToken(20000);
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001018 for (var k = 0; k < times; ++k)
Jens Geyer2b2ea622021-04-09 22:55:11 +02001019 await client.testVoid(token);
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001020 sw.Stop();
1021 Console.WriteLine(" = {0} ms a testVoid() call", sw.ElapsedMilliseconds / times);
1022 return returnCode;
1023 }
1024 }
1025}