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

Statistics not getting populated correctly on CosmosException #846

Merged
merged 11 commits into from
Sep 27, 2019
Prev Previous commit
Next Next commit
Making test more robust
ealsur committed Sep 24, 2019
commit a5b55b8063caeca87e70673d99fda860eb6086d3
Original file line number Diff line number Diff line change
@@ -1536,18 +1536,27 @@ public async Task VerifySessionTokenPassThrough()
[TestMethod]
public async Task VerifySessionNotFoundStatistics()
{
ToDoActivity temp = ToDoActivity.CreateRandomToDoActivity("TBD");

string invalidSessionToken = "0:-1#20";
Container container = await this.database.CreateContainerIfNotExistsAsync("NoSession", "/id");

try
{
ItemResponse<ToDoActivity> readResponse = await this.Container.ReadItemAsync<ToDoActivity>(temp.id, new Cosmos.PartitionKey(temp.status), new ItemRequestOptions() { SessionToken = invalidSessionToken });
Assert.Fail("Should had thrown ReadSessionNotAvailable");
ToDoActivity temp = ToDoActivity.CreateRandomToDoActivity("TBD");

string invalidSessionToken = "0:-1#2000";

try
{
ItemResponse<ToDoActivity> readResponse = await container.ReadItemAsync<ToDoActivity>(temp.id, new Cosmos.PartitionKey(temp.status), new ItemRequestOptions() { SessionToken = invalidSessionToken });
Assert.Fail("Should had thrown ReadSessionNotAvailable");
}
catch (CosmosException cosmosException)
{
Assert.IsTrue(cosmosException.Message.Contains("ContactedReplicas"), cosmosException.Message);
}
}
catch (CosmosException cosmosException)
finally
{
Assert.IsTrue(cosmosException.Message.Contains("ContactedReplicas"));
await container.DeleteContainerAsync();
}
}