Beispiel #1
0
 /// <summary>
 ///   Initializes a new <see cref="BufferedPublisher" \> instance.
 /// </summary>
 ///
 /// <param name="testConfiguration">The <see cref="TestConfiguration" /> used to configure the processor test scenario run.</param>
 /// <param name="bufferedPublisherConfiguration">The <see cref="BufferedPublisherConfiguration" /> instance used to configure this instance of <see cref="BufferedPublisher" />.</param>
 /// <param name="metrics">The <see cref="Metrics" /> instance used to send metrics to Application Insights.</param>
 /// <param name="testName">The name of the test being run in order to organize metrics being collected.</param>
 ///
 public BufferedPublisher(TestConfiguration testConfiguration,
                          BufferedPublisherConfiguration bufferedPublisherConfiguration,
                          Metrics metrics,
                          string testName)
 {
     _metrics           = metrics;
     _testConfiguration = testConfiguration;
     _bufferedPublisherConfiguration = bufferedPublisherConfiguration;
     _testName = testName;
 }
Beispiel #2
0
    /// <summary>
    ///   Starts a background task for each test that needs to be run, and waits for all
    ///   test runs to completed before returning.
    /// </summary>
    ///
    /// <param name="roleList">The list of roles needed for the scenario being run.</param>
    /// <param name="testConfiguration">The <see cref="TestConfiguration" /> instance used to configure this test scenario run.</param>
    /// <param name="roleConfiguration">The <see cref="RoleConfiguration" /> instance used to configure the role being run.</param>
    /// <param name="metrics">The <see cref="Metrics" /> instance used by this role to send metrics to application insights.</param>
    /// <param name="testName">The name of the test scenario that is being run, for metrics purposes.</param>
    /// <param name="cancellationToken">The <see cref="CancellationToke"/> instance to signal the request to cancel the operation.</param>
    ///
    private static async Task RunRole(string role,
                                      TestConfiguration testConfiguration,
                                      RoleConfiguration roleConfiguration,
                                      Metrics metrics,
                                      string testName,
                                      CancellationToken cancellationToken)
    {
        if (role == RoleConfiguration.Publisher)
        {
            var publisherConfiguration = new PublisherConfiguration();
            var publisher = new Publisher(publisherConfiguration, testConfiguration, metrics, testName);
            await publisher.Start(cancellationToken);
        }

        if (role == RoleConfiguration.BufferedPublisher)
        {
            var publisherConfiguration = new BufferedPublisherConfiguration();
            var publisher = new BufferedPublisher(testConfiguration, publisherConfiguration, metrics, testName);
            await publisher.Start(cancellationToken);
        }

        if (role == RoleConfiguration.Processor)
        {
            var partitionCount = _getPartitionCount(testConfiguration.EventHubsConnectionString, testConfiguration.EventHub);
            await partitionCount.ConfigureAwait(false);

            var processConfiguration = new ProcessorConfiguration();
            var processor            = new Processor(testConfiguration, processConfiguration, metrics, partitionCount.Result, testName);
            await processor.Start(cancellationToken);
        }

        if (role == RoleConfiguration.BurstBufferedPublisher)
        {
            var publisherConfiguration = new BufferedPublisherConfiguration();
            publisherConfiguration.ProducerPublishingDelay = TimeSpan.FromMinutes(25);
            var publisher = new BufferedPublisher(testConfiguration, publisherConfiguration, metrics, testName);
            await publisher.Start(cancellationToken);
        }

        //return Task.CompletedTask;
        await Task.Delay(TimeSpan.FromSeconds(1));
    }