[test] Start mock server in storage.tests.js to run tests independently of live server

This commit is contained in:
Sergey Konovalov
2025-06-16 02:12:24 +03:00
parent 6e12c92016
commit fb341604f9
3 changed files with 31 additions and 80 deletions

View File

@ -19,7 +19,7 @@ jobs:
- name: Caching dependencies
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '20'
cache: 'npm'
cache-dependency-path: |
./npm-shrinkwrap.json
@ -32,25 +32,9 @@ jobs:
npm --prefix Common ci
npm --prefix DocService ci
- name: Install and start RabbitMQ
run: |
sudo apt-get update
sudo apt-get install -y rabbitmq-server
sudo systemctl start rabbitmq-server
sudo rabbitmqctl status
- name: Install and configure PostgreSQL
run: |
sudo apt-get update
sudo apt-get install -y postgresql postgresql-contrib
sudo systemctl start postgresql
sudo -u postgres psql -c "CREATE USER onlyoffice WITH PASSWORD 'onlyoffice';"
sudo -u postgres psql -c "CREATE DATABASE onlyoffice OWNER onlyoffice;"
sudo -u postgres psql -c "ALTER USER onlyoffice WITH SUPERUSER;"
sudo -u postgres psql -d onlyoffice -f schema/postgresql/createdb.sql
- name: Creating service configuration
run: |
mkdir -p /tmp/storage
mkdir -p Common/config
echo '{
"storage": {
@ -75,23 +59,5 @@ jobs:
},
}' > Common/config/local.json
- name: Create storage directory
run: mkdir -p /tmp/storage
- name: Start server instance
run: |
cd DocService && npx cross-env NODE_ENV=development-linux NODE_CONFIG_DIR=../Common/config node sources/server.js &
sleep 10
- name: Run storage tests
run: |
cd ./DocService
npx jest ../tests/integration/withServerInstance/storage.tests.js --inject-globals=false --config=../tests/jest.config.js
- name: Cleanup
if: always()
run: |
pkill -f "node sources/server.js" || true
rm -rf /tmp/storage
sudo systemctl stop rabbitmq-server
sudo systemctl stop postgresql
run: npm run storage-tests