design/mocks3server_chaos_design.md
Create a MockS3ServerChaos implementation, modeled after the existing AsyncFileChaos pattern. This enables comprehensive testing of S3 client error handling, retry logic, and resilience against realistic failure scenarios.
Philosophy: mocks3 should be more intolerant/strict than real s3
FoundationDB's S3BlobStore client needs thorough testing against realistic S3 failure scenarios, but the existing MockS3Server only provides deterministic "happy path" responses. Real S3 services exhibit various error conditions that clients must handle gracefully.
MockS3ServerChaos is a new class that acts as a chaos-enabled wrapper around the base MockS3Server, following the established chaos injection pattern:
MockS3ServerChaos will follow the AsyncFileChaos pattern with fault injector-driven chaos:
// S3FaultInjector provides configurable rates (0.0-1.0) via g_network->global()
auto injector = g_network->global(enS3FaultInjector);
if (injector) {
double errorRate = injector->getErrorRate(); // 0.0-1.0 probability
double throttleRate = injector->getThrottleRate(); // 0.0-1.0 probability
double delayRate = injector->getDelayRate(); // 0.0-1.0 probability
double maxDelay = injector->getMaxDelay(); // seconds
// Runtime decision using deterministic random
if (deterministicRandom()->random01() < errorRate) {
// Inject error based on configured probability
}
}
BUGGIFY is a probabilistic macro (not boolean) that evaluates to true with low probability:
if (BUGGIFY) {
// Occasionally inject extra chaos - executes randomly, not always
// Used for additional chaos beyond configured rates
}
S3BlobStore.actor.cpp patterns)deterministicRandom()->random01()if (random < rate) pattern like AsyncFileChaosSupports targeted chaos injection with configurable multipliers:
g_network->global() like DiskFailureInjector and BitFlipperChaosMetrics systemMockS3ServerChaos Configuration:
├── S3FaultInjector (primary control) - Configurable fault rates:
│ ├── errorRate: 0.0-1.0 (0% to 100% error probability)
│ ├── throttleRate: 0.0-1.0 (throttling probability)
│ ├── delayRate: 0.0-1.0 (delay probability)
│ └── maxDelay: seconds (maximum delay time)
├── BUGGIFY (occasional extras) - Probabilistic additional chaos
└── Runtime Decision Logic:
├── Operation classification (GET/PUT/DELETE/multipart/list)
├── Deterministic random + configured rates
├── Chaos injection actors (delay/error/corruption)
├── S3-compatible error response generation
└── Base MockS3RequestHandler delegation
Replace startMockS3Server() calls with startMockS3ServerChaos() in simulation tests:
// Before:
wait(startMockS3Server(listenAddress));
// After:
wait(startMockS3ServerChaos(listenAddress));
Chaos behavior is controlled by S3FaultInjector rates (0.0-1.0), with BUGGIFY providing occasional extra chaos - no master boolean switch.