Inheritance: AutoscalingConfigurationSet, IAutoscalingConfigurationSet
        public async Task EnsureProvisioningAsync_ShouldNotCallUpdateOnClientWhenValuesAreTheSame()
        {
            var readsConfiguration = new AutoscalingConfiguration {EnableAutoscaling = true};
            var writesConfiguration = new AutoscalingConfiguration {EnableAutoscaling = true};
            var configurationSet = new TableAutoscalingConfigurationSet
            {
                TableName = tableName, DemoMode = false, Reads = readsConfiguration, Writes = writesConfiguration,
            };
            var provisioned = new DynamoDbTableThroughput { ReadThroughput = 500, WriteThroughput = 1000 };
            var updated = new DynamoDbTableThroughput { ReadThroughput = 500, WriteThroughput = 1000 };

            await tableProvisioner.ProvisionAsync(configurationSet, provisioned, updated);

            throughputClientMock.Verify(
                client => client.SetTableThroughputLevelAsync(tableName, 500, 1000, default(CancellationToken)),
                Times.Never);
        }
        public async Task EnsureProvisioningAsync_ShouldCallUpdateOnClientOnlyWithEnabledThroughput()
        {
            var configurationSet = new TableAutoscalingConfigurationSet
            {
                TableName = tableName,
                DemoMode = false,
                Reads = new AutoscalingConfiguration { EnableAutoscaling = false },
                Writes = new AutoscalingConfiguration { EnableAutoscaling = true },
            };
            var provisioned = new DynamoDbTableThroughput { ReadThroughput = 500, WriteThroughput = 1000 };
            var updated = new DynamoDbTableThroughput { ReadThroughput = 1000, WriteThroughput = 2000 };

            await tableProvisioner.ProvisionAsync(configurationSet, provisioned, updated);

            throughputClientMock.Verify(
                client => client.SetTableThroughputLevelAsync(tableName, 500, 2000, default(CancellationToken)),
                Times.Once);
        }
Esempio n. 3
0
        internal async Task EnsureTableProvisionAsync(
            bool isCircuitBreakerTripped,
            TableAutoscalingConfigurationSet configuration,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();

            var tableName = configuration.TableName;
            var provisioned = await throughputClient.GetTableThroughputLevelAsync(tableName, cancellationToken).ConfigureAwait(false);
            var metrics = await metricsClient.GetTableMetricsAsync(tableName, cancellationToken).ConfigureAwait(false);
            LogStats(configuration, provisioned, metrics);

            var updated = EnsureProvision(isCircuitBreakerTripped, provisioned, metrics, configuration);
            var provisioner = new TableProvisioner(tableName, throughputClient, structuredLogger);
            await provisioner.ProvisionAsync(configuration, provisioned, updated, cancellationToken).ConfigureAwait(false);
        }