Skip to content

Conversation

@xinlian12
Copy link
Member

@xinlian12 xinlian12 commented Nov 11, 2025

Changes

  1. Add support for head collection request in fault injection
 FaultInjectionRule faultInjectionRule =
            new FaultInjectionRuleBuilder(faultInjectionRuleId)
                .condition(
                    new FaultInjectionConditionBuilder()
                        .operationType(FaultInjectionOperationType.HEAD_COLLECTION)
                        .build()
                )
                .result(
                    FaultInjectionResultBuilders
                        .getResultBuilder(serverErrorType)
                        .times(2)
                        .build()
                )
                .duration(Duration.ofMinutes(5))
                .build()
  1. Allow config a TransportClientInteceptor to modify the store response on direct layer, which can be used to trigger barrier request flow
        CosmosInterceptorHelper.registerTransportClientInterceptor(
            newClient,
            (request, storeResponse) -> {
                if (request.getResourceType() == ResourceType.Document && request.getOperationType() == operationType) {
                    // Decrement so that GCLSN < LSN to simulate the replication lag
                    storeResponse.setGCLSN(storeResponse.getLSN() - 2L);
                }
                return storeResponse;
            }
        );

Copilot AI review requested due to automatic review settings November 11, 2025 19:30
@xinlian12 xinlian12 requested review from a team and kirankumarkolli as code owners November 11, 2025 19:30
Copilot finished reviewing on behalf of xinlian12 November 11, 2025 19:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for fault injection on head collection requests (barrier requests) and introduces a transport client interceptor mechanism to modify store responses at the direct layer for testing purposes.

Key Changes:

  • Added HEAD_COLLECTION operation type to fault injection framework for testing barrier requests
  • Introduced ITransportClientInterceptor interface and registration mechanism to allow modifying store responses in tests
  • Added setGCLSN and setHeaderValue methods to StoreResponse for test-driven header modification

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
module-info.java Exports interceptor package to test module
ITransportClientInterceptor.java New interface defining transport client interceptor contract
TransportClient.java Implements interceptor registration and applies interceptors to store responses
StoreResponse.java Adds methods to modify response headers for testing
StoreClient.java Delegates interceptor registration to replicated resource client
ServerStoreModel.java Implements interceptor registration interface method
ReplicatedResourceClient.java Delegates interceptor registration to transport client
BarrierRequestHelper.java Copies fault injection context to barrier requests
RxStoreModel.java Adds interceptor registration to interface
RxGatewayStoreModel.java No-op implementation for gateway mode
RxDocumentClientImpl.java Delegates interceptor registration to store model
ImplementationBridgeHelpers.java Adds bridge method for interceptor registration
AsyncDocumentClient.java Adds interceptor registration to interface
CosmosAsyncClient.java Implements interceptor registration with bridge helper
FaultInjectionServerErrorRuleOnDirectTests.java Adds comprehensive test for barrier request fault injection
CosmosTransportClientInterceptor.java Test implementation of interceptor interface
CosmosInterceptorHelper.java Test helper for registering interceptors
FaultInjectionRuleProcessor.java Maps HEAD_COLLECTION to operation and resource types
FaultInjectionOperationType.java Adds HEAD_COLLECTION operation type

@github-actions
Copy link
Contributor

github-actions bot commented Nov 11, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

com.azure:azure-cosmos

@xinlian12
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@xinlian12
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@xinlian12
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@FabianMeiswinkel FabianMeiswinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants