Skip to content

Commit

Permalink
Merge #378: Reestablish E2E Tests
Browse files Browse the repository at this point in the history
f35a067 fix: [#342] reestablish E2E Tests (Jose Celano)

Pull request description:

  Reestablish E2E Tests.

ACKs for top commit:
  josecelano:
    ACK f35a067

Tree-SHA512: e7554977dce0928c633be89ad48566566fe5f9cd43d28985eb43ee9400a79d98c0f332a5fa68080db88fc32aa321708104f46619ddd8c4796bb687bddea09c63
  • Loading branch information
josecelano committed Nov 13, 2023
2 parents 0608122 + f35a067 commit 64479b7
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
/config-tracker.local.toml
/config.local.toml
/config.toml
/contrib/dev-tools/container/
/cspell.json
/data_v2.db*
/data.db
/data.db*
/docker/
/project-words.txt
/README.md
/rustfmt.toml
/storage/
/target/
/target/
34 changes: 34 additions & 0 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,37 @@ jobs:
- id: coverage
name: Generate Coverage Report
run: cargo llvm-cov nextest --tests --benches --examples --workspace --all-targets --all-features

integration:
name: Integrations
runs-on: ubuntu-latest
needs: check

strategy:
matrix:
toolchain: [stable, nightly]

steps:
- id: checkout
name: Checkout Repository
uses: actions/checkout@v4

- id: setup
name: Setup Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}
components: llvm-tools-preview

- id: cache
name: Enable Job Cache
uses: Swatinem/rust-cache@v2

# Temporary Cleaning to avoid Rust Compiler Bug
- id: clean
name: Make Build Clean
run: cargo clean

- id: test
name: Run Integration Tests
run: ./contrib/dev-tools/container/e2e/run-e2e-tests.sh
5 changes: 4 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: torrust
services:

index:
image: torrust-index:release
build:
context: .
dockerfile: ./Containerfile
target: debug
tty: true
environment:
- TORRUST_INDEX_CONFIG=${TORRUST_INDEX_CONFIG}
Expand Down
6 changes: 6 additions & 0 deletions contrib/dev-tools/container/e2e/mysql/e2e-env-down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.container.mysql.toml) \
TORRUST_TRACKER_CONFIG=$(cat ./share/default/config/tracker.container.mysql.toml) \
docker compose down

4 changes: 2 additions & 2 deletions contrib/dev-tools/container/e2e/mysql/e2e-env-reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Delete the databases and recreate them.

docker compose down
./contrib/dev-tools/container/e2e/mysql/e2e-env-down.sh

# Index

Expand All @@ -29,4 +29,4 @@ if ! [ -f "./storage/tracker/lib/database/torrust_tracker_e2e_testing.db" ]; the
sqlite3 ./storage/tracker/lib/database/torrust_tracker_e2e_testing.db "VACUUM;"
fi

./docker/bin/e2e/mysql/e2e-env-up.sh
./contrib/dev-tools/container/e2e/mysql/e2e-env-up.sh
4 changes: 2 additions & 2 deletions contrib/dev-tools/container/e2e/mysql/e2e-env-restart.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

docker compose down
./docker/bin/e2e/mysql/e2e-env-up.sh
./contrib/dev-tools/container/e2e/mysql/e2e-env-downp.sh
./contrib/dev-tools/container/e2e/mysql/e2e-env-up.sh
17 changes: 10 additions & 7 deletions contrib/dev-tools/container/e2e/mysql/e2e-env-up.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/bin/bash

TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \
TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.container.mysql.toml) \
docker compose build

TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \
TORRUST_IDX_BACK_CONFIG=$(cat config-idx-back.mysql.local.toml) \
USER_ID=${USER_ID:-1000} \
# Index
TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.container.mysql.toml) \
TORRUST_INDEX_DATABASE_DRIVER="mysql" \
TORRUST_INDEX_TRACKER_API_TOKEN="MyAccessToken" \
TORRUST_IDX_BACK_MYSQL_DATABASE="torrust_index_e2e_testing" \
TORRUST_TRACKER_CONFIG=$(cat config-tracker.local.toml) \
TORRUST_TRACKER_DATABASE_DRIVER=${TORRUST_TRACKER_DATABASE_DRIVER:-mysql} \
TORRUST_TRACKER_API_ADMIN_TOKEN=${TORRUST_TRACKER_API_ADMIN_TOKEN:-MyAccessToken} \
# Tracker
TORRUST_TRACKER_CONFIG=$(cat ./share/default/config/tracker.container.mysql.toml) \
TORRUST_TRACKER_DATABASE_DRIVER="mysql" \
TORRUST_TRACKER_API_ADMIN_TOKEN="MyAccessToken" \
docker compose up -d

15 changes: 8 additions & 7 deletions contrib/dev-tools/container/e2e/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ 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
./contrib/dev-tools/init/install-local.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
./contrib/dev-tools/container/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 index and wait until they are healthy
Expand All @@ -60,16 +60,16 @@ sleep 20s
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
TORRUST_IDX_BACK_E2E_SHARED=true TORRUST_IDX_BACK_E2E_CONFIG_PATH="./share/default/config/index.container.sqlite3.toml" cargo test || exit 1

# Stop E2E testing environment
docker compose down
./contrib/dev-tools/container/e2e/sqlite/e2e-env-down.sh || exit 1

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

# Start E2E testing environment
./docker/bin/e2e/mysql/e2e-env-up.sh || exit 1
./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
Expand All @@ -91,7 +91,8 @@ 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;"

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

# Stop E2E testing environment
docker compose down
./contrib/dev-tools/container/e2e/mysql/e2e-env-down.sh || exit 1

5 changes: 5 additions & 0 deletions contrib/dev-tools/container/e2e/sqlite/e2e-env-down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.container.sqlite3.toml) \
TORRUST_TRACKER_CONFIG=$(cat ./share/default/config/tracker.container.sqlite3.toml) \
docker compose down
4 changes: 2 additions & 2 deletions contrib/dev-tools/container/e2e/sqlite/e2e-env-reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Delete the databases and recreate them.

docker compose down
./contrib/dev-tools/container/e2e/sqlite/e2e-env-down.sh

rm -f ./storage/database/torrust_index_e2e_testing.db
rm -f ./storage/tracker/lib/database/torrust_tracker_e2e_testing.db
Expand All @@ -20,4 +20,4 @@ if ! [ -f "./storage/tracker/lib/database/torrust_tracker_e2e_testing.db" ]; the
sqlite3 ./storage/tracker/lib/database/torrust_tracker_e2e_testing.db "VACUUM;"
fi

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

docker compose down
./docker/bin/e2e/sqlite/e2e-env-up.sh
./contrib/dev-tools/container/e2e/sqlite/e2e-env-down.sh
./contrib/dev-tools/container/e2e/sqlite/e2e-env-up.sh
18 changes: 10 additions & 8 deletions contrib/dev-tools/container/e2e/sqlite/e2e-env-up.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/bin/bash

TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \
TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.container.sqlite3.toml) \
docker compose build

TORRUST_IDX_BACK_USER_UID=${TORRUST_IDX_BACK_USER_UID:-1000} \
TORRUST_IDX_BACK_CONFIG=$(cat config-idx-back.sqlite.local.toml) \
TORRUST_IDX_BACK_MYSQL_DATABASE="torrust_index_e2e_testing" \
TORRUST_TRACKER_CONFIG=$(cat config-tracker.local.toml) \
TORRUST_TRACKER_DATABASE_DRIVER=${TORRUST_TRACKER_DATABASE_DRIVER:-sqlite3} \
TORRUST_TRACKER_API_ADMIN_TOKEN=${TORRUST_TRACKER_API_ADMIN_TOKEN:-MyAccessToken} \
USER_ID=${USER_ID:-1000} \
# Index
TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.container.sqlite3.toml) \
TORRUST_INDEX_DATABASE_DRIVER="sqlite3" \
TORRUST_INDEX_TRACKER_API_TOKEN="MyAccessToken" \
# Tracker
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

4 changes: 2 additions & 2 deletions contrib/dev-tools/container/install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

./docker/bin/build.sh
./bin/install.sh
./contrib/dev-tools/container/e2e/bin/build.sh
./contrib/dev-tools/init/install-local.sh
2 changes: 1 addition & 1 deletion contrib/dev-tools/init/install-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ 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;"
sqlite3 ./storage/index/lib/database/sqlite3.db "VACUUM;"
fi

0 comments on commit 64479b7

Please sign in to comment.