Skip to content

Commit

Permalink
refactor(ci): reorganize E2E testing scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Aug 9, 2023
1 parent 22b8f8a commit 0b29678
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 83 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
- uses: taiki-e/install-action@nextest
- name: Test Coverage
run: cargo llvm-cov nextest
- name: E2E Tests with SQLite
run: ./docker/bin/run-e2e-tests.sh
- name: E2E Tests with MySQL
run: ./docker/bin/e2e/mysql/run-e2e-tests.sh
- name: E2E Tests
run: ./docker/bin/e2e/run-e2e-tests.sh

File renamed without changes.
3 changes: 0 additions & 3 deletions docker/bin/e2e-env-down.sh

This file was deleted.

4 changes: 0 additions & 4 deletions docker/bin/e2e-env-restart.sh

This file was deleted.

3 changes: 0 additions & 3 deletions docker/bin/e2e/mysql/e2e-env-down.sh

This file was deleted.

4 changes: 2 additions & 2 deletions docker/bin/e2e/mysql/e2e-env-reset.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

./docker/bin/e2e/mysql/e2e-env-down.sh

# Delete the databases and recreate them.

docker compose down

# Index Backend

# Database credentials
Expand Down
2 changes: 1 addition & 1 deletion docker/bin/e2e/mysql/e2e-env-restart.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

./docker/bin/e2e/mysql/e2e-env-down.sh
docker compose down
./docker/bin/e2e/mysql/e2e-env-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,39 @@ wait_for_container_to_be_healthy() {
return 1
}

# Install tool to create torrent files
# 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
./bin/install.sh || exit 1

# TEST USING SQLITE
echo "Running E2E tests using SQLite ..."

# Start E2E testing environment
./docker/bin/e2e/sqlite/e2e-env-up.sh || exit 1

wait_for_container_to_be_healthy torrust-mysql-1 10 3
# todo: implement healthchecks for tracker and backend 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

# Run E2E tests with shared app instance
TORRUST_IDX_BACK_E2E_SHARED=true TORRUST_IDX_BACK_E2E_CONFIG_PATH="./config-idx-back.sqlite.local.toml" cargo test || exit 1

# Stop E2E testing environment
docker compose down

# TEST USING MYSQL
echo "Running E2E tests using MySQL ..."

# Start E2E testing environment
./docker/bin/e2e/mysql/e2e-env-up.sh || exit 1

Expand All @@ -67,4 +94,4 @@ mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD -e "CREATE DATABASE IF NOT
TORRUST_IDX_BACK_E2E_SHARED=true TORRUST_IDX_BACK_E2E_CONFIG_PATH="./config-idx-back.mysql.local.toml" cargo test || exit 1

# Stop E2E testing environment
./docker/bin/e2e/mysql/e2e-env-down.sh
docker compose down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# Delete the SQLite databases and recreate them.
# Delete the databases and recreate them.

./docker/bin/e2e-env-down.sh
docker compose down

rm -f ./storage/database/torrust_index_backend_e2e_testing.db
rm -f ./storage/database/torrust_tracker_e2e_testing.db
Expand All @@ -23,4 +23,4 @@ if ! [ -f "./storage/database/torrust_tracker_e2e_testing.db" ]; then
echo ";" | sqlite3 ./storage/database/torrust_tracker_e2e_testing.db
fi

./docker/bin/e2e-env-up.sh
./docker/bin/e2e/sqlite/e2e-env-up.sh
4 changes: 4 additions & 0 deletions docker/bin/e2e/sqlite/e2e-env-restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

docker compose down
./docker/bin/e2e/sqlite/e2e-env-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \
docker compose build

TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \
TORRUST_IDX_BACK_CONFIG=$(cat config-idx-back.local.toml) \
TORRUST_IDX_BACK_CONFIG=$(cat config-idx-back.sqlite.local.toml) \
TORRUST_TRACKER_CONFIG=$(cat config-tracker.local.toml) \
TORRUST_TRACKER_API_TOKEN=${TORRUST_TRACKER_API_TOKEN:-MyAccessToken} \
docker compose up -d
60 changes: 0 additions & 60 deletions docker/bin/run-e2e-tests.sh

This file was deleted.

0 comments on commit 0b29678

Please sign in to comment.