{"id":15066116,"url":"https://github.com/buraksenyurt/resistance","last_synced_at":"2025-04-10T13:41:27.747Z","repository":{"id":253819298,"uuid":"844621645","full_name":"buraksenyurt/Resistance","owner":"buraksenyurt","description":"It is a library containing functions that create a chaotic environment for durability tests in web app environments.","archived":false,"fork":false,"pushed_at":"2024-08-23T21:49:00.000Z","size":47,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T00:12:20.270Z","etag":null,"topics":["chaos-engineering","distributed-systems","dotnet-core","resiliency"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/Resistance/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/buraksenyurt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-19T16:25:45.000Z","updated_at":"2024-08-24T00:13:27.000Z","dependencies_parsed_at":"2024-08-23T22:46:28.835Z","dependency_job_id":null,"html_url":"https://github.com/buraksenyurt/Resistance","commit_stats":null,"previous_names":["buraksenyurt/resistance"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buraksenyurt%2FResistance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buraksenyurt%2FResistance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buraksenyurt%2FResistance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buraksenyurt%2FResistance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buraksenyurt","download_url":"https://codeload.github.com/buraksenyurt/Resistance/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248226038,"owners_count":21068117,"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":["chaos-engineering","distributed-systems","dotnet-core","resiliency"],"created_at":"2024-09-25T01:01:51.110Z","updated_at":"2025-04-10T13:41:27.729Z","avatar_url":"https://github.com/buraksenyurt.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Resistance\n\nIt is a library containing functions that create a chaotic environment for durability tests in web app environments.\n\nIn distributed systems, it is important that the whole is durable. The functions in this package can be added to an Asp.Net Runtime Middleware line. The following situations can be simulated in server or service environments.\n\n## Simulation Scenarios\n\n- Latency: Generating delays in service response times. For example delaying the response by 500 to 2500 milliseconds.\n- Resource Race: Simulating receiving too many requests.\n- Outage: Providing service interruption for certain periods of time. For example, a service outage of ten seconds in every minute.\n- Network Failure: It ensures that HTTP 500 is returned based on a certain percentage of service calls.\n- Data Inconsistency: Data corruption on the response body. For example, adding text-based information to the body of every second response.\n\n## Usage\n\nBy default, all simulation behaviors are disabled. These values ​​can be enabled via appSettings. For more detailed settings, the Middleware function is used.\n\n```json\n{\n  \"ResistanceFlags\": {\n    \"NetworkFailureIsActive\": true,\n    \"LatencyIsActive\": false,\n    \"ResourceRaceIsActive\": true,\n    \"OutageIsActive\": false,\n    \"DataInconsistencyIsActive\": false\n  }\n}\n```\n\nCode example;\n\n```csharp\n// For appSettings based options\nbuilder.Services.Configure\u003cResistanceFlags\u003e(builder.Configuration.GetSection(\"ResistanceFlags\"));\n\napp.UseResistance(new ResistanceOptions\n{\n    // Network Failure (HTTP 500 Internal Service Error with %25 probility)\n    NetworkFailureProbability = NetworkFailureProbability.Percent25,\n    // For 5 requests coming from the same IP every 10 seconds, the HTTP 429 Too Many Requests scenario is generated.\n    ResourceRacePeriod = new ResourceRacePeriod\n    {\n        DueTime = TimeSpan.FromSeconds(5),\n        Period = TimeSpan.FromSeconds(5),\n        RequestLimit = 5\n    },\n    // Manipulating response data with %50 probability\n    DataInconsistencyProbability = DataInconsistencyProbability.Percent20,\n    // Produce HTTP 503 Service Unavailable 10 seconds per minute\n    OutagePeriod = new OutagePeriod\n    {\n        Duration = TimeSpan.FromSeconds(10),\n        Frequency = TimeSpan.FromMinutes(1)\n    },\n    // Latency 500 millisecdons - 2500 milliseconds\n    LatencyPeriod = new LatencyPeriod\n    {\n        MinDelayMs = TimeSpan.FromMilliseconds(500),\n        MaxDelayMs = TimeSpan.FromMilliseconds(2500)\n    }\n});\n```\n\n## Test App\n\nResistance.Test Api application can be used to test Nuget package. After referencing the package from Nuget repo, tests can be performed with Swagger interface or Postman, simple Curl command or Resistance.TestClient console application(Suggested).\n\n```bash\ndotnet run\n\n# The port address may differ\ncurl -X 'GET' \\\n  'http://localhost:5225/getSalary' \\\n  -H 'accept: */*'\n```\n\nFor example, when the Network Failure behavior is enabled, one of the expected results should be as follows.\n\n![Postman Sample](https://github.com/user-attachments/assets/d03f2f1b-1f7a-4c6e-9e74-2af4be0b88b8)\n\nThe tests performed with the Console application are as follows.\n\n### Outage Test\n\nThe service is down for 10 seconds every minute.\n\n![Outage sample](https://github.com/user-attachments/assets/14758868-68d4-4f3d-81e3-76a4c91a1475)\n\n### Network Failure Test\n\nHTTP 500 Internal Service Error error is returned with a 25% probability.\n\n![Network Failure Sample](https://github.com/user-attachments/assets/dc31002c-7bb4-4034-aaec-84aec943ab0e)\n\n### Latency Test\n\nThere will be a delay in service response times.\n\n![Latency Sample](https://github.com/user-attachments/assets/bb75d6dd-9810-47c6-9358-aa704c579f95)\n\n### Data Inconsistency Test\n\nService response data is manipulated with a certain probability value.\n\n![Data Inconsistency Sample](https://github.com/user-attachments/assets/377163ae-e416-4c4e-add6-f044762524e7)\n\n### Resource Race Test\n\nThe service returns HTTP code 429, indicating that it has received too many requests. For 5 requests coming from the same IP every 10 seconds, the HTTP 429 Too Many Requests scenario is generated.\n\n![Resource Race Sample](https://github.com/user-attachments/assets/8e0a271a-44b3-4745-98ad-8ade9dfac5d8)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburaksenyurt%2Fresistance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fburaksenyurt%2Fresistance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburaksenyurt%2Fresistance/lists"}