mirror of
https://github.com/SaraSmiseth/prosody.git
synced 2025-05-04 13:10:38 +00:00
Add support for postgres, mariadb/mysql databases (#23)
* Add environment variables for Database configuration. * Install postgres and mysql dependencies. * Test refactoring * Run tests for prosody with postgres and also for prosody with sqlite. * Add tests that check if postgres or sqlite is used.
This commit is contained in:
parent
5bcf0fd3d0
commit
80216c5fdc
14 changed files with 153 additions and 49 deletions
|
@ -15,31 +15,57 @@ generateCert() {
|
|||
fi
|
||||
}
|
||||
|
||||
registerTestUser() {
|
||||
local userName="$1"
|
||||
local containerName="$2"
|
||||
sudo docker exec "$containerName" /bin/bash -c "/entrypoint.bash register $userName localhost 12345678"
|
||||
}
|
||||
|
||||
registerTestUsers() {
|
||||
local containerName="$1"
|
||||
registerTestUser admin "$containerName"
|
||||
registerTestUser user1 "$containerName"
|
||||
registerTestUser user2 "$containerName"
|
||||
registerTestUser user3 "$containerName"
|
||||
}
|
||||
|
||||
runTests() {
|
||||
local containerName="$1"
|
||||
python --version \
|
||||
&& python3 --version \
|
||||
&& python3 -m venv venv \
|
||||
&& source venv/bin/activate \
|
||||
&& python --version \
|
||||
&& pip --version \
|
||||
&& pip install -r requirements.txt \
|
||||
&& pytest \
|
||||
&& deactivate \
|
||||
&& sleep 5 \
|
||||
&& sudo docker-compose logs "$containerName" \
|
||||
&& export batsContainerName="$containerName" \
|
||||
&& ./bats/bats-core/bin/bats tests.bats \
|
||||
&& ./bats/bats-core/bin/bats tests-"$containerName".bats
|
||||
}
|
||||
|
||||
generateCert "localhost"
|
||||
generateCert "conference.localhost"
|
||||
generateCert "proxy.localhost"
|
||||
generateCert "pubsub.localhost"
|
||||
generateCert "upload.localhost"
|
||||
|
||||
# Run tests for first container with postgres
|
||||
# Start postgres first and wait for 10 seconds before starting prosody.
|
||||
sudo docker-compose down \
|
||||
&& sudo docker-compose up -d \
|
||||
\
|
||||
&& sudo docker exec tests_prosody_1 /bin/bash -c "/entrypoint.sh register admin localhost 12345678" \
|
||||
&& sudo docker exec tests_prosody_1 /bin/bash -c "/entrypoint.sh register user1 localhost 12345678" \
|
||||
&& sudo docker exec tests_prosody_1 /bin/bash -c "/entrypoint.sh register user2 localhost 12345678" \
|
||||
&& sudo docker exec tests_prosody_1 /bin/bash -c "/entrypoint.sh register user3 localhost 12345678" \
|
||||
\
|
||||
&& python --version \
|
||||
&& python3 --version \
|
||||
&& python3 -m venv venv \
|
||||
&& source venv/bin/activate \
|
||||
&& python --version \
|
||||
&& pip --version \
|
||||
&& pip install -r requirements.txt \
|
||||
&& pytest \
|
||||
&& deactivate \
|
||||
&& sleep 5 \
|
||||
&& sudo docker-compose logs \
|
||||
&& ./bats/bats-core/bin/bats tests.bats
|
||||
&& sudo docker-compose up -d postgres \
|
||||
&& sleep 10 \
|
||||
&& sudo docker-compose up -d prosody_postgres
|
||||
|
||||
registerTestUsers tests_prosody_postgres_1
|
||||
runTests prosody_postgres
|
||||
sudo docker-compose down
|
||||
|
||||
# Run tests for second container with SQLite
|
||||
sudo docker-compose up -d prosody
|
||||
registerTestUsers tests_prosody_1
|
||||
runTests prosody
|
||||
sudo docker-compose down
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue