forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add debugging feature which leaves integration test containers runnin…
…g after test completes (apache#9626) ### Motivation For debugging purposes, it is useful to have the ability to leave the integration test containers running after the test completes. For example, this feature was necessary in investigating the issue apache#9622 . It was possible to view the log files and find out the issue. If the containers are killed, this options is lost. ### Modifications Adds handling to the initialization and stopping of Pulsar containers and Pulsar cluster so that containers get configured using Testcontainers "reuse mode" which leaves containers running after the test JVM stops. Normally the Testcontainers automatic container cleanup feature stops all containers which weren't explicitly stopped during the tests. Testcontainers reuse mode must be enabled by setting environment variable `TESTCONTAINERS_REUSE_ENABLE=true` (or by setting `testcontainers.reuse.enable=true` in `~/.testcontainers.properties`). The modifications in this PR skip stopping PulsarContainer and PulsarCluster instances if environment variable `PULSAR_CONTAINERS_LEAVE_RUNNING=true` . ### Usage example In unix shells, one can pass environment variables by prepending the command with the variables, for example: ``` PULSAR_CONTAINERS_LEAVE_RUNNING=true TESTCONTAINERS_REUSE_ENABLE=true mvn -B -f tests/pom.xml test -DintegrationTests -DredirectTestOutputToFile=false -DtestRetryCount=0 -DfailIfNoTests=false -Dtest=CLITest#testCreateSubscriptionCommand ``` After the test run, one can use `docker ps` and `docker exec -it [container_name] bash` to get a shell in the running container that was left behind the test run when this feature introduced by this PR is active. After debugging, one can use this command to kill all containers that were left running: ``` docker kill $(docker ps -q --filter "label=pulsarcontainer=true") ``` (the solution in this PR labels the containers with "pulsarcontainer=true")
- Loading branch information
Showing
2 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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