-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #383: Reestablish E2E Tests (reopened)
d92443d fix: [#342] E2E test execution with MySQL (Jose Celano) 31351fa fix: [#342] disable clippy warning (Jose Celano) f8aa238 fix: [#342] broken E2E tests after renaming Category::category_id field (Jose Celano) e78607d fix: [#342] SQLite data file path inside the container for E2E tests (Jose Celano) 1cce823 fix: [#342] index container not running for E2E tests (Jose Celano) 03943ef fix: [#342] fix en vars to run E2E tests (Jose Celano) Pull request description: The E2E test suite execution was not reestablished correctly [here](#378). Some env vars were renamed (like `TORRUST_INDEX_E2E_SHARED`) so we were not running E2E tests (although they seemed to pass, we were only executing the ones that do not require a shared env). This PR only reestablishes the E2E tests. There are a lot of pending refactors that will be done in new PRs like [renaming env vars](#361). Top commit has no ACKs. Tree-SHA512: fc8f9f89dab83b8b2cb263befc614c9c8ebec884a060e4e5c6a958827d537b4c1198e0c8cdb4b709902a9869366088dc91ac33cca15a1fdf357a215a8328589e
- Loading branch information
Showing
18 changed files
with
159 additions
and
58 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,15 @@ | ||
#!/bin/bash | ||
|
||
# This script is only intended to be used for E2E testing environment. | ||
|
||
# Database credentials | ||
MYSQL_USER="root" | ||
MYSQL_PASSWORD="root_secret_password" | ||
MYSQL_HOST="127.0.0.1" | ||
MYSQL_DATABASE="torrust_index_e2e_testing" | ||
|
||
# Create the MySQL database for the index. Assumes MySQL client is installed. | ||
# The docker compose configuration already creates the database the first time | ||
# the container is created. | ||
echo "Creating MySQL database $MYSQL_DATABASE for for E2E testing ..." | ||
MYSQL_PWD=$MYSQL_PASSWORD mysql -h $MYSQL_HOST -u $MYSQL_USER -e "CREATE DATABASE IF NOT EXISTS $MYSQL_DATABASE;" |
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,70 @@ | ||
#!/bin/bash | ||
|
||
CURRENT_USER_NAME=$(whoami) | ||
CURRENT_USER_ID=$(id -u) | ||
echo "User name: $CURRENT_USER_NAME" | ||
echo "User id: $CURRENT_USER_ID" | ||
|
||
TORRUST_IDX_BACK_USER_UID=$CURRENT_USER_ID | ||
TORRUST_TRACKER_USER_UID=$CURRENT_USER_ID | ||
export TORRUST_IDX_BACK_USER_UID | ||
export TORRUST_TRACKER_USER_UID | ||
|
||
# todo: remove duplicate funtion | ||
wait_for_container_to_be_healthy() { | ||
local container_name="$1" | ||
local max_retries="$2" | ||
local retry_interval="$3" | ||
local retry_count=0 | ||
|
||
while [ $retry_count -lt "$max_retries" ]; do | ||
container_health="$(docker inspect --format='{{json .State.Health}}' "$container_name")" | ||
if [ "$container_health" != "{}" ]; then | ||
container_status="$(echo "$container_health" | jq -r '.Status')" | ||
if [ "$container_status" == "healthy" ]; then | ||
echo "Container $container_name is healthy" | ||
return 0 | ||
fi | ||
fi | ||
|
||
retry_count=$((retry_count + 1)) | ||
echo "Waiting for container $container_name to become healthy (attempt $retry_count of $max_retries)..." | ||
sleep "$retry_interval" | ||
done | ||
|
||
echo "Timeout reached, container $container_name is not healthy" | ||
return 1 | ||
} | ||
|
||
# Install tool to create torrent files. | ||
# It's needed by some tests to generate and parse test torrent files. | ||
cargo install imdl || exit 1 | ||
|
||
# Install app (no docker) that will run the test suite against the E2E testing | ||
# environment (in docker). | ||
cp .env.local .env || exit 1 | ||
|
||
# TEST USING MYSQL | ||
echo "Running E2E tests using MySQL ..." | ||
|
||
# Start E2E testing environment | ||
./contrib/dev-tools/container/e2e/mysql/e2e-env-up.sh || exit 1 | ||
|
||
wait_for_container_to_be_healthy torrust-mysql-1 10 3 | ||
# todo: implement healthchecks for tracker and index and wait until they are healthy | ||
#wait_for_container torrust-tracker-1 10 3 | ||
#wait_for_container torrust-idx-back-1 10 3 | ||
sleep 20s | ||
|
||
# Just to make sure that everything is up and running | ||
docker ps | ||
|
||
# Install MySQL database for the index | ||
./contrib/dev-tools/container/e2e/mysql/install.sh || exit 1 | ||
|
||
# Run E2E tests with shared app instance | ||
TORRUST_INDEX_E2E_SHARED=true TORRUST_INDEX_E2E_PATH_CONFIG="./share/default/config/index.container.mysql.toml" cargo test || exit 1 | ||
|
||
# Stop E2E testing environment | ||
./contrib/dev-tools/container/e2e/mysql/e2e-env-down.sh || exit 1 | ||
|
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,13 @@ | ||
#!/bin/bash | ||
|
||
# This script is only intended to be used for E2E testing environment. | ||
|
||
# Generate storage directory if it does not exist | ||
mkdir -p ./storage/index/lib/database | ||
|
||
# Generate the sqlite database if it does not exist | ||
if ! [ -f "./storage/index/lib/database/sqlite3.db" ]; then | ||
# todo: it should get the path from tracker.toml and only do it when we use sqlite | ||
sqlite3 ./storage/index/lib/database/sqlite3.db "VACUUM;" | ||
fi | ||
|
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -68,6 +68,7 @@ rowid | |
RUSTDOCFLAGS | ||
RUSTFLAGS | ||
rustfmt | ||
rustversion | ||
serde | ||
sgxj | ||
singlepart | ||
|
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
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
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