public async Task ReplaceThroughputTest() { string containerName = Guid.NewGuid().ToString(); string partitionKeyPath = "/users"; CosmosContainerResponse containerResponse = await this.cosmosDatabase.Containers.CreateContainerIfNotExistsAsync(containerName, partitionKeyPath); Assert.AreEqual(HttpStatusCode.Created, containerResponse.StatusCode); CosmosContainer cosmosContainer = this.cosmosDatabase.Containers[containerName]; int?readThroughput = await cosmosContainer.ReadProvisionedThroughputAsync(); Assert.IsNotNull(readThroughput); await cosmosContainer.ReplaceProvisionedThroughputAsync(readThroughput.Value + 1000); int?replaceThroughput = await cosmosContainer.ReadProvisionedThroughputAsync(); Assert.IsNotNull(replaceThroughput); Assert.AreEqual(readThroughput.Value + 1000, replaceThroughput); containerResponse = await cosmosContainer.DeleteAsync(); Assert.AreEqual(HttpStatusCode.NoContent, containerResponse.StatusCode); }
public async Task SharedThroughputTests() { string databaseId = Guid.NewGuid().ToString(); int throughput = 10000; CosmosDatabaseResponse createResponse = await this.CreateDatabaseHelper(databaseId, databaseExists : false, throughput : throughput); Assert.AreEqual(HttpStatusCode.Created, createResponse.StatusCode); CosmosDatabase cosmosDatabase = createResponse; int? readThroughput = await cosmosDatabase.ReadProvisionedThroughputAsync(); Assert.AreEqual(throughput, readThroughput); string containerId = Guid.NewGuid().ToString(); string partitionPath = "/users"; CosmosContainerResponse containerResponse = await cosmosDatabase.Containers.CreateContainerAsync(containerId, partitionPath); Assert.AreEqual(HttpStatusCode.Created, containerResponse.StatusCode); CosmosContainer container = containerResponse; readThroughput = await container.ReadProvisionedThroughputAsync(); Assert.IsNull(readThroughput); await container.DeleteAsync(); await cosmosDatabase.DeleteAsync(); }
private async Task CreateContainerIfNotExistsAsync(CosmosContainerOptions options) { // TODO: Container単位のDefaultThroughputの実装 CosmosContainer container = await Database.Containers.CreateContainerIfNotExistsAsync(options.ToCosmosContainerSettings()); var throughput = await container.ReadProvisionedThroughputAsync(); _logger.LogInformation($"Container:{container.Id}; throughput:{ConvertThroughputLogString(throughput)}"); }
public async Task ThroughputNonExistingTest() { string containerName = Guid.NewGuid().ToString(); CosmosContainer cosmosContainer = this.cosmosDatabase.Containers[containerName]; await cosmosContainer.ReadProvisionedThroughputAsync(); CosmosContainerResponse containerResponse = await cosmosContainer.DeleteAsync(); Assert.AreEqual(HttpStatusCode.NotFound, containerResponse.StatusCode); }
private static async Task GetAndChangeContainerPerformance(CosmosContainer simpleContainer) { //********************************************************************************************* // Get configured performance (reserved throughput) of a CosmosContainer //********************************************************************************************** int?throughput = await simpleContainer.ReadProvisionedThroughputAsync(); Console.WriteLine($"\n2. Found throughput \n{throughput.Value}\nusing container's id \n{simpleContainer.Id}"); //****************************************************************************************************************** // Change performance (reserved throughput) of CosmosContainer // Let's change the performance of the container to 500 RU/s //****************************************************************************************************************** await simpleContainer.ReplaceProvisionedThroughputAsync(500); Console.WriteLine("\n3. Replaced throughput. Throughput is now 500.\n"); // Get the offer again after replace int?throughputAfterReplace = await simpleContainer.ReadProvisionedThroughputAsync(); Console.WriteLine($"3. Found throughput \n{throughputAfterReplace.Value}\n using container's ResourceId {simpleContainer.Id}.\n"); }
public async Task ThroughputTest() { int expectedThroughput = 2400; string containerName = Guid.NewGuid().ToString(); string partitionKeyPath = "/users"; ContainerResponse containerResponse = await this.database.DefineContainer(containerName, partitionKeyPath) .CreateAsync(expectedThroughput); Assert.AreEqual(HttpStatusCode.Created, containerResponse.StatusCode); CosmosContainer cosmosContainer = this.database.GetContainer(containerName); int?readThroughput = await cosmosContainer.ReadProvisionedThroughputAsync(); Assert.IsNotNull(readThroughput); Assert.AreEqual(expectedThroughput, readThroughput); containerResponse = await cosmosContainer.DeleteAsync(); Assert.AreEqual(HttpStatusCode.NoContent, containerResponse.StatusCode); }