Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ private void validateSubstatusCodeOnNotFoundExceptionInSessionReadAsync(boolean
validateSuccess(deleteObservable, validator);
Mono<ResourceResponse<Document>> readObservable = client.readDocument(document.getSelfLink(), requestOptions);
FailureValidator notFoundValidator = new FailureValidator.Builder().resourceNotFound().unknownSubStatusCode().build();
validateFailure(readObservable, notFoundValidator);
validateResourceResponseFailure(readObservable, notFoundValidator);

} finally {
safeClose(client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void validateNoChargeOnFailedSessionRead() throws Exception {
try {
// CREATE collection
DocumentCollection parentResource = writeClient.createCollection(createdDatabase.getSelfLink(),
getCollectionDefinition(), null).block().getResource();
getInternalCollectionDefinition(), null).block().getResource();

// Document to lock pause/resume clients
Document documentDefinition = getDocumentDefinition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


package com.azure.cosmos.implementation;
import com.azure.cosmos.rx.TestSuiteBase;

import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.ConsistencyLevel;
Expand Down Expand Up @@ -42,9 +43,9 @@ public class ConsistencyTestsBase extends TestSuiteBase {

@BeforeClass(groups = {"direct"}, timeOut = SETUP_TIMEOUT)
public void before_ConsistencyTestsBase() throws Exception {
initClient = createGatewayRxDocumentClient().build();
createdDatabase = SHARED_DATABASE;
createdCollection = SHARED_MULTI_PARTITION_COLLECTION;
initClient = createInternalGatewayRxDocumentClient().build();
createdDatabase = SHARED_DATABASE_INTERNAL;
createdCollection = SHARED_MULTI_PARTITION_COLLECTION_INTERNAL;
}

void validateStrongConsistency(
Expand Down Expand Up @@ -85,7 +86,7 @@ void validateConsistentLSN(RxDocumentClientImpl readClient, RxDocumentClientImpl
assertThat(quorumAckedLSN > 0).isTrue();
FailureValidator validator = new FailureValidator.Builder().statusCode(404).lsnGreaterThan(quorumAckedLSN).build();
Mono<ResourceResponse<Document>> readObservable = readClient.readDocument(document.getSelfLink(), options);
validateFailure(readObservable, validator);
validateResourceResponseFailure(readObservable, validator);
}

void validateConsistentLSNAndQuorumAckedLSN(RxDocumentClientImpl readClient, RxDocumentClientImpl writeClient) {
Expand All @@ -101,7 +102,7 @@ void validateConsistentLSNAndQuorumAckedLSN(RxDocumentClientImpl readClient, RxD

FailureValidator validator = new FailureValidator.Builder().statusCode(404).lsnGreaterThanEqualsTo(quorumAckedLSN).exceptionQuorumAckedLSNInNotNull().build();
Mono<ResourceResponse<Document>> readObservable = readClient.deleteDocument(document.getSelfLink(), options);
validateFailure(readObservable, validator);
validateResourceResponseFailure(readObservable, validator);

}

Expand Down Expand Up @@ -206,7 +207,7 @@ void validateSessionContainerAfterCollectionCreateReplace(boolean useGateway) {
DocumentCollection coll = null;
{
// self link
ResourceResponse<DocumentCollection> collection = writeClient.createCollection(createdDatabase.getSelfLink(), getCollectionDefinition(), null).block();
ResourceResponse<DocumentCollection> collection = writeClient.createCollection(createdDatabase.getSelfLink(), getInternalCollectionDefinition(), null).block();
String globalSessionToken1 = writeClient.getSession().getSessionToken(collection.getResource().getSelfLink());
String globalSessionToken2 = writeClient.getSession().getSessionToken(BridgeInternal.getAltLink(collection.getResource()));
System.out.println("BridgeInternal.getAltLink(collection.getResource()) " + BridgeInternal.getAltLink(collection.getResource()));
Expand All @@ -220,7 +221,7 @@ void validateSessionContainerAfterCollectionCreateReplace(boolean useGateway) {
}
{
// name link
ResourceResponse<DocumentCollection> collection = writeClient.createCollection(BridgeInternal.getAltLink(createdDatabase), getCollectionDefinition(), null).block();
ResourceResponse<DocumentCollection> collection = writeClient.createCollection(BridgeInternal.getAltLink(createdDatabase), getInternalCollectionDefinition(), null).block();

String globalSessionToken1 = writeClient.getSession().getSessionToken(collection.getResource().getSelfLink());
String globalSessionToken2 = writeClient.getSession().getSessionToken(BridgeInternal.getAltLink(collection.getResource()));
Expand Down Expand Up @@ -427,7 +428,7 @@ void validateSessionContainerAfterCollectionDeletion(boolean useGateway, boolean

String collectionId = UUID.randomUUID().toString();
try {
DocumentCollection collectionDefinition = getCollectionDefinition();
DocumentCollection collectionDefinition = getInternalCollectionDefinition();
collectionDefinition.setId(collectionId);
DocumentCollection collection = createCollection(client2, createdDatabase.getId(), collectionDefinition, null);
ResourceResponseValidator<DocumentCollection> successValidatorCollection = new ResourceResponseValidator.Builder<DocumentCollection>()
Expand All @@ -449,7 +450,7 @@ void validateSessionContainerAfterCollectionDeletion(boolean useGateway, boolean

{
// just create the second for fun
DocumentCollection collection2 = createCollection(client2, createdDatabase.getId(), getCollectionDefinition(), null);
DocumentCollection collection2 = createCollection(client2, createdDatabase.getId(), getInternalCollectionDefinition(), null);
successValidatorCollection = new ResourceResponseValidator.Builder<DocumentCollection>()
.withId(collection2.getId())
.build();
Expand All @@ -466,8 +467,8 @@ void validateSessionContainerAfterCollectionDeletion(boolean useGateway, boolean
// now delete collection use different client
client1.deleteCollection(collection.getSelfLink(), null).block();

DocumentCollection collectionRandom1 = createCollection(client2, createdDatabase.getId(), getCollectionDefinition());
DocumentCollection documentCollection = getCollectionDefinition();
DocumentCollection collectionRandom1 = createCollection(client2, createdDatabase.getId(), getInternalCollectionDefinition());
DocumentCollection documentCollection = getInternalCollectionDefinition();
collectionDefinition.setId(collectionId);
DocumentCollection collectionSameName = createCollection(client2, createdDatabase.getId(), collectionDefinition);
String documentId1 = "Generation2-" + 0;
Expand Down Expand Up @@ -497,7 +498,7 @@ void validateSessionContainerAfterCollectionDeletion(boolean useGateway, boolean
requestOptions1.setPartitionKey(new PartitionKey(createdDocument.get("mypk")));
readObservable = client2.readDocument(BridgeInternal.getAltLink(createdDocument), requestOptions1);
FailureValidator failureValidator = new FailureValidator.Builder().subStatusCode(1002).build();
validateFailure(readObservable, failureValidator);
validateResourceResponseFailure(readObservable, failureValidator);
}
// this will trigger client2 to clear the token
{
Expand Down Expand Up @@ -584,7 +585,7 @@ void validateSessionTokenWithPreConditionFailureBase(boolean useGateway, boolean
Mono<ResourceResponse<Document>> preConditionFailureResponseObservable = validationClient.upsertDocument(BridgeInternal.getAltLink(createdCollection),
documentResponse.getResource(), requestOptions1, true);
FailureValidator failureValidator = new FailureValidator.Builder().statusCode(HttpConstants.StatusCodes.PRECONDITION_FAILED).build();
validateFailure(preConditionFailureResponseObservable, failureValidator);
validateResourceResponseFailure(preConditionFailureResponseObservable, failureValidator);
assertThat(isSessionEqual(validationClient.getSession(), writeClient.getSession())).isTrue();

} finally {
Expand Down Expand Up @@ -625,7 +626,7 @@ void validateSessionTokenWithDocumentNotFoundExceptionBase(boolean useGateway, b
.sendClientTelemetryToService(ClientTelemetry.DEFAULT_CLIENT_TELEMETRY_ENABLED))
.build();
try {
DocumentCollection collectionDefinition = getCollectionDefinition();
DocumentCollection collectionDefinition = getInternalCollectionDefinition();
collectionDefinition.setId("TestCollection");

ResourceResponse<Document> documentResponse = writeClient.createDocument(BridgeInternal.getAltLink(createdCollection), getDocumentDefinition(), null, true).block();
Expand All @@ -635,7 +636,7 @@ void validateSessionTokenWithDocumentNotFoundExceptionBase(boolean useGateway, b
requestOptions.setPartitionKey(new PartitionKey(documentResponse.getResource().get("mypk")));
// try to read a non existent document in the same partition that we previously wrote to
Mono<ResourceResponse<Document>> readObservable = validationClient.readDocument(BridgeInternal.getAltLink(documentResponse.getResource()) + "dummy", requestOptions);
validateFailure(readObservable, failureValidator);
validateResourceResponseFailure(readObservable, failureValidator);
assertThat(isSessionEqual(validationClient.getSession(), writeClient.getSession())).isTrue();
} finally {
safeClose(writeClient);
Expand Down Expand Up @@ -676,7 +677,7 @@ void validateSessionTokenWithExpectedExceptionBase(boolean useGateway, boolean i
// try to read a non existent document in the same partition that we previously wrote to
Mono<ResourceResponse<Document>> readObservable = writeClient.readDocument(BridgeInternal.getAltLink(documentResponse.getResource()),
requestOptions);
validateFailure(readObservable, failureValidator);
validateResourceResponseFailure(readObservable, failureValidator);
} finally {
safeClose(writeClient);
}
Expand Down Expand Up @@ -722,7 +723,7 @@ void validateSessionTokenWithConflictExceptionBase(boolean useGateway, boolean i
Mono<ResourceResponse<Document>> conflictDocumentResponse = validationClient.createDocument(BridgeInternal.getAltLink(createdCollection),
documentDefinition, null,
true);
validateFailure(conflictDocumentResponse, failureValidator);
validateResourceResponseFailure(conflictDocumentResponse, failureValidator);
assertThat(isSessionEqual(validationClient.getSession(), writeClient.getSession())).isTrue();
} finally {
safeClose(writeClient);
Expand Down Expand Up @@ -800,12 +801,12 @@ void validateSessionTokenMultiPartitionCollectionBase(boolean useGateway, boolea
Mono<ResourceResponse<Document>> readObservable = writeClient.readDocument(childResource1.getResource().getSelfLink(), option);
FailureValidator failureValidator =
new FailureValidator.Builder().statusCode(HttpConstants.StatusCodes.NOTFOUND).subStatusCode(HttpConstants.SubStatusCodes.READ_SESSION_NOT_AVAILABLE).build();
validateFailure(readObservable, failureValidator);
validateResourceResponseFailure(readObservable, failureValidator);

readObservable = writeClient.readDocument(childResource2.getResource().getSelfLink(), option);
failureValidator =
new FailureValidator.Builder().statusCode(HttpConstants.StatusCodes.NOTFOUND).subStatusCode(HttpConstants.SubStatusCodes.READ_SESSION_NOT_AVAILABLE).build();
validateFailure(readObservable, failureValidator);
validateResourceResponseFailure(readObservable, failureValidator);

assertThat(writeClient.getSession().getSessionToken(createdCollection.getSelfLink())).isEqualTo
(writeClient.getSession().getSessionToken(BridgeInternal.getAltLink(createdCollection)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.cosmos.implementation;
import com.azure.cosmos.rx.TestSuiteBase;

import com.azure.cosmos.models.CosmosQueryRequestOptions;
import com.azure.cosmos.models.FeedResponse;
Expand Down Expand Up @@ -42,7 +43,7 @@ public String getMultiPartitionCollectionLink() {
return TestUtils.getCollectionNameLink(createdDatabase.getId(), createdMultiPartitionCollection.getId());
}

@Factory(dataProvider = "clientBuilders")
@Factory(dataProvider = "internalClientBuilders")
public DocumentQuerySpyWireContentTest(Builder clientBuilder) {
super(clientBuilder);
}
Expand Down Expand Up @@ -154,12 +155,12 @@ public void before_DocumentQuerySpyWireContentTest() throws Exception {

client = new SpyClientBuilder(this.clientBuilder()).build();

createdDatabase = SHARED_DATABASE;
createdSinglePartitionCollection = SHARED_SINGLE_PARTITION_COLLECTION;
truncateCollection(SHARED_SINGLE_PARTITION_COLLECTION);
createdDatabase = SHARED_DATABASE_INTERNAL;
createdSinglePartitionCollection = SHARED_SINGLE_PARTITION_COLLECTION_INTERNAL;
truncateCollection(SHARED_SINGLE_PARTITION_COLLECTION_INTERNAL);

createdMultiPartitionCollection = SHARED_MULTI_PARTITION_COLLECTION;
truncateCollection(SHARED_MULTI_PARTITION_COLLECTION);
createdMultiPartitionCollection = SHARED_MULTI_PARTITION_COLLECTION_INTERNAL;
truncateCollection(SHARED_MULTI_PARTITION_COLLECTION_INTERNAL);

for(int i = 0; i < 3; i++) {
createdDocumentsInSinglePartitionCollection.add(createDocument(client, getCollectionLink(createdSinglePartitionCollection), i));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.cosmos.implementation;
import com.azure.cosmos.rx.TestSuiteBase;

import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.DirectConnectionConfig;
Expand Down Expand Up @@ -423,16 +424,16 @@ private void executeCreateRecoversFrom410GoneOnPartitionSplitDuringIdleTime(

@AfterMethod(groups = { "direct" }, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true)
public void afterMethod() {
deleteCollectionIfExists(client, SHARED_DATABASE.getId(), createdCollection.getId());
deleteCollectionIfExists(client, SHARED_DATABASE_INTERNAL.getId(), createdCollection.getId());
safeClose(client);
}

@BeforeMethod(groups = { "direct" })
public void beforeMethod(Method method) {
RequestOptions options = new RequestOptions();
options.setOfferThroughput(40100);
createdDatabase = SHARED_DATABASE;
createdCollection = createCollection(createdDatabase.getId(), getCollectionDefinition(), options);
createdDatabase = SHARED_DATABASE_INTERNAL;
createdCollection = createCollection(createdDatabase.getId(), getInternalCollectionDefinition(), options);
client = SpyClientUnderTestFactory.createClientUnderTest(clientBuilder());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

package com.azure.cosmos.implementation;
import com.azure.cosmos.rx.TestSuiteBase;

import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.CosmosException;
Expand All @@ -23,7 +24,7 @@ public class NetworkFailureTest extends TestSuiteBase {
@Factory(dataProvider = "simpleClientBuildersWithDirect")
public NetworkFailureTest(AsyncDocumentClient.Builder clientBuilder) {
super(clientBuilder);
this.collectionDefinition = getCollectionDefinition();
this.collectionDefinition = getInternalCollectionDefinition();
}

@Test(groups = { "long-emulator" }, timeOut = TIMEOUT)
Expand All @@ -33,7 +34,7 @@ public void createCollectionWithUnreachableHost() {
try {
client = SpyClientUnderTestFactory.createClientWithGatewaySpy(clientBuilder());

Database database = SHARED_DATABASE;
Database database = SHARED_DATABASE_INTERNAL;

Mono<ResourceResponse<DocumentCollection>> createObservable = client
.createCollection(database.getSelfLink(), collectionDefinition, null);
Expand All @@ -57,7 +58,7 @@ public void createCollectionWithUnreachableHost() {

FailureValidator validator = new FailureValidator.Builder().instanceOf(CosmosException.class).build();
Instant start = Instant.now();
validateFailure(createObservable, validator, TIMEOUT);
validateResourceResponseFailure(createObservable, validator, TIMEOUT);
Instant after = Instant.now();
assertThat(after.toEpochMilli() - start.toEpochMilli())
.isGreaterThanOrEqualTo(ClientRetryPolicy.MaxRetryCount * ClientRetryPolicy.RetryIntervalInMS);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.cosmos.implementation;
import com.azure.cosmos.rx.TestSuiteBase;

import com.azure.cosmos.CosmosItemSerializer;
import com.azure.cosmos.implementation.AsyncDocumentClient.Builder;
Expand Down Expand Up @@ -43,7 +44,7 @@ public String getDocumentLink() {
return TestUtils.getDocumentNameLink(createdDatabase.getId(), createdCollection.getId(), DOCUMENT_ID);
}

@Factory(dataProvider = "clientBuilders")
@Factory(dataProvider = "internalClientBuilders")
public RequestHeadersSpyWireTest(Builder clientBuilder) {
super(clientBuilder);
}
Expand Down Expand Up @@ -371,9 +372,9 @@ public void before_DocumentQuerySpyWireContentTest() throws Exception {

client = new SpyClientBuilder(this.clientBuilder()).build();

createdDatabase = SHARED_DATABASE;
createdCollection = SHARED_SINGLE_PARTITION_COLLECTION;
truncateCollection(SHARED_SINGLE_PARTITION_COLLECTION);
createdDatabase = SHARED_DATABASE_INTERNAL;
createdCollection = SHARED_SINGLE_PARTITION_COLLECTION_INTERNAL;
truncateCollection(SHARED_SINGLE_PARTITION_COLLECTION_INTERNAL);

client.createDocument(getCollectionLink(createdCollection),
getDocumentDefinition(), null, false).block();
Expand Down
Loading
Loading