{"id":20698400,"url":"https://github.com/sozu-proxy/sozu-integration-tests","last_synced_at":"2026-04-18T23:02:58.602Z","repository":{"id":50800889,"uuid":"150077596","full_name":"sozu-proxy/sozu-integration-tests","owner":"sozu-proxy","description":"Integration tests for sozu with https://www.testcontainers.org/","archived":false,"fork":false,"pushed_at":"2021-05-29T00:44:24.000Z","size":139,"stargazers_count":2,"open_issues_count":15,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-17T19:05:49.785Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sozu-proxy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-24T09:05:33.000Z","updated_at":"2020-11-14T13:09:11.000Z","dependencies_parsed_at":"2022-09-06T00:21:24.069Z","dependency_job_id":null,"html_url":"https://github.com/sozu-proxy/sozu-integration-tests","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sozu-proxy%2Fsozu-integration-tests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sozu-proxy%2Fsozu-integration-tests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sozu-proxy%2Fsozu-integration-tests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sozu-proxy%2Fsozu-integration-tests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sozu-proxy","download_url":"https://codeload.github.com/sozu-proxy/sozu-integration-tests/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242967686,"owners_count":20214280,"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":"2024-11-17T00:24:34.924Z","updated_at":"2026-04-18T23:02:53.547Z","avatar_url":"https://github.com/sozu-proxy.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Integration tests for Sozu\n\nExperimental test suite for [Sozu](https://github.com/sozu-proxy/sozu)\n\n# Requirements\n\n## Packages\n\n- Gradle 4.8 at least\n- OpenJDK 1.8\n- Docker 1.6.0 at least\n- An environment with more than 2GB free disk space\n\nNOTE: You don't have to install `gradle` to run the tests. This repository provide a gradle wrapper binary: `gradlew` that contain Gradle.\n\n## Network (temporary until fixed)\n\nYou *must* create a local `bridge` network named \"my-net\":\n`docker network create --driver=bridge --subnet=172.18.0.0/16 my-net`\nUse this subnet in your Sozu `config.toml` for the backends address.\n\n# Build\n\n`gradle build` or `./gradlew build` with the gradle wrapper.\n\n# Run the test suite\n\n`gradle test` or `./gradlew test` (add `--info` or `--debug`) to run the tests suite.\n\n**Run only one test:**s\n\n`./gradlew test --tests \"\u003ctestClass\u003e.\u003ctestName\u003e\" --info`\n\ne.g.: `./gradlew test --tests \"SozuContainerTest.testRetryPolicy\" --info`\n\nThis can take additional time to run the test suite the first time because of the download (and buid) of the docker images.\n`testcontainers` doesn't check if the local docker image of your container as the same version as the one on docker hub.\nSo you have to `docker pull \u003cyour image\u003e` if you work with docker image from docker HUB in your tests.\n\n\nYou can set the path to a local sozu Dockerfile with `SOZU_DOCKERFILE` env variable to avoid to download the sozu image from dockerhub.\n\n\nNOTE: To avoid that you can build your container from a local `Dockerfile`:\nThis example use the `Classpath` to store the `Dockerfile`.\n\n```java\npublic class MyContainer {\n\n    public MyContainer() {\n            super(\n                new ImageFromDockerfile()\n                    .withFileFromClasspath(\"Dockerfile\", \"path/to/Dockerfile\")\n            );\n    }\n\n}\n```\n\n# Add a new test `Class`\n\n1. Create a new test file in `src/test/java`\n2. Put all your config file in `src/test/resources` to retrieve them from the `Classpath`\n3. Create a new test `Class`\n4. Define the containers you want to run at the start of your test suite as fields of your `Class` and add `@Rule` on them\n(that'll be use by `testcontainers`). You can still create them in the `@Before` or in your tests method.\n5. `gradle test` or `./gradlew test` to run the test suite.\n\n## Example\n\n```java\npublic class MyContainer\u003cSELF extends MyContainer\u003cSELF\u003e\u003e extends GenericContainer\u003cSELF\u003e {\n\n\n    public static final String IMAGE = \"helloworld\";\n    public static final String DEFAULT_TAG = \"latest\";\n\n    // Get image from dockerHUB\n    public MyContainer() {\n        super(IMAGE+ \":\" + DEFAULT_TAG);\n    }\n\n    @Override\n    protected void configure() {\n        // use with* method to change the docker run command\n    }\n\n    // Build the URL to connect to your container with a mapped port\n    public URL getBaseUrl(String scheme, int port) throws MalformedURLException {\n        return new URL(scheme + \"://\" + getContainerIpAddress() + \":\" + getMappedPort(port));\n    }\n}\n```\n\n# Add a new type of container\n\n1. Create a new `Class` file in `src/main/java`\n2. Extend them from GenericContainer: `\u003cSELF extends NodeBackendContainer\u003cSELF\u003e\u003e extends GenericContainer\u003cSELF\u003e`\n3. (optional) To modify the docker image you have to do this in the constructor with the method `with*` e.g.: `withFileFromClasspath`\n4. (optional) To modify the `docker run` command generate by testcontainers you have to do this in `@Override protected void configure()`\n\nSee [here](https://www.testcontainers.org/usage/options.html) for more information\n\nNOTE: Use the `getMappedPort(\u003cport\u003e)` to get the host port mapped to the exposed port in the container.\n\n## Example\n\n```java\npublic class MyContainerTest {\n    @Rule\n    public MyContainer myContainer = new MyContainer();\n\n    @Test\n    public void testConnectionForMyContainer() throws Exception {\n        URLConnection urlConnection = myContainer.getBaseUrl().openConnection();\n        BufferedReader reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));\n        String line = reader.readLine();\n        assertEquals(\"A message\", line);\n    }\n}\n\n```\n\n# Known issues\n\n#### Can't get Docker image\n\nSometime `libcontainers` fail at download the docker images due to a network problem during the first run or when these are not already present in the host.\nYou can just replay the test suite to fix this.\n\n```bash\n  SozuContainerTest\n    ✘ classMethod\n      org.testcontainers.containers.ContainerFetchException: Can't get Docker image: org.testcontainers.images.builder.ImageFromDockerfile@1dfc4dc1\n\nSozuContainerTest \u003e classMethod FAILED\n    org.testcontainers.containers.ContainerFetchException: Can't get Docker image: org.testcontainers.images.builder.ImageFromDockerfile@1dfc4dc1\n        Caused by:\n        com.github.dockerjava.api.exception.DockerClientException: Could not build image: The command '/bin/sh -c npm install' returned a non-zero code: 1\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsozu-proxy%2Fsozu-integration-tests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsozu-proxy%2Fsozu-integration-tests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsozu-proxy%2Fsozu-integration-tests/lists"}