feat: mimic the Fault Injector API - #6
Merged
Merged
Conversation
…tion - Add POST /scenarios/predefined/:scenario endpoint with Zod validation - Create scenarios folder structure similar to default_interceptors - Implement remove-add scenario: - Picks a random node from existing proxies - Adds a new node with auto-incremented port - Intercepts CLUSTER SLOTS to exclude picked node and include new node - Sends SMIGRATING notification (slots about to migrate) - Sends SMIGRATED notification (slots migrated to new node) - Add helper functions for scenario operations: - buildSMigratingNotification() - RESP3 SMIGRATING notification - buildSMigratedNotification() - RESP3 SMIGRATED notification - createCustomClusterSlotsInterceptor() - custom cluster slots response - getSlotRangesForProxy() - calculate slot ranges for a proxy - addNode() - add new proxy node - sendToAllClients() - broadcast to all clients - pickRandom() - random element selection - findNextAvailablePort() - find next available port - Add bar scenario skeleton for future implementation
Implement action-based API matching the Fault Injector interface for executing Redis cluster operations with slot migration simulation. New API endpoints: - POST /action - Submit an action for async execution - GET /action/:action_id - Poll action status and result - GET /slot-migrate - List triggers for slot migration effects Implemented slot migration effects: - remove-add: Remove one node and add a new one - remove: Remove a node and redistribute slots - add: Add a new node and rebalance slots - slot-shuffle: Redistribute slots across existing nodes Each effect sends SMIGRATING/SMIGRATED push notifications to connected clients and updates CLUSTER SLOTS interceptors accordingly. Removed deprecated /scenarios endpoints in favor of the new action API.
Make the proxy's action API a drop-in stand-in for the Fault Injector (re_fault_injector) so FI clients work against it unchanged: - Implement reset_cluster: restore the initial proxy topology and reapply default interceptors. - Implement create_database: size the proxy cluster to database_config.shards_count and return raw_endpoints, username, password, tls and bdb_id in the action output, matching what FI clients parse. - Add GET /action to list submitted actions. - Report "running" while an action executes and return structured action output instead of the hardcoded "Done". - Generate FI-shaped triggers for GET /slot-migrate: real trigger names (migrate, maintenance_mode, failover), descriptions, and full dbconfig requirements with ext-ip/ext-hostname names, mirroring the FI's TRIGGER_DEFINITIONS and dbconfig templates. - Broadcast SMIGRATING/SMIGRATED to clients on every node during remove and remove-add, so each cluster connection observes the migration. - Push SMIGRATING to connections opened during an active migration, matching how a real cluster treats new connections mid-migration. - Complete the action type enum to FI parity (reset_cluster, topology_change_standalone, network_latency, wait_for_database_active, collect_debuginfo). - Make migration delays env-overridable (MIGRATION_DELAY_MS, COMPLETION_DELAY_MS) so tests run fast. - Remove the dead /scenarios modules and their stale tests; cover the action API with new tests instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
POST /reject-traffic/start drops every client connection and stops accepting new ones on all nodes. POST /reject-traffic/stop brings the listeners back up. Interceptors and topology survive the cycle, and both endpoints are idempotent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
POST /action+GET /action/:id— submit actions, poll status (pending/running/success/failed)GET /action— list submitted actionsslot_migrateaction — effects:remove-add,remove,add,slot-shuffle, with SMIGRATING/SMIGRATED push notifications to all clients, incl. connections opened mid-migrationcreate_databaseaction — sizes the proxy cluster toshards_count, returnsraw_endpoints/bdb_id/credentialsreset_clusteraction — restores initial topology and interceptorsGET /slot-migrate?effect=— FI-shaped triggers (migrate,maintenance_mode,failover) with full dbconfig requirementsPOST /reject-traffic/start/POST /reject-traffic/stop— simulate the endpoints going offline (drop all connections, refuse new ones) and back onlineMIGRATION_DELAY_MS/COMPLETION_DELAY_MS/scenarioscode; new test coverage for all of the above🤖 Generated with Claude Code