Skip to content

Commit

Permalink
fix: [torrust#342] E2E test execution with MySQL
Browse files Browse the repository at this point in the history
The Tracker configuration was using MySQL instead of SQLite but the
database was not created. We can use SQLite for the Tracker even if in
this case we are testing with MySQL becuase E2E test are for the Index
not the tracker.
  • Loading branch information
josecelano committed Nov 14, 2023
1 parent 31351fa commit d92443d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@ jobs:

- id: test-mysql
name: Run Integration Tests (MySQL)
run: ./contrib/dev-tools/container/e2e/mysql/run-e2e-tests.sh
run: ./contrib/dev-tools/container/e2e/mysql/run-e2e-tests.sh
5 changes: 3 additions & 2 deletions contrib/dev-tools/container/e2e/mysql/e2e-env-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ USER_ID=${USER_ID:-1000} \
TORRUST_INDEX_DATABASE_DRIVER="mysql" \
TORRUST_INDEX_TRACKER_API_TOKEN="MyAccessToken" \
TORRUST_IDX_BACK_MYSQL_DATABASE="torrust_index_e2e_testing" \
TORRUST_TRACKER_CONFIG=$(cat ./share/default/config/tracker.container.mysql.toml) \
TORRUST_TRACKER_DATABASE_DRIVER="mysql" \
TORRUST_TRACKER_CONFIG=$(cat ./share/default/config/tracker.container.sqlite3.toml) \
TORRUST_TRACKER_DATABASE_DRIVER="sqlite3" \
TORRUST_TRACKER_API_ADMIN_TOKEN="MyAccessToken" \
docker compose up -d

15 changes: 15 additions & 0 deletions contrib/dev-tools/container/e2e/mysql/install.sh
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;"
11 changes: 2 additions & 9 deletions contrib/dev-tools/container/e2e/mysql/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,8 @@ sleep 20s
# Just to make sure that everything is up and running
docker ps

# Database credentials
MYSQL_USER="root"
MYSQL_PASSWORD="root_secret_password"
MYSQL_HOST="localhost"
MYSQL_DATABASE="torrust_index_e2e_testing"

# Create the MySQL database for the index. Assumes MySQL client is installed.
echo "Creating MySQL database $MYSQL_DATABASE for for E2E testing ..."
mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD -e "CREATE DATABASE IF NOT EXISTS $MYSQL_DATABASE;"
# 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
Expand Down
2 changes: 1 addition & 1 deletion contrib/dev-tools/container/e2e/sqlite/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# This script is only intended to be used for local development or testing environments.
# 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
Expand Down

0 comments on commit d92443d

Please sign in to comment.