Example #1
0
        private async Task SetDataPerformanceTest(IRingMasterRequestHandler ringMasterClient, ConfigurationSection config, CancellationToken cancellationToken)
        {
            try
            {
                string testRootPath = config.GetStringValue("TestPath");
                int    maxConcurrentSetDataBatches = config.GetIntValue("MaxConcurrentBatches");
                int    maxNodes    = config.GetIntValue("MaxNodesToLoad");
                int    batchLength = config.GetIntValue("BatchLength");

                ControlPlaneStressServiceEventSource.Log.SetDataPerformanceTestStarted(testRootPath, maxNodes, batchLength);
                var instrumentation        = new SetDataPerformanceInstrumentation(this.MetricsFactory);
                var setDataPerformanceTest = new SetDataPerformance(instrumentation, maxConcurrentSetDataBatches, cancellationToken);

                setDataPerformanceTest.MinDataSizePerNode = config.GetIntValue("MinDataSizePerNode");
                setDataPerformanceTest.MaxDataSizePerNode = config.GetIntValue("MaxDataSizePerNode");

                await setDataPerformanceTest.LoadNodes(ringMasterClient, testRootPath, maxNodes);

                await Task.Run(() => setDataPerformanceTest.QueueRequests(ringMasterClient, batchLength));

                ControlPlaneStressServiceEventSource.Log.SetDataPerformanceTestCompleted();
            }
            catch (Exception ex)
            {
                ControlPlaneStressServiceEventSource.Log.SetDataPerformanceTestFailed(ex.ToString());
            }
        }
        private void ConnectPerformanceTest(ConfigurationSection config, CancellationToken cancellationToken)
        {
            try
            {
                var instrumentation = new ConnectPerformanceInstrumentation(this.MetricsFactory);
                var random          = new Random();

                string connectionString = config.GetStringValue("TargetConnectionString");
                connectionString = Helpers.GetServerAddressIfNotProvided(connectionString);
                IPEndPoint[] endpoints                    = SecureTransport.ParseConnectionString(connectionString);
                string       testPath                     = config.GetStringValue("TestPath");
                int          numConnections               = config.GetIntValue("NumberOfConnections");
                int          maxConcurrentRequests        = config.GetIntValue("MaxConcurrentRequests");
                int          minConnectionLifetimeSeconds = config.GetIntValue("MinConnectionLifetimeSeconds");
                int          maxConnectionLifetimeSeconds = config.GetIntValue("MaxConnectionLifetimeSeconds");

                Func <IRingMasterRequestHandler> createConnection = () =>
                {
                    var connectionConfiguration = new SecureTransport.Configuration
                    {
                        UseSecureConnection          = false,
                        CommunicationProtocolVersion = RingMasterCommunicationProtocol.MaximumSupportedVersion,
                        MaxConnectionLifespan        = TimeSpan.FromSeconds(random.Next(minConnectionLifetimeSeconds, maxConnectionLifetimeSeconds))
                    };

                    var protocol  = new RingMasterCommunicationProtocol();
                    var transport = new SecureTransport(connectionConfiguration, instrumentation, cancellationToken);
                    var client    = new RingMasterClient(protocol, transport);
                    transport.StartClient(endpoints);

                    ConnectionStressServiceEventSource.Log.CreateConnection(
                        connectionConfiguration.UseSecureConnection,
                        connectionConfiguration.CommunicationProtocolVersion,
                        (long)connectionConfiguration.MaxConnectionLifespan.TotalSeconds);

                    client.Exists("/", watcher: null).Wait();
                    return((IRingMasterRequestHandler)client);
                };

                using (var connectPerformanceTest = new ConnectPerformance(instrumentation, maxConcurrentRequests, cancellationToken))
                {
                    ConnectionStressServiceEventSource.Log.ConnectPerformanceTestStarted(testPath, numConnections, minConnectionLifetimeSeconds, maxConnectionLifetimeSeconds);

                    connectPerformanceTest.EstablishConnections(createConnection, numConnections);

                    connectPerformanceTest.QueueRequests(testPath);
                }

                ConnectionStressServiceEventSource.Log.ConnectPerformanceTestCompleted();
            }
            catch (Exception ex)
            {
                ConnectionStressServiceEventSource.Log.ConnectPerformanceTestFailed(ex.ToString());
            }
        }
        private async Task CreateAndDeleteHierarchyTest(IRingMasterRequestHandler ringMaster, ConfigurationSection config, CancellationToken cancellationToken)
        {
            try
            {
                string testPath           = config.GetStringValue("CreateAndDeleteHierarchy.TestPath");
                int    maxNodes           = config.GetIntValue("CreateAndDeleteHierarchy.MaxNodes");
                bool   useScheduledDelete = config.GetBoolValue("CreateAndDeleteHierarchy.UseScheduledDelete");

                await ringMaster.Create(testPath, null, null, CreateMode.PersistentAllowPathCreation, throwIfNodeExists : false);

                while (!cancellationToken.IsCancellationRequested)
                {
                    var createInstrumentation      = new CreatePerformanceInstrumentation(this.MetricsFactory);
                    int maxConcurrentCreateBatches = config.GetIntValue("Create.MaxConcurrentBatches");
                    int createBatchLength          = config.GetIntValue("Create.BatchLength");

                    var createPerformanceTest = new CreatePerformance(createInstrumentation, maxConcurrentCreateBatches, cancellationToken);
                    createPerformanceTest.MinChildrenCountPerNode = config.GetIntValue("Create.MinChildrenCountPerNode");
                    createPerformanceTest.MaxChildrenCountPerNode = config.GetIntValue("Create.MaxChildrenCountPerNode");
                    createPerformanceTest.MinDataSizePerNode      = config.GetIntValue("Create.MinDataSizePerNode");
                    createPerformanceTest.MaxDataSizePerNode      = config.GetIntValue("Create.MaxDataSizePerNode");
                    createPerformanceTest.MaxNodeNameLength       = config.GetIntValue("Create.MaxNodeNameLength");

                    PopulationStressServiceEventSource.Log.CreateAndDeleteHierarchyCreateStarted(testPath, maxNodes, createBatchLength);

                    createPerformanceTest.CreateHierarchy(ringMaster, testPath, createBatchLength, maxNodes);

                    int maxConcurrentDeleteBatches = config.GetIntValue("Delete.MaxConcurrentBatches");
                    int deleteBatchLength          = config.GetIntValue("Delete.BatchLength");

                    var deleteInstrumentation = new DeletePerformanceInstrumentation(this.MetricsFactory);
                    var deletePerformanceTest = new DeletePerformance(deleteInstrumentation, maxConcurrentDeleteBatches, cancellationToken);

                    PopulationStressServiceEventSource.Log.CreateAndDeleteHierarchyDeleteStarted(testPath, maxNodes, deleteBatchLength, useScheduledDelete);

                    if (useScheduledDelete)
                    {
                        deletePerformanceTest.ScheduledDelete(ringMaster, testPath);
                    }
                    else
                    {
                        await deletePerformanceTest.LoadNodes(ringMaster, testPath, maxNodes);

                        deletePerformanceTest.QueueDeletes(ringMaster, deleteBatchLength);
                    }
                }

                PopulationStressServiceEventSource.Log.CreateAndDeleteHierarchyTestCompleted();
            }
            catch (Exception ex)
            {
                PopulationStressServiceEventSource.Log.CreateAndDeleteHierarchyTestFailed(ex.ToString());
            }
        }
        private void GetChildrenPerformanceTest(IRingMasterRequestHandler ringMaster, ConfigurationSection config, CancellationToken cancellationToken)
        {
            string testPath              = config.GetStringValue("TestPath");
            int    maxChildren           = config.GetIntValue("MaxChildren");
            int    maxConcurrentRequests = config.GetIntValue("MaxConcurrentRequests");

            var instrumentation            = new GetChildrenPerformanceInstrumentation(this.MetricsFactory);
            var getChildrenPerformanceTest = new GetChildrenPerformance(instrumentation, maxConcurrentRequests, cancellationToken);

            EnumerationStressServiceEventSource.Log.GetChildrenPerformanceTestStarted(testPath, maxChildren, maxConcurrentRequests);
            getChildrenPerformanceTest.QueueRequests(ringMaster, testPath, maxChildren);
        }
Example #5
0
        /// <summary>
        /// Measures the performance of Watchers.
        /// </summary>
        /// <param name="ringMaster">RingMaster client</param>
        /// <param name="config">Configuration section</param>
        /// <param name="cancellationToken">Token that must be observed for cancellation signal</param>
        /// <returns>Task that tracks execution of this test</returns>
        private async Task SubscribePerformanceTest(IRingMasterRequestHandler ringMaster, ConfigurationSection config, CancellationToken cancellationToken)
        {
            string testPath = config.GetStringValue("TestPath");
            int    maxNodes = config.GetIntValue("MaxNodesToLoad");
            int    maxGetChildrenEnumerationCount = config.GetIntValue("MaxChildrenEnumerationCount");
            int    maxConcurrentWatchers          = config.GetIntValue("MaxConcurrentWatchers");
            int    maxConcurrency = 16;

            SubscribeStressServiceEventSource.Log.WatcherPerformanceTestStarted(testPath, maxNodes, maxConcurrentWatchers);
            var instrumentation        = new WatcherPerformanceInstrumentation(this.MetricsFactory);
            var watcherPerformanceTest = new BulkWatcherPerformance(instrumentation, maxConcurrency, cancellationToken);

            await watcherPerformanceTest.LoadNodes(ringMaster, testPath, maxNodes, maxGetChildrenEnumerationCount);

            await Task.Run(() => watcherPerformanceTest.SetWatchers(ringMaster));
        }
Example #6
0
        private async Task GetDataPerformanceTest(IRingMasterRequestHandler ringMaster, ConfigurationSection config, CancellationToken cancellationToken)
        {
            try
            {
                string testRootPath = config.GetStringValue("TestPath");
                int    maxConcurrentGetDataBatches = config.GetIntValue("MaxConcurrentBatches");
                int    batchLength = config.GetIntValue("BatchLength");
                int    maxNodes    = config.GetIntValue("MaxNodesToLoad");

                var instrumentation        = new GetDataPerformanceInstrumentation(this.MetricsFactory);
                var getDataPerformanceTest = new GetDataPerformance(instrumentation, maxConcurrentGetDataBatches, cancellationToken);
                await getDataPerformanceTest.LoadNodes(ringMaster, testRootPath, maxNodes);

                ringMaster.Timeout = 100;
                ServingPlaneStressServiceEventSource.Log.GetDataPerformanceTestStarted(testRootPath, maxNodes, batchLength);
                await Task.Run(() => getDataPerformanceTest.QueueBatches(ringMaster, batchLength));

                ServingPlaneStressServiceEventSource.Log.GetDataPerformanceTestCompleted();
            }
            catch (Exception ex)
            {
                ServingPlaneStressServiceEventSource.Log.GetDataPerformanceTestFailed(ex.ToString());
            }
        }