mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(docker): modify db configuration for new tests
A user that can create databases is now required for tests, we use the 'root' user in Docker. Added docker services: --------------------- - mariadb_test - host localhost:13307 Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
fa43f6bc3e
commit
fa26c8078b
12 changed files with 53 additions and 79 deletions
|
@ -5,6 +5,10 @@ set -eou pipefail
|
|||
cp -vf conf/config.dev conf/config
|
||||
sed -i "s;YOUR_AUR_ROOT;$(pwd);g" conf/config
|
||||
|
||||
# Change database user/password.
|
||||
sed -ri "s/^;?(user) = .*$/\1 = aur/" conf/config
|
||||
sed -ri "s/^;?(password) = .*$/\1 = aur/" conf/config
|
||||
|
||||
sed -ri "s;^(aur_location) = .+;\1 = ${AURWEB_FASTAPI_PREFIX};" conf/config
|
||||
|
||||
# Setup Redis for FastAPI.
|
||||
|
|
|
@ -13,23 +13,18 @@ done
|
|||
|
||||
# Configure databases.
|
||||
DATABASE="aurweb" # Persistent database for fastapi/php-fpm.
|
||||
TEST_DB="aurweb_test" # Test database (ephemereal).
|
||||
|
||||
echo "Taking care of primary database '${DATABASE}'..."
|
||||
mysql -u root -e "CREATE USER IF NOT EXISTS 'aur'@'localhost' IDENTIFIED BY 'aur';"
|
||||
mysql -u root -e "CREATE USER IF NOT EXISTS 'aur'@'%' IDENTIFIED BY 'aur';"
|
||||
mysql -u root -e "CREATE DATABASE IF NOT EXISTS $DATABASE;"
|
||||
mysql -u root -e "GRANT ALL ON ${DATABASE}.* TO 'aur'@'localhost';"
|
||||
mysql -u root -e "GRANT ALL ON ${DATABASE}.* TO 'aur'@'%';"
|
||||
|
||||
# Drop and create our test database.
|
||||
echo "Dropping test database '$TEST_DB'..."
|
||||
mysql -u root -e "DROP DATABASE IF EXISTS $TEST_DB;"
|
||||
mysql -u root -e "CREATE DATABASE $TEST_DB;"
|
||||
mysql -u root -e "GRANT ALL ON ${TEST_DB}.* TO 'aur'@'localhost';"
|
||||
mysql -u root -e "GRANT ALL ON ${TEST_DB}.* TO 'aur'@'%';"
|
||||
mysql -u root -e "CREATE USER IF NOT EXISTS 'aur'@'%' IDENTIFIED BY 'aur';"
|
||||
mysql -u root -e "GRANT ALL ON aurweb.* TO 'aur'@'localhost';"
|
||||
mysql -u root -e "GRANT ALL ON aurweb.* TO 'aur'@'%';"
|
||||
|
||||
echo "Created new '$TEST_DB'!"
|
||||
mysql -u root -e "CREATE USER IF NOT EXISTS 'root'@'%' IDENTIFIED BY 'aur';"
|
||||
mysql -u root -e "GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;"
|
||||
|
||||
mysqladmin -uroot shutdown
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ set -eou pipefail
|
|||
# Setup a config for our mysql db.
|
||||
cp -vf conf/config.dev conf/config
|
||||
sed -i "s;YOUR_AUR_ROOT;$(pwd);g" conf/config
|
||||
sed -ri "s/^;?(user) = .*$/\1 = aur/g" conf/config
|
||||
sed -ri "s/^;?(password) = .*$/\1 = aur/g" conf/config
|
||||
|
||||
python -m aurweb.initdb 2>/dev/null || /bin/true
|
||||
|
||||
|
|
|
@ -9,14 +9,19 @@ done
|
|||
cp -vf conf/config.dev conf/config
|
||||
sed -i "s;YOUR_AUR_ROOT;$(pwd);g" conf/config
|
||||
|
||||
sed -ri "s;^(aur_location) = .+;\1 = ${AURWEB_PHP_PREFIX};" conf/config
|
||||
# Change database user/password.
|
||||
sed -ri "s/^;?(user) = .*$/\1 = aur/" conf/config
|
||||
sed -ri "s/^;?(password) = .*$/\1 = aur/" conf/config
|
||||
|
||||
# Enable memcached.
|
||||
sed -ri 's/^(cache) = .+$/\1 = memcache/' conf/config
|
||||
|
||||
# Setup various location configurations.
|
||||
sed -ri "s;^(aur_location) = .+;\1 = ${AURWEB_PHP_PREFIX};" conf/config
|
||||
sed -ri "s|^(git_clone_uri_anon) = .+|\1 = ${AURWEB_PHP_PREFIX}/%s.git|" conf/config.defaults
|
||||
sed -ri "s|^(git_clone_uri_priv) = .+|\1 = ${AURWEB_SSHD_PREFIX}/%s.git|" conf/config.defaults
|
||||
|
||||
# Listen on :9000.
|
||||
sed -ri 's/^(listen).*/\1 = 0.0.0.0:9000/' /etc/php/php-fpm.d/www.conf
|
||||
sed -ri 's/^;?(clear_env).*/\1 = no/' /etc/php/php-fpm.d/www.conf
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -eou pipefail
|
||||
|
||||
# Initialize the new database; ignore errors.
|
||||
python -m aurweb.initdb 2>/dev/null || /bin/true
|
||||
|
||||
exec php-fpm --fpm-config /etc/php/php-fpm.conf --nodaemonize
|
||||
|
|
|
@ -25,17 +25,8 @@ done
|
|||
rm -rf $PROMETHEUS_MULTIPROC_DIR
|
||||
mkdir -p $PROMETHEUS_MULTIPROC_DIR
|
||||
|
||||
# Initialize the new database; ignore errors.
|
||||
python -m aurweb.initdb 2>/dev/null || \
|
||||
(echo "Error: aurweb.initdb failed; already initialized?" && /bin/true)
|
||||
|
||||
# Run test_initdb ahead of time, which clears out the database,
|
||||
# in case of previous failures which stopped the test suite before
|
||||
# finishing the ends of some test fixtures.
|
||||
eatmydata -- pytest test/test_initdb.py
|
||||
|
||||
# Run pytest with optional targets in front of it.
|
||||
eatmydata -- make -C test "${PARAMS[@]}" pytest
|
||||
pytest
|
||||
|
||||
# By default, report coverage and move it into cache.
|
||||
if [ $COVERAGE -eq 1 ]; then
|
||||
|
|
|
@ -12,12 +12,6 @@ bash $dir/run-sharness.sh
|
|||
# Pass --silence to avoid reporting coverage. We will do that below.
|
||||
bash $dir/run-pytests.sh --no-coverage
|
||||
|
||||
# Export SQLite aurweb configuration.
|
||||
export AUR_CONFIG=conf/config.sqlite
|
||||
|
||||
# Run Python tests.
|
||||
bash $dir/run-pytests.sh --no-coverage
|
||||
|
||||
make -C test coverage
|
||||
|
||||
# /cache is mounted as a volume. Copy coverage into it.
|
||||
|
|
|
@ -1,17 +1,8 @@
|
|||
#!/bin/bash
|
||||
set -eou pipefail
|
||||
|
||||
DB_NAME="aurweb_test"
|
||||
|
||||
# Setup a config for our mysql db.
|
||||
cp -vf conf/config.dev conf/config
|
||||
sed -i "s;YOUR_AUR_ROOT;$(pwd);g" conf/config
|
||||
sed -ri "s/^(name) = .+/\1 = ${DB_NAME}/" conf/config
|
||||
|
||||
# The port can be excluded from use if properly using
|
||||
# volumes to share the mysql socket from the mariadb service.
|
||||
# Example port sed:
|
||||
# sed -i "s/^;?(port = .+)$/\1/" conf/config
|
||||
|
||||
# Continue onto the main command.
|
||||
exec "$@"
|
||||
|
|
|
@ -3,6 +3,5 @@ set -eou pipefail
|
|||
dir="$(dirname $0)"
|
||||
|
||||
bash $dir/test-mysql-entrypoint.sh
|
||||
bash $dir/test-sqlite-entrypoint.sh
|
||||
|
||||
exec "$@"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue