Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: E2E test execution continues even when the docker build fail due to test fails #728

Open
josecelano opened this issue Sep 11, 2024 · 0 comments
Labels
- Developer - Torrust Improvement Experience Bug Incorrect Behavior Continuous Integration Workflows and Automation

Comments

@josecelano
Copy link
Member

You can run E2E tests (with Sqlite) locally with:

./contrib/dev-tools/container/e2e/sqlite/run-e2e-tests.sh

The script:

  • builds the docker image
  • starts the containers (docker compose up)
  • runs the E2E tests using the shared docker environment

The Containerfile contains a layer to run the unit tests:

# Extract and Test (release)
FROM tester AS test
WORKDIR /test
COPY . /test/src
COPY --from=build \
  /build/torrust-index.tar.zst \
  /test/torrust-index.tar.zst
RUN cargo nextest run --workspace-remap /test/src/ --extract-to /test/src/ --no-run --archive-file /test/torrust-index.tar.zst
RUN cargo nextest run --workspace-remap /test/src/ --target-dir-remap /test/src/target/ --cargo-metadata /test/src/target/nextest/cargo-metadata.json --binaries-metadata /test/src/target/nextest/binaries-metadata.json

If some tests fail, the build fails, but the E2E script (run-e2e-tests.sh) continues executing the next steps.

The output when the test fail:

2.116         FAIL [   0.462s] torrust-index::mod e2e::web::api::v1::contexts::torrent::contract::for_authenticated_users::and_non_admins::it_should_allow_non_admin_users_to_upload_torrents
2.116 warning: 6/154 tests were not run due to test failure (run with --no-fail-fast to run all tests)
2.118 error: test run failed
------
failed to solve: process "/bin/sh -c cargo nextest run --workspace-remap /test/src/ --target-dir-remap /test/src/target/ --cargo-metadata /test/src/target/nextest/cargo-metadata.json --binaries-metadata /test/src/target/nextest/binaries-metadata.json" did not complete successfully: exit code: 100

You can reproduce it by simply adding a failing test.

I guess we can fixed but returning an error code in the contrib/dev-tools/container/e2e/sqlite/mode/public/e2e-env-up.sh script.

#!/bin/bash

TORRUST_INDEX_CONFIG_TOML=$(cat ./share/default/config/index.public.e2e.container.sqlite3.toml) \
    docker compose build --no-cache || exit 1

USER_ID=${USER_ID:-1000} \
    TORRUST_INDEX_CONFIG_TOML=$(cat ./share/default/config/index.public.e2e.container.sqlite3.toml) \
    TORRUST_INDEX_DATABASE="e2e_testing_sqlite3" \
    TORRUST_INDEX_DATABASE_DRIVER="sqlite3" \
    TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN="MyAccessToken" \
    TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__USER_CLAIM_TOKEN_PEPPER="MaxVerstappenWC2021" \
    TORRUST_TRACKER_CONFIG_TOML=$(cat ./share/default/config/tracker.public.e2e.container.sqlite3.toml) \
    TORRUST_TRACKER_DATABASE="e2e_testing_sqlite3" \
    TORRUST_TRACKER_CONFIG_OVERRIDE_CORE__DATABASE__DRIVER="sqlite3" \
    TORRUST_TRACKER_CONFIG_OVERRIDE_HTTP_API__ACCESS_TOKENS__ADMIN="MyAccessToken" \
    docker compose up --detach --pull always --remove-orphans || exit 1

NOTICE: the || exit 1

I haven't tested it yet.

@josecelano josecelano added Bug Incorrect Behavior Continuous Integration Workflows and Automation - Developer - Torrust Improvement Experience labels Sep 11, 2024
@josecelano josecelano transferred this issue from torrust/torrust-tracker Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Developer - Torrust Improvement Experience Bug Incorrect Behavior Continuous Integration Workflows and Automation
Projects
None yet
Development

No branches or pull requests

1 participant