Skip to content

Commit

Permalink
Cosmos DB: update to 2019 12 and add interface (#994)
Browse files Browse the repository at this point in the history
* feat: generate cosmos db 2019 12

* fix: compile error, options: dictionary -> CreateUpdateOption

* feat: add interface for cosmos db

* feat: update location interface for cosmos db

* feat: update sql interface

* feat: implement cosmos db account

* feat: implement for index policy

* feat: implement for sql container

* feat: update test case

* fix: test error

* fix: Idictionary<string, string> serialization error

* fix: update test case

* feat: update session record

* feat: add key vault uri in property

* fix: compile error in low version

* feat: add breaking change note
  • Loading branch information
ChenTanyi authored Mar 5, 2020
1 parent e9dd0d3 commit 5ca9dab
Show file tree
Hide file tree
Showing 80 changed files with 29,408 additions and 24,261 deletions.
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

0 comments on commit 5ca9dab

Please sign in to comment.