blob: 26bd120c46fdc017e5f72db139cecbfd6ee65a28 [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 Geyere26b4a82024-11-12 23:53:04 +0100228 //var cert = new X509Certificate2(existingPath, "thrift");
229 var cert = X509CertificateLoader.LoadPkcs12FromFile(existingPath, "thrift");
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100230
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 Geyera06eedc2023-11-16 23:23:04 +0100260 null);
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 Geyer4115e952023-11-21 23:00:01 +0100396 public static 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 Geyer4115e952023-11-21 23:00:01 +0100411 return Task.FromResult(ErrorUnknown);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100412 }
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 Geyer4115e952023-11-21 23:00:01 +0100435 return Task.FromResult(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 Geyer4115e952023-11-21 23:00:01 +0100442 return Task.FromResult(ErrorUnknown);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100443 }
444 }
445
446 public static string BytesToHex(byte[] data)
447 {
Jens Geyere26b4a82024-11-12 23:53:04 +0100448 return Convert.ToHexString(data);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100449 }
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";
Jens Geyer4115e952023-11-21 23:00:01 +0100649 one.Binary_field = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF];
650 two.Binary_field = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF];
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100651 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 };
Jens Geyer4115e952023-11-21 23:00:01 +0100823 insane.Xtructs = [ truck ];
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100824 Console.Write("testInsanity()");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200825 var whoa = await client.testInsanity(insane, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100826 Console.Write(" = {");
827 foreach (var key in whoa.Keys)
828 {
829 var val = whoa[key];
830 Console.Write(key + " => {");
831
832 foreach (var k2 in val.Keys)
833 {
834 var v2 = val[k2];
835
836 Console.Write(k2 + " => {");
837 var userMap = v2.UserMap;
838
839 Console.Write("{");
840 if (userMap != null)
841 {
842 foreach (var k3 in userMap.Keys)
843 {
844 Console.Write(k3 + " => " + userMap[k3] + ", ");
845 }
846 }
847 else
848 {
849 Console.Write("null");
850 }
851 Console.Write("}, ");
852
853 var xtructs = v2.Xtructs;
854
855 Console.Write("{");
856 if (xtructs != null)
857 {
858 foreach (var x in xtructs)
859 {
860 Console.Write("{\"" + x.String_thing + "\", " + x.Byte_thing + ", " + x.I32_thing + ", " + x.I32_thing + "}, ");
861 }
862 }
863 else
864 {
865 Console.Write("null");
866 }
867 Console.Write("}");
868
869 Console.Write("}, ");
870 }
871 Console.Write("}, ");
872 }
873 Console.WriteLine("}");
874
875 sbyte arg0 = 1;
876 var arg1 = 2;
877 var arg2 = long.MaxValue;
Jens Geyer261cad32019-11-20 19:03:14 +0100878 var multiDict = new Dictionary<short, string>
879 {
880 [1] = "one"
881 };
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100882
883 var tmpMultiDict = new List<string>();
884 foreach (var pair in multiDict)
885 tmpMultiDict.Add(pair.Key +" => "+ pair.Value);
886
887 var arg4 = Numberz.FIVE;
888 long arg5 = 5000000;
889 Console.Write("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + ",{" + string.Join(",", tmpMultiDict) + "}," + arg4 + "," + arg5 + ")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200890 var multiResponse = await client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100891 Console.Write(" = Xtruct(byte_thing:" + multiResponse.Byte_thing + ",String_thing:" + multiResponse.String_thing
892 + ",i32_thing:" + multiResponse.I32_thing + ",i64_thing:" + multiResponse.I64_thing + ")\n");
893
894 try
895 {
896 Console.WriteLine("testException(\"Xception\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200897 await client.testException("Xception", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100898 Console.WriteLine("*** FAILED ***");
899 returnCode |= ErrorExceptions;
900 }
901 catch (Xception ex)
902 {
903 if (ex.ErrorCode != 1001 || ex.Message != "Xception")
904 {
905 Console.WriteLine("*** FAILED ***");
906 returnCode |= ErrorExceptions;
907 }
908 }
909 catch (Exception ex)
910 {
911 Console.WriteLine("*** FAILED ***");
912 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200913 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100914 }
915 try
916 {
917 Console.WriteLine("testException(\"TException\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200918 await client.testException("TException", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100919 Console.WriteLine("*** FAILED ***");
920 returnCode |= ErrorExceptions;
921 }
922 catch (Thrift.TException)
923 {
924 // OK
925 }
926 catch (Exception ex)
927 {
928 Console.WriteLine("*** FAILED ***");
929 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200930 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100931 }
932 try
933 {
934 Console.WriteLine("testException(\"ok\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200935 await client.testException("ok", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100936 // OK
937 }
938 catch (Exception ex)
939 {
940 Console.WriteLine("*** FAILED ***");
941 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200942 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100943 }
944
945 try
946 {
947 Console.WriteLine("testMultiException(\"Xception\", ...)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200948 await client.testMultiException("Xception", "ignore", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100949 Console.WriteLine("*** FAILED ***");
950 returnCode |= ErrorExceptions;
951 }
952 catch (Xception ex)
953 {
954 if (ex.ErrorCode != 1001 || ex.Message != "This is an Xception")
955 {
956 Console.WriteLine("*** FAILED ***");
957 returnCode |= ErrorExceptions;
958 }
959 }
960 catch (Exception ex)
961 {
962 Console.WriteLine("*** FAILED ***");
963 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200964 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100965 }
966 try
967 {
968 Console.WriteLine("testMultiException(\"Xception2\", ...)");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200969 await client.testMultiException("Xception2", "ignore", MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100970 Console.WriteLine("*** FAILED ***");
971 returnCode |= ErrorExceptions;
972 }
973 catch (Xception2 ex)
974 {
Jens Geyer3cac3202022-01-31 18:04:35 +0100975 if (ex.ErrorCode != 2002 || ex.Struct_thing?.String_thing != "This is an Xception2")
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100976 {
977 Console.WriteLine("*** FAILED ***");
978 returnCode |= ErrorExceptions;
979 }
980 }
981 catch (Exception ex)
982 {
983 Console.WriteLine("*** FAILED ***");
984 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +0200985 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100986 }
987 try
988 {
989 Console.WriteLine("testMultiException(\"success\", \"OK\")");
Jens Geyer2b2ea622021-04-09 22:55:11 +0200990 if ("OK" != (await client.testMultiException("success", "OK", MakeTimeoutToken())).String_thing)
Jens Geyeraa0c8b32019-01-28 23:27:45 +0100991 {
992 Console.WriteLine("*** FAILED ***");
993 returnCode |= ErrorExceptions;
994 }
995 }
996 catch (Exception ex)
997 {
998 Console.WriteLine("*** FAILED ***");
999 returnCode |= ErrorExceptions;
Mario Emmenlauer47e49232020-04-07 18:43:46 +02001000 Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001001 }
1002
Jens Geyerb11f63c2019-03-14 21:12:38 +01001003 Console.WriteLine("Test Oneway(1)");
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001004 var sw = new Stopwatch();
1005 sw.Start();
Jens Geyer2b2ea622021-04-09 22:55:11 +02001006 await client.testOneway(1, MakeTimeoutToken());
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001007 sw.Stop();
1008 if (sw.ElapsedMilliseconds > 1000)
1009 {
1010 Console.WriteLine("*** FAILED ***");
1011 returnCode |= ErrorBaseTypes;
1012 }
1013
1014 Console.Write("Test Calltime()");
1015 var times = 50;
1016 sw.Reset();
1017 sw.Start();
Jens Geyer1b770f22019-03-12 01:19:43 +01001018 var token = MakeTimeoutToken(20000);
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001019 for (var k = 0; k < times; ++k)
Jens Geyer2b2ea622021-04-09 22:55:11 +02001020 await client.testVoid(token);
Jens Geyeraa0c8b32019-01-28 23:27:45 +01001021 sw.Stop();
1022 Console.WriteLine(" = {0} ms a testVoid() call", sw.ElapsedMilliseconds / times);
1023 return returnCode;
1024 }
1025 }
1026}