Skip to content

Commit

Permalink
ChangeFeedProcessor now does not force refresh cache. PartitionKeyRan…
Browse files Browse the repository at this point in the history
…ge validation is opt-in instead of default on.
  • Loading branch information
Jake Willey committed Apr 21, 2021
1 parent 6b6feb8 commit 9d7fad1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public override async Task CreateMissingLeasesAsync()
this.containerRid,
FeedRangeEpk.FullRange.Range,
NoOpTrace.Singleton,
forceRefresh: true);
forceRefresh: false);
DefaultTrace.TraceInformation("Source collection: '{0}', {1} partition(s)", this.container.LinkUri, ranges.Count);
await this.CreateLeasesAsync(ranges).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class CosmosItemTests : BaseCosmosClientHelper
[TestInitialize]
public async Task TestInitialize()
{
await base.TestInit();
await base.TestInit(validateSinglePartitionKeyRangeCacheCall: true);
string PartitionKey = "/pk";
this.containerSettings = new ContainerProperties(id: Guid.NewGuid().ToString(), partitionKeyPath: PartitionKey);
ContainerResponse response = await this.database.CreateContainerAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public abstract class BaseCosmosClientHelper
protected CancellationTokenSource cancellationTokenSource = null;
protected CancellationToken cancellationToken;

public async Task TestInit()
public async Task TestInit(bool validateSinglePartitionKeyRangeCacheCall = false)
{
this.cancellationTokenSource = new CancellationTokenSource();
this.cancellationToken = this.cancellationTokenSource.Token;

this.cosmosClient = TestCommon.CreateCosmosClient();
this.cosmosClient = TestCommon.CreateCosmosClient(validatePartitionKeyRangeCalls: validateSinglePartitionKeyRangeCacheCall);
this.database = await this.cosmosClient.CreateDatabaseAsync(Guid.NewGuid().ToString(),
cancellationToken: this.cancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

public class HttpHandlerMetaDataValidator : DelegatingHandler
{
private readonly ConcurrentDictionary<Uri, int> numOfPkRangeCachePerCollection = new ConcurrentDictionary<Uri, int>();

public HttpHandlerMetaDataValidator() : base(new HttpClientHandler())
{
}
Expand All @@ -23,7 +21,7 @@ public HttpHandlerMetaDataValidator() : base(new HttpClientHandler())

protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
HttpResponseMessage httpResponseMessage = await base.SendAsync(request, cancellationToken);;
HttpResponseMessage httpResponseMessage = await base.SendAsync(request, cancellationToken); ;
if (request.Method == HttpMethod.Get)
{
if (httpResponseMessage.StatusCode == System.Net.HttpStatusCode.NotModified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ internal static (string endpoint, string authKey) GetAccountInfo()

internal static CosmosClientBuilder GetDefaultConfiguration(
bool useCustomSeralizer = true,
bool validatePartitionKeyRangeCalls = true)
bool validatePartitionKeyRangeCalls = false)
{
(string endpoint, string authKey) = TestCommon.GetAccountInfo();
CosmosClientBuilder clientBuilder = new CosmosClientBuilder(accountEndpoint: endpoint, authKeyOrResourceToken: authKey);
Expand All @@ -94,7 +94,7 @@ internal static CosmosClientBuilder GetDefaultConfiguration(
internal static CosmosClient CreateCosmosClient(
Action<CosmosClientBuilder> customizeClientBuilder = null,
bool useCustomSeralizer = true,
bool validatePartitionKeyRangeCalls = true)
bool validatePartitionKeyRangeCalls = false)
{
CosmosClientBuilder cosmosClientBuilder = GetDefaultConfiguration(useCustomSeralizer, validatePartitionKeyRangeCalls);
customizeClientBuilder?.Invoke(cosmosClientBuilder);
Expand All @@ -107,7 +107,7 @@ internal static CosmosClient CreateCosmosClient(
internal static CosmosClient CreateCosmosClient(
CosmosClientOptions clientOptions,
string resourceToken = null,
bool validatePartitionKeyRangeCalls = true)
bool validatePartitionKeyRangeCalls = false)
{
string authKey = resourceToken ?? ConfigurationManager.AppSettings["MasterKey"];
string endpoint = ConfigurationManager.AppSettings["GatewayEndpoint"];
Expand Down

0 comments on commit 9d7fad1

Please sign in to comment.