{"id":16752798,"url":"https://github.com/aalekhpatel07/partition-sim","last_synced_at":"2026-05-10T06:47:49.728Z","repository":{"id":65598089,"uuid":"593926938","full_name":"aalekhpatel07/partition-sim","owner":"aalekhpatel07","description":"Simulate a network partition between a distributed cluster of nodes.","archived":false,"fork":false,"pushed_at":"2023-02-20T21:43:55.000Z","size":69,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T07:31:02.553Z","etag":null,"topics":["distributed-systems","docker","docker-compose","infrastructure-test"],"latest_commit_sha":null,"homepage":"https://aalekhpatel07.github.io/partition-sim-ui/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aalekhpatel07.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-01-27T06:55:18.000Z","updated_at":"2023-04-11T16:06:51.000Z","dependencies_parsed_at":"2023-12-08T10:47:45.246Z","dependency_job_id":null,"html_url":"https://github.com/aalekhpatel07/partition-sim","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"f740528104c701537470520e832c4a3a7ddb99a4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aalekhpatel07%2Fpartition-sim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aalekhpatel07%2Fpartition-sim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aalekhpatel07%2Fpartition-sim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aalekhpatel07%2Fpartition-sim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aalekhpatel07","download_url":"https://codeload.github.com/aalekhpatel07/partition-sim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299843,"owners_count":20916192,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distributed-systems","docker","docker-compose","infrastructure-test"],"created_at":"2024-10-13T02:48:09.715Z","updated_at":"2026-05-10T06:47:44.704Z","avatar_url":"https://github.com/aalekhpatel07.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Network Partition Simulator\n\n\n## Use cases\n- To test the operation of a distributed protocol under unstable (but controlled) network conditions.\n- To test the behaviour of a web-service under flaky network conditions. (Example: disabling/enabling network connectivity to the server).\n\n## Architecture\n\nIndividual `node`s work as docker containers and form a cluster of test nodes. They register their address and ports with `Consul` when they're ready\nto serve requests. The nodes also register an http healthcheck with Consul so that they can be monitored periodically.\n\nThe `supervisor` node is the orchestrator node that tweaks the `iptables` rules on the whole test cluster. The supervisor loads the state of the cluster\nby querying Consul. Once the cluster under test is loaded by the supervisor (via `/api/v1/load_cluster`), the supervisor is ready to serve the Partition API.\n\nThe supervisor understands the following network-related mutations and queries:\n\n1. `Partition` - `POST api/v1/partition/\u003csource_id\u003e/\u003ctarget_id\u003e`: Given ids of a source and a target node, configure the firewall on the target node such that all packets coming from the source node are dropped.\n2. `Heal` - `POST api/v1/heal/\u003csource_id\u003e/\u003ctarget_id\u003e`: Given ids of a source and a target node, configure the firewall on the target node such that all packets coming from the source node are accepted.\n3. `Restore` - `POST api/v1/restore`: Clear all the firewall rules across the cluster so that all nodes can communicate with each other.\n4. `Rules` - `GET api/v1/rules/\u003ctarget_id\u003e`: Given id of a target node, list all the `INPUT` rules currently configured on the target node.\n\n## Usage\n\nDockerize the system into a single process that will communicate with other docker containers whenever necessary. Ensure the system accepts `http` healthchecks at `/health`.\n\nConsider using `docker/test-node.Dockerfile` as reference to structure your Dockerfile:\n\n```Dockerfile\nFROM rust:1.66 AS build\nWORKDIR /app\nRUN apt-get update -y \u0026\u0026 apt-get upgrade -y\nRUN apt-get install curl python3-venv openssh-client openssh-server iptables sudo -y\nCOPY register_service.py /register_service.py\nRUN chmod +x /register_service.py\nRUN python3 -m venv /var/venv/node\nRUN /var/venv/node/bin/python -m pip install requests\nRUN mkdir -p /etc/ssh\nCOPY docker/sshd_config /etc/ssh/sshd_config\n\n# Application related config.\n...\n\n# Make sure the `register_service.py` script gets called before your applications boots up.\nCOPY entrypoint.sh /entrypoint.sh\nRUN chmod +x /entrypoint.sh\n\nENTRYPOINT [\"/entrypoint.sh\"]\n```\n\n`entrypoint.sh`\n\n```sh\nusermod --password $(echo \"root\" | openssl passwd -1 -stdin) root\nservice ssh restart\n/var/venv/node/bin/python3 /register_service.py --name \"test-node\" --port 9000\n\n# Now start your long running application that uses port 9000 to communicate with its peers.\n...\n```\n\nThe `docker/test-supervisor.Dockerfile` is to be used as is. Once the node's dockerfile is set up, start the `docker-compose` deployment:\n\n```sh\ndocker-compose up -d\n```\n\nThe `test-supervisor` container exposes an http api at port `3000` which can be used to control the network partitions in the test cluster.\nThe consul container is used solely for service discovery but if you're interested its UI can be accessed at port `8500` of the `consul` container.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faalekhpatel07%2Fpartition-sim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faalekhpatel07%2Fpartition-sim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faalekhpatel07%2Fpartition-sim/lists"}