Skip to content

Don't use the default container databases for E2E testing #392

@josecelano

Description

@josecelano

Parent: #384

If I'm not wrong @da2ce7, the entrypoint.sh script for the container copies the default configuration file and creates the SQLite empty database (if we are using SQLite) the first time the container is executed. That allows users to run the service without providing a configuration.

It uses the default configuration in the share/default/config dir.

For SQLite:

  • /usr/share/torrust/default/database/index.sqlite3.db
  • /usr/share/torrust/default/config/index.container.sqlite3.toml

The database connection config option in that toml file is:

[database]
connect_url = "sqlite:///var/lib/torrust/index/database/sqlite3.db?mode=rwc"

The file /usr/share/torrust/default/database/index.sqlite3.db is copied to /var/lib/torrust/index/database/sqlite3.db inside the container.

To run E2E tests we use docker and we use the same configuration:

# run-e2e-tests.sh
USER_ID=${USER_ID:-1000} \
    TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.container.sqlite3.toml) \
    TORRUST_INDEX_DATABASE_DRIVER="sqlite3" \
    TORRUST_INDEX_TRACKER_API_TOKEN="MyAccessToken" \
    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

As you can see we inject the same configuration /share/default/config/index.container.sqlite3.toml file.

That means we use the default database to run E2E tests. In our previous setup before the container overhaul, we were using different databases, to avoid overwriting the default containerized environment.

I think we only need to add new configuration files for E2E testing:

  • contrib/dev-tools/container/e2e/mysql/index.container.e2e.mysql.toml
  • contrib/dev-tools/container/e2e/sqlite/index.container.e2e.sqlite3.toml
  • contrib/dev-tools/container/e2e/mysql/tracker.container.e2e.mysql.toml
  • contrib/dev-tools/container/e2e/sqlite/tracker.container.e2e.sqlite3.toml

And change the run-e2e-tests.sh script to use the new files.

What do you think @da2ce7?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions