-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make iterating on integration tests easier (#789)
Writing and iterating on integration tests are cumbersome, having to wait 10 minutes for the test-suite to run just to see if your test works or not is unacceptable. In this PR, I added a detailed workflow for writing tests that should shorten the feedback cycle of modifying tests to be as low as a few seconds. It will involve opening a shell into a long-lived container that has all the setup and dependencies necessary and then running your desired tests directly there. I added a convenience script that bootstraps the environment and then opens an interactive shell into the container and you can then run tests immediately in an environment that is more or less identical to what we have running in CircleCI
- Loading branch information
Showing
4 changed files
with
94 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
GREEN="\033[0;32m" | ||
RED="\033[0;31m" | ||
BLUE="\033[0;34m" | ||
RESET="\033[0m" | ||
|
||
|
||
cd tests/docker/ | ||
docker compose kill main || true | ||
docker compose build main | ||
docker compose down | ||
docker compose up -d | ||
# wait for the container to start | ||
while ! docker compose exec main ls; do | ||
echo "Waiting for test environment to start" | ||
sleep 1 | ||
done | ||
echo "===================================" | ||
docker compose exec -e LOG_LEVEL=error -d main toxiproxy-server | ||
docker compose exec --workdir /app main cargo build | ||
docker compose exec -d --workdir /app main ./target/debug/pgcat ./.circleci/pgcat.toml | ||
docker compose exec --workdir /app/tests/ruby main bundle install | ||
docker compose exec --workdir /app/tests/python main pip3 install -r requirements.txt | ||
echo "Interactive test environment ready" | ||
echo "To run integration tests, you can use the following commands:" | ||
echo -e " ${BLUE}Ruby: ${RED}cd /app/tests/ruby && bundle exec ruby tests.rb --format documentation${RESET}" | ||
echo -e " ${BLUE}Python: ${RED}cd /app && python3 tests/python/tests.py${RESET}" | ||
echo -e " ${BLUE}Rust: ${RED}cd /app/tests/rust && cargo run ${RESET}" | ||
echo -e " ${BLUE}Go: ${RED}cd /app/tests/go && /usr/local/go/bin/go test${RESET}" | ||
echo "the source code for tests are directly linked to the source code in the container so you can modify the code and run the tests again" | ||
echo "You can rebuild PgCat from within the container by running" | ||
echo -e " ${GREEN}cargo build${RESET}" | ||
echo "and then run the tests again" | ||
echo "===================================" | ||
docker compose exec --workdir /app/tests main bash |
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