From 4f5d3cad6bf36ccde0b651ee4ffa02bb04384a68 Mon Sep 17 00:00:00 2001 From: Padmanabh Gupta Date: Wed, 18 Dec 2024 13:57:20 +0530 Subject: [PATCH] remove networking test in BDN --- benchmark/BDN.benchmark/Network/Network.cs | 25 ------ .../BDN.benchmark/Network/NetworkBase.cs | 81 ------------------- 2 files changed, 106 deletions(-) delete mode 100644 benchmark/BDN.benchmark/Network/Network.cs delete mode 100644 benchmark/BDN.benchmark/Network/NetworkBase.cs diff --git a/benchmark/BDN.benchmark/Network/Network.cs b/benchmark/BDN.benchmark/Network/Network.cs deleted file mode 100644 index ac1250fa4c..0000000000 --- a/benchmark/BDN.benchmark/Network/Network.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -using System.Net.Security; -using BenchmarkDotNet.Attributes; - -namespace BDN.benchmark.Network -{ - [MemoryDiagnoser] - public class Network : NetworkBase - { - [Benchmark] - public async Task TestNetworkTask() - { - var sslStreams = GetStreams(); - var sslStreamWrites = new List(MaxConnections); - var sslClientAuthOptions = new SslClientAuthenticationOptions { RemoteCertificateValidationCallback = CertValidationCallback }; - foreach (var stream in sslStreams) - { - sslStreamWrites.Add(stream.AuthenticateAsClientAsync(sslClientAuthOptions)); - } - await Task.WhenAll(sslStreamWrites); - } - } -} \ No newline at end of file diff --git a/benchmark/BDN.benchmark/Network/NetworkBase.cs b/benchmark/BDN.benchmark/Network/NetworkBase.cs deleted file mode 100644 index d69d6a5a26..0000000000 --- a/benchmark/BDN.benchmark/Network/NetworkBase.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -using System.Net.Security; -using System.Net.Sockets; -using System.Security.Cryptography.X509Certificates; -using BenchmarkDotNet.Attributes; -using Garnet.networking; -using Garnet.server; -using Garnet.server.TLS; - -namespace BDN.benchmark.Network -{ - public abstract class NetworkBase - { - /// - /// Base class for operations benchmarks - /// - protected RemoteCertificateValidationCallback CertValidationCallback = (a, b, c, d) => { return true; }; - private IGarnetServer GarnetServer; - private Dictionary TcpClients; - private IReadOnlyList SslStreams; - protected const int MaxConnections = 128; - - [GlobalSetup] - public virtual async Task GlobalSetup() - { - try - { - var tlsOptions = new GarnetTlsOptions( - certFileName: "testcert.pfx", - certPassword: "placeholder", - clientCertificateRequired: false, - certificateRevocationCheckMode: X509RevocationMode.NoCheck, - issuerCertificatePath: "testcert.pfx", - null, 0, false, null); - var serverBufferSize = BufferSizeUtils.ServerBufferSize(new MaxSizeSettings()); - GarnetServer = new GarnetServerTcp("127.0.0.1", 3278, serverBufferSize, tlsOptions); - GarnetServer.Start(); - // This is done to compare sync vs async workloads since blocking patterns exhaust threadpool. - ThreadPool.SetMinThreads(4, 4); - await SetupClientPool(); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - - public IReadOnlyList GetStreams() - { - return SslStreams; - } - - private async Task SetupClientPool() - { - TcpClients = new Dictionary(); - for (int i = 0; i < MaxConnections; i++) - { - var client = new TcpClient(); - await client.ConnectAsync("127.0.0.1", 3278); - var sslStream = new SslStream(client.GetStream(), false, CertValidationCallback, null); - TcpClients.Add(client, sslStream); - } - SslStreams = [.. TcpClients.Values]; - } - - /// - /// Cleanup - /// - [GlobalCleanup] - public virtual void GlobalCleanup() - { - foreach (var tcpClient in TcpClients) - { - tcpClient.Value.Dispose(); - tcpClient.Key.Dispose(); - } - GarnetServer.Dispose(); - } - } -} \ No newline at end of file