Skip to content

Commit

Permalink
Merge branch 'users/askagarw/summaryDiagnosticsImproved' of https://g…
Browse files Browse the repository at this point in the history
…ithub.com/Azure/azure-cosmos-dotnet-v3 into users/askagarw/summaryDiagnosticsImproved
  • Loading branch information
asketagarwal committed Sep 15, 2021
2 parents fe59982 + 50735e9 commit e6429ee
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal ClientEncryptionKeyProperties(ClientEncryptionKeyProperties source)
/// <summary>
/// Encryption algorithm that will be used along with this client encryption key to encrypt/decrypt data.
/// </summary>
[JsonProperty(PropertyName = Constants.Properties.EncryptionAlgorithmId, NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(PropertyName = Constants.Properties.EncryptionAlgorithm, NullValueHandling = NullValueHandling.Ignore)]
public string EncryptionAlgorithm { get; internal set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,39 @@ public async Task ChangeFeedIteratorCore_CannotMixTokensFromOtherContainers()
Assert.AreEqual(HttpStatusCode.BadRequest, responseMessage.StatusCode);
}

/// <summary>
/// This test validates Incremental Change Feed by inserting and deleting documents and verifying nothing reported
/// </summary>
[TestMethod]
public async Task ChangeFeedIteratorCore_DeleteAfterCreate()
{
ContainerProperties properties = new ContainerProperties(id: Guid.NewGuid().ToString(), partitionKeyPath: ChangeFeedIteratorCoreTests.PartitionKey);
properties.ChangeFeedPolicy.FullFidelityRetention = TimeSpan.FromMinutes(5);
ContainerResponse response = await this.database.CreateContainerAsync(
properties,
cancellationToken: this.cancellationToken);
ContainerInternal container = (ContainerInternal)response;
// Insert documents and then delete them
int totalDocuments = 50;
IList<ToDoActivity> createdItems = await this.CreateRandomItems(container, totalDocuments, randomPartitionKey: true);
foreach (ToDoActivity item in createdItems)
{
await container.DeleteItemAsync<ToDoActivity>(item.id, new PartitionKey(item.pk));
}
FeedIterator<ToDoActivityWithMetadata> changefeedIterator = container.GetChangeFeedIterator<ToDoActivityWithMetadata>(
ChangeFeedStartFrom.Beginning(),
ChangeFeedMode.Incremental);
while (changefeedIterator.HasMoreResults)
{
FeedResponse<ToDoActivityWithMetadata> feedResponse = await changefeedIterator.ReadNextAsync(this.cancellationToken);
Assert.AreEqual(HttpStatusCode.NotModified, feedResponse.StatusCode, "Incremental Change Feed does not present intermediate results and should return nothing.");
if (feedResponse.StatusCode == HttpStatusCode.NotModified)
{
break;
}
}
}

/// <summary>
/// This test validates Full Fidelity Change Feed by inserting and deleting documents and verifying all operations are present
/// </summary>
Expand Down Expand Up @@ -791,6 +824,31 @@ public async Task TestCancellationTokenAsync()
}
}

/// <summary>
/// This test validates error with Full Fidelity Change Feed and start from beginning.
/// </summary>
[TestMethod]
public async Task ChangeFeedIteratorCore_WithFullFidelityReadFromBeginning()
{
ContainerProperties properties = new ContainerProperties(id: Guid.NewGuid().ToString(), partitionKeyPath: ChangeFeedIteratorCoreTests.PartitionKey);
properties.ChangeFeedPolicy.FullFidelityRetention = TimeSpan.FromMinutes(5);
ContainerResponse response = await this.database.CreateContainerAsync(
properties,
cancellationToken: this.cancellationToken);
ContainerInternal container = (ContainerInternal)response;
int totalDocuments = 10;
await this.CreateRandomItems(container, totalDocuments, randomPartitionKey: true);

// FF does not work with StartFromBeginning currently, capture error
FeedIterator<ToDoActivityWithMetadata> fullFidelityIterator = container.GetChangeFeedIterator<ToDoActivityWithMetadata>(
ChangeFeedStartFrom.Beginning(),
ChangeFeedMode.FullFidelity);

CosmosException cosmosException = await Assert.ThrowsExceptionAsync<CosmosException>(() => fullFidelityIterator.ReadNextAsync());
Assert.AreEqual(HttpStatusCode.BadRequest, cosmosException.StatusCode, "Full Fidelity Change Feed does not work with StartFromBeginning currently.");
Assert.IsTrue(cosmosException.Message.Contains("FullFidelity Change Feed must have valid If-None-Match header."));
}

private async Task<IList<ToDoActivity>> CreateRandomItems(ContainerInternal container, int pkCount, int perPKItemCount = 1, bool randomPartitionKey = true)
{
Assert.IsFalse(!randomPartitionKey && perPKItemCount > 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
],
"MethodInfo": "System.Nullable`1[System.DateTime] LastModified;CanRead:True;CanWrite:True;System.Nullable`1[System.DateTime] get_LastModified();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"System.String EncryptionAlgorithm[Newtonsoft.Json.JsonPropertyAttribute(NullValueHandling = 1, PropertyName = \"encryptionAlgorithmId\")]": {
"System.String EncryptionAlgorithm[Newtonsoft.Json.JsonPropertyAttribute(NullValueHandling = 1, PropertyName = \"encryptionAlgorithm\")]": {
"Type": "Property",
"Attributes": [
"JsonPropertyAttribute"
Expand Down

0 comments on commit e6429ee

Please sign in to comment.