-
Notifications
You must be signed in to change notification settings - Fork 2.1k
ThinClient E2E Integration #44854
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
Merged
Merged
ThinClient E2E Integration #44854
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d7b6835
add changes for thin client e2e integration.
nehrao1 d47a232
pr comments
nehrao1 ca85acb
pr comments
nehrao1 7180a54
pr comments
nehrao1 62a3284
remove redundant metadata check from earlier causing direct mode test…
nehrao1 0a33a49
add thinclient profile and stage to live tests
nehrao1 9ada50c
modify useThinClient()
nehrao1 375c49a
pr comments
nehrao1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
...s/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/ThinClientE2ETest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
| package com.azure.cosmos.implementation; | ||
nehrao1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import com.azure.cosmos.ConsistencyLevel; | ||
| import com.azure.cosmos.CosmosAsyncClient; | ||
| import com.azure.cosmos.CosmosAsyncContainer; | ||
| import com.azure.cosmos.CosmosClientBuilder; | ||
| import com.azure.cosmos.models.CosmosItemRequestOptions; | ||
| import com.azure.cosmos.models.CosmosItemResponse; | ||
| import com.azure.cosmos.models.CosmosPatchOperations; | ||
| import com.azure.cosmos.models.PartitionKey; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
|
||
| public class ThinClientE2ETest extends com.azure.cosmos.rx.TestSuiteBase { | ||
| @Test(groups = {"thinclient"}) | ||
| public void testThinClientDocumentPointOperations() { | ||
| CosmosAsyncClient client = null; | ||
| try { | ||
| System.setProperty("COSMOS.THINCLIENT_ENABLED", "true"); | ||
| System.setProperty("COSMOS.HTTP2_ENABLED", "true"); | ||
|
|
||
| String thinclientTestEndpoint = System.getProperty("COSMOS.THINCLIENT_ENDPOINT"); | ||
| String thinclientTestKey = System.getProperty("COSMOS.THINCLIENT_KEY"); | ||
|
|
||
| client = new CosmosClientBuilder() | ||
| .endpoint(thinclientTestEndpoint) | ||
| .key(thinclientTestKey) | ||
| .gatewayMode() | ||
| .consistencyLevel(ConsistencyLevel.SESSION) | ||
| .buildAsyncClient(); | ||
|
|
||
| CosmosAsyncContainer container = client.getDatabase("updatedd-thin-client-test-db").getContainer("thin-client-test-container-1"); | ||
| ObjectMapper mapper = new ObjectMapper(); | ||
| ObjectNode doc = mapper.createObjectNode(); | ||
| String idValue = UUID.randomUUID().toString(); | ||
| doc.put("id", idValue); | ||
| doc.put("pk", idValue); | ||
|
|
||
| // create | ||
| // todo: test other overloads for create | ||
| CosmosItemResponse<ObjectNode> createResponse = container.createItem(doc).block(); | ||
| assertThat(createResponse.getStatusCode()).isEqualTo(201); | ||
| assertThat(createResponse.getRequestCharge()).isGreaterThan(0.0); | ||
|
|
||
| // read | ||
| // todo: test other overloads for read | ||
| CosmosItemResponse<ObjectNode> readResponse = container.readItem(idValue, new PartitionKey(idValue), ObjectNode.class).block(); | ||
| assertThat(readResponse.getStatusCode()).isEqualTo(200); | ||
| assertThat(readResponse.getRequestCharge()).isGreaterThan(0.0); | ||
|
|
||
| ObjectNode doc2 = mapper.createObjectNode(); | ||
| String idValue2 = UUID.randomUUID().toString(); | ||
| doc2.put("id", idValue2); | ||
| doc2.put("pk", idValue); | ||
|
|
||
| // replace | ||
| // todo: test other overloads for replace | ||
| CosmosItemResponse<ObjectNode> replaceResponse = container.replaceItem(doc2, idValue, new PartitionKey(idValue)).block(); | ||
| assertThat(replaceResponse.getStatusCode()).isEqualTo(200); | ||
| assertThat(replaceResponse.getRequestCharge()).isGreaterThan(0.0); | ||
| CosmosItemResponse<ObjectNode> readAfterReplaceResponse = container.readItem(idValue2, new PartitionKey(idValue), ObjectNode.class).block(); | ||
| assertThat(readAfterReplaceResponse.getStatusCode()).isEqualTo(200); | ||
| ObjectNode replacedItemFromRead = readAfterReplaceResponse.getItem(); | ||
| assertThat(replacedItemFromRead.get("id").asText()).isEqualTo(idValue2); | ||
| assertThat(replacedItemFromRead.get("pk").asText()).isEqualTo(idValue); | ||
|
|
||
| ObjectNode doc3 = mapper.createObjectNode(); | ||
| doc3.put("id", idValue2); | ||
| doc3.put("pk", idValue); | ||
| doc3.put("newField", "newValue"); | ||
|
|
||
| // upsert | ||
| // todo: test other overloads for upsert | ||
| CosmosItemResponse<ObjectNode> upsertResponse = container.upsertItem(doc3, new PartitionKey(idValue), new CosmosItemRequestOptions()).block(); | ||
| assertThat(upsertResponse.getStatusCode()).isEqualTo(200); | ||
| assertThat(upsertResponse.getRequestCharge()).isGreaterThan(0.0); | ||
| CosmosItemResponse<ObjectNode> readAfterUpsertResponse = container.readItem(idValue2, new PartitionKey(idValue), ObjectNode.class).block(); | ||
| ObjectNode upsertedItemFromRead = readAfterUpsertResponse.getItem(); | ||
| assertThat(upsertedItemFromRead.get("id").asText()).isEqualTo(idValue2); | ||
| assertThat(upsertedItemFromRead.get("pk").asText()).isEqualTo(idValue); | ||
| assertThat(upsertedItemFromRead.get("newField").asText()).isEqualTo("newValue"); | ||
|
|
||
| // patch | ||
| // todo: test other overloads for patch | ||
| CosmosPatchOperations patchOperations = CosmosPatchOperations.create(); | ||
| patchOperations.add("/anotherNewField", "anotherNewValue"); | ||
| patchOperations.replace("/newField", "patchedNewField"); | ||
| CosmosItemResponse<ObjectNode> patchResponse = container.patchItem(idValue2, new PartitionKey(idValue), patchOperations, ObjectNode.class).block(); | ||
| assertThat(patchResponse.getStatusCode()).isEqualTo(200); | ||
| assertThat(patchResponse.getRequestCharge()).isGreaterThan(0.0); | ||
| CosmosItemResponse<ObjectNode> readAfterPatchResponse = container.readItem(idValue2, new PartitionKey(idValue), ObjectNode.class).block(); | ||
| ObjectNode patchedItemFromRead = readAfterPatchResponse.getItem(); | ||
| assertThat(patchedItemFromRead.get("id").asText()).isEqualTo(idValue2); | ||
| assertThat(patchedItemFromRead.get("pk").asText()).isEqualTo(idValue); | ||
| assertThat(patchedItemFromRead.get("newField").asText()).isEqualTo("patchedNewField"); | ||
| assertThat(patchedItemFromRead.get("anotherNewField").asText()).isEqualTo("anotherNewValue"); | ||
|
|
||
| // delete | ||
| // todo: test other overloads for delete | ||
nehrao1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| CosmosItemResponse<Object> deleteResponse = container.deleteItem(idValue2, new PartitionKey(idValue)).block(); | ||
| assertThat(deleteResponse.getStatusCode()).isEqualTo(204); | ||
| assertThat(deleteResponse.getRequestCharge()).isGreaterThan(0.0); | ||
| } finally { | ||
nehrao1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| System.clearProperty("COSMOS.THINCLIENT_ENABLED"); | ||
| System.clearProperty("COSMOS.HTTP2_ENABLED"); | ||
| client.close(); | ||
| } | ||
| } | ||
| } | ||
35 changes: 35 additions & 0 deletions
35
sdk/cosmos/azure-cosmos-tests/src/test/resources/thinclient-testng.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <!-- | ||
| ~ The MIT License (MIT) | ||
| ~ Copyright (c) 2018 Microsoft Corporation | ||
| ~ | ||
| ~ Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| ~ of this software and associated documentation files (the "Software"), to deal | ||
| ~ in the Software without restriction, including without limitation the rights | ||
| ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| ~ copies of the Software, and to permit persons to whom the Software is | ||
| ~ furnished to do so, subject to the following conditions: | ||
| ~ | ||
| ~ The above copyright notice and this permission notice shall be included in all | ||
| ~ copies or substantial portions of the Software. | ||
| ~ | ||
| ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| ~ SOFTWARE. | ||
| --> | ||
| <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd"> | ||
| <suite name="thinclient"> | ||
| <test name="thinclient" group-by-instances="true"> | ||
| <groups> | ||
| <run> | ||
| <include name="thinclient"/> | ||
| </run> | ||
| </groups> | ||
| <packages> | ||
| <package name="com.azure.cosmos.*"/> | ||
| </packages> | ||
| </test> | ||
| </suite> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.