{"id":25050608,"url":"https://github.com/steadybit/testcontainers","last_synced_at":"2025-04-14T06:41:06.423Z","repository":{"id":43680215,"uuid":"456847059","full_name":"steadybit/testcontainers","owner":"steadybit","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-12T07:37:37.000Z","size":97,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-11T22:49:15.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/steadybit.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}},"created_at":"2022-02-08T08:34:28.000Z","updated_at":"2024-03-31T14:25:35.000Z","dependencies_parsed_at":"2023-02-13T22:45:16.121Z","dependency_job_id":null,"html_url":"https://github.com/steadybit/testcontainers","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steadybit%2Ftestcontainers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steadybit%2Ftestcontainers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steadybit%2Ftestcontainers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steadybit%2Ftestcontainers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/steadybit","download_url":"https://codeload.github.com/steadybit/testcontainers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837196,"owners_count":21169373,"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":[],"created_at":"2025-02-06T09:16:58.517Z","updated_at":"2025-04-14T06:41:06.399Z","avatar_url":"https://github.com/steadybit.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Steadybit Testcontainers\n\n## What is it?\n\nSteadybit Testcontainers is a helper library to the [Testcontainers Project](https://testcontainers.org) to implement Resilience Tests. \n\n## Getting Started\n\n\u003e We have a [blog post discussing \"Resilience Tests with Testcontainers\"](https://www.steadybit.com/blog/resilience-testing-using-testcontainers/) which gives a more detailed explanation.\n\n### 1. Add Steadybit Testcontainers to your project:\nAdd this to the test dependencies in your `pom.xml`:\n```xml\n\u003cdependency\u003e  \n  \u003cgroupId\u003ecom.steadybit\u003c/groupId\u003e\n  \u003cartifactId\u003esteadybit-testcontainers\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.1\u003c/version\u003e\n  \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n### 2. Add some Chaos to your Testcontainers Test:\n\nHere is an example for delaying the Redis traffic:\n```java\n@Testcontainers\npublic class RedisBackedCacheIntTest {\n    private RedisBackedCache underTest;\n\n    @Container\n    public GenericContainer redis = new GenericContainer(DockerImageName.parse(\"redis:5.0.3-alpine\")).withExposedPorts(6379);\n\n    @BeforeEach\n    public void setUp() {\n        underTest = new RedisBackedCache(redis.getHost(), redis.getFirstMappedPort());\n    }\n\n    @Test\n    public void testFindingAnInsertedValue() {\n        underTest.put(\"foo\", \"FOO\");\n\n        Optional\u003cString\u003e foundObject = Steadybit.networkDelayPackages(Duration.ofSeconds(2))\n                .forContainers(redis)\n                .exec(() -\u003e {\n                    //this code runs after the attack was started.\n                    //As soon as this lambda exits the attack will be stopped.\n                    return underTest.get(\"foo\", String.class);\n                });\n\n        assertTrue(\"When an object in the cache is retrieved, it can be found\", foundObject.isPresent());\n        assertEquals(\"When we put a String in to the cache and retrieve it, the value is the same\", \"FOO\", foundObject.get());\n    }\n}\n```\n\n## Available Attacks\n\n- `networkDelayPackages`: Delays egress tcp/udp network packages for containers (on eth0 by default)\n- `networkLoosePackages`: Looses egress tcp/udp network packages for containers (on eth0 by default)\n- `networkCorruptPackages`: Corrupts egress tcp/udp network packages for containers (on eth0 by default)\n- `networkLimitBandwidth`: Limits tcp/udp network bandwidth for containers (on eth0 by default)\n- `networkBlackhole`: Blocks all network traffic for containers\n- `networkBlockDns`: Blocks all network traffic for containers on dns port (53)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteadybit%2Ftestcontainers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteadybit%2Ftestcontainers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteadybit%2Ftestcontainers/lists"}