bbejeck opened a new pull request, #22860:
URL: https://github.com/apache/kafka/pull/22860

   ## What                                                                      
                                                                                
                                                
     A lightweight, client-agnostic Kafka **wire-protocol fault-injection 
proxy** for Streams                                                             
                                                        
     integration tests. It sits between a client and an embedded broker — point 
any                                                                             
                                                  
     `bootstrap.servers` at it — and decodes/re-encodes responses with Kafka's 
own protocol classes                                                            
                                                   
     (`RequestHeader`, `AbstractResponse`, `RequestUtils#serialize`), so it's 
correct across all                                                              
                                                    
     wire/flexible versions with no hand-rolled byte offsets.                   
                                                                                
                                                  
                                                                                
                                                                                
                                                  
     ## Why                                                                     
                                                                                
                                                  
     This proxy lets a test deterministically inject broker-side faults — and 
*drive lifecycle transitions*                                                   
                                                                           
     (fault → rebalance / migrate / corrupt / revive) — to flush out that class 
of bug before release.                                                          
                                                  
                                                                                
                                                                                
                                                  
     ## API                                                                     
                                                                                
                                                  
     ```java                                                                    
                                                                                
                                                  
     try (var proxy = 
KafkaProtocolFaultProxy.inFrontOf(cluster.bootstrapServers())) {                
                                                                                
                            
         props.put(BOOTSTRAP_SERVERS_CONFIG, proxy.bootstrapServers());         
                                                                                
                                                  
         proxy.injectError(ApiKeys.END_TXN, Errors.INVALID_TXN_STATE).once();   
                                                                                
                                                  
         proxy.disconnectOn(ApiKeys.END_TXN).everyTime();   // models the EOS 
commit gap                                                                      
                                                    
     }                                                                          
                                                                                
                                                  
     ```                                                                        
                                                                                
                                                  
                                                                                
                                                                                
                                                  
     Triggers: `once()` / `onCall(n)` / `times(n)` / `everyTime()` / 
`withProbability(p)` — the first                                                
                                                             
     three are deterministic and assertion-safe. Routing is transparent 
(rewrites                                                                       
                                                          
     `Metadata`/`FindCoordinator`); sockets are never dropped unless a 
`disconnectOn` rule fires, so                                                   
                                                           
     the proxy isn't itself a flakiness source.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to