Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmos DB: update to 2019 12 and add interface #994

Merged
merged 16 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions Tests/Fluent.Tests/CosmosDB/CosmosDBTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.Azure.Management.ResourceManager.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent.Core;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Linq;
using Xunit;
Expand Down Expand Up @@ -37,7 +38,7 @@ public void CosmosDBCRUD()
.WithKind(DatabaseAccountKind.GlobalDocumentDB)
.WithSessionConsistency()
.WithWriteReplication(Region.USWest)
.WithReadReplication(Region.USCentral)
.WithReadReplication(Region.USCentral, true)
.WithIpRangeFilter("")
.WithMultipleWriteLocationsEnabled(true)
.Create();
Expand All @@ -46,15 +47,18 @@ public void CosmosDBCRUD()
Assert.Equal(DatabaseAccountKind.GlobalDocumentDB.Value, databaseAccount.Kind);
Assert.Equal(2, databaseAccount.WritableReplications.Count);
Assert.Equal(2, databaseAccount.ReadableReplications.Count);
Assert.True(databaseAccount.ReadableReplications.First(l => l.LocationName.ToLower().Replace(" ", "") == Region.USCentral.ToString()).IsZoneRedundant);
Assert.Equal(DefaultConsistencyLevel.Session, databaseAccount.DefaultConsistencyLevel);
Assert.True(databaseAccount.MultipleWriteLocationsEnabled);

databaseAccount = databaseAccount.Update()
.WithReadReplication(Region.AsiaSouthEast)
.WithoutReadReplication(Region.USEast)
.WithoutReadReplication(Region.USCentral)
.WithoutAllReplications()
.WithWriteReplication(Region.USWest)
.WithReadReplication(Region.USEast)
.Apply();

Assert.Equal(Region.USEast.ToString(), databaseAccount.WritableReplications.First(l => l.FailoverPriority == 1).LocationName.ToLower().Replace(" ", ""));

databaseAccount = databaseAccount.Update()
.WithEventualConsistency()
.WithTag("tag2", "value2")
Expand Down Expand Up @@ -297,13 +301,18 @@ public void CanCRUDSqlContainer()
.WithThroughput(400)
.DefineIndexingPolicy()
.WithIndexingMode(IndexingMode.Consistent)
.WithIncludedPath(new IncludedPath(path: "/*"))
.WithExcludedPath(new ExcludedPath(path: "/myPathToNotIndex/*"))
.WithIncludedPath("/*")
.WithExcludedPath("/myPathToNotIndex/*")
.WithCompositeIndexEmptyList()
.WithCompositePath("/myOrderByPath1", CompositePathSortOrder.Ascending)
.WithCompositePath("/myOrderByPath2", CompositePathSortOrder.Descending)
.Attach()
.Attach()
.WithPartitionKey(paths: new List<string>() { "/myPartitionKey" }, kind: PartitionKind.Hash, version: null)
.WithStoredProcedure("test", new SqlStoredProcedureResource(id: null, body: "function test(){}"))
.WithUserDefinedFunction("test", new SqlUserDefinedFunctionResource(id: null, body: "function test(){}"))
.WithTrigger("test", new SqlTriggerResource(id: null, body: "function test(){}", triggerType: TriggerType.Pre, triggerOperation: TriggerOperation.All))
.WithPartitionKey(PartitionKind.Hash, null)
.WithPartitionKeyPath("/myPartitionKey")
.WithStoredProcedure("test", "function test(){}")
.WithUserDefinedFunction("test", "function test(){}")
.WithTrigger("test", "function test(){}", TriggerType.Pre, TriggerOperation.All)
.Attach()
.Attach()
.Create();
Expand All @@ -326,6 +335,8 @@ public void CanCRUDSqlContainer()
Assert.Equal(IndexingMode.Consistent, container.IndexingPolicy.IndexingMode);
Assert.NotNull(container.IndexingPolicy.IncludedPaths.Single(element => element.Path == "/*"));
Assert.NotNull(container.IndexingPolicy.ExcludedPaths.Single(element => element.Path == "/myPathToNotIndex/*"));
Assert.Equal(1, container.IndexingPolicy.CompositeIndexes.Count);
Assert.Equal(2, container.IndexingPolicy.CompositeIndexes[0].Count);
Assert.True(container.PartitionKey.Paths.Contains("/myPartitionKey"));
Assert.Equal(PartitionKind.Hash, container.PartitionKey.Kind);
Assert.NotNull(container.GetStoredProcedure("test"));
Expand All @@ -335,9 +346,9 @@ public void CanCRUDSqlContainer()
databaseAccount = databaseAccount.Update()
.WithAutomaticFailoverEnabled(false)
.UpdateSqlDatabase(sqlDbName)
.WithOption("throughput", "800")
.WithThroughput(800)
.UpdateSqlContainer(sqlContainerName)
.WithOption("throughput", "600")
.WithThroughput(600)
.UpdateIndexingPolicy()
.WithoutExcludedPath("/myPathToNotIndex/*")
.Parent()
Expand Down Expand Up @@ -570,9 +581,9 @@ public void CanCRUDGremlinGraph()

databaseAccount = databaseAccount.Update()
.UpdateGremlinDatabase(gremlinName)
.WithOption("throughput", "800")
.WithThroughput(800)
.UpdateGremlinGraph(gremlinGraphName)
.WithOption("throughput", "600")
.WithThroughput(600)
.Parent()
.Parent()
.Apply();
Expand Down
Loading