From 51a90a25dcd4617b8d9b2cc53ebf1d08be33c49f Mon Sep 17 00:00:00 2001 From: PauI Ostrovckij Date: Wed, 11 Jun 2025 22:47:27 +0300 Subject: [PATCH] [feature] run s3,fs storage tests in pipeline --- .github/workflows/fsStorageTests.yml | 97 ++++++++++++++++++++++++++++ .github/workflows/s3storageTests.yml | 75 +++++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 .github/workflows/fsStorageTests.yml create mode 100644 .github/workflows/s3storageTests.yml diff --git a/.github/workflows/fsStorageTests.yml b/.github/workflows/fsStorageTests.yml new file mode 100644 index 00000000..7efe18d0 --- /dev/null +++ b/.github/workflows/fsStorageTests.yml @@ -0,0 +1,97 @@ +name: fs Storage Tests +on: + push: + branches: + - '**' + paths: + - 'tests/integration/withServerInstance/storage.tests.js' + - 'Common/sources/storage/**' + +jobs: + fs-storage-tests: + name: File System Storage + runs-on: ubuntu-latest + + steps: + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Caching dependencies + uses: actions/setup-node@v3 + with: + node-version: '16' + cache: 'npm' + cache-dependency-path: | + ./npm-shrinkwrap.json + ./Common/npm-shrinkwrap.json + ./DocService/npm-shrinkwrap.json + + - name: Install modules + run: | + npm ci + 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 Common/config + echo '{ + "storage": { + "name": "storage-fs", + "fs": { + "folderPath": "/tmp/storage", + "urlExpires": 900, + "secretString": "verysecretstring" + }, + "region": "", + "endpoint": "http://localhost/s3", + "bucketName": "cache", + "storageFolderName": "files", + "cacheFolderName": "data", + "urlExpires": 604800, + "accessKeyId": "", + "secretAccessKey": "", + "sslEnabled": false, + "s3ForcePathStyle": true, + "externalHost": "", + "useDirectStorageUrls": true + }, + }' > 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 \ No newline at end of file diff --git a/.github/workflows/s3storageTests.yml b/.github/workflows/s3storageTests.yml new file mode 100644 index 00000000..78594388 --- /dev/null +++ b/.github/workflows/s3storageTests.yml @@ -0,0 +1,75 @@ +name: s3 Storage Tests +on: + push: + branches: + - '**' + paths: + - 'tests/integration/withServerInstance/storage.tests.js' + - 'Common/sources/storage/**' + +jobs: + storage-tests: + name: Storage Tests + runs-on: ubuntu-latest + + steps: + - name: Run MinIO docker container + run: | + docker run --name minio \ + -p 9000:9000 \ + -p 9001:9001 \ + -e "MINIO_ROOT_USER=minioadmin" \ + -e "MINIO_ROOT_PASSWORD=minioadmin" \ + -d minio/minio server /data --console-address ":9001" + + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Caching dependencies + uses: actions/setup-node@v3 + with: + node-version: '16' + cache: 'npm' + cache-dependency-path: | + ./npm-shrinkwrap.json + ./Common/npm-shrinkwrap.json + ./DocService/npm-shrinkwrap.json + + - name: Install modules + run: | + npm ci + npm --prefix Common ci + npm --prefix DocService ci + + - name: Creating storage configuration + run: | + echo '{ + "storage": { + "name": "storage-s3", + "region": "us-east-1", + "endpoint": "http://localhost:9000", + "accessKeyId": "minioadmin", + "secretAccessKey": "minioadmin", + "bucket": "cache", + "forcePathStyle": true + }, + "persistentStorage": { + "name": "storage-s3", + "region": "us-east-1", + "endpoint": "http://localhost:9000", + "accessKeyId": "minioadmin", + "secretAccessKey": "minioadmin", + "bucket": "cache", + "forcePathStyle": true + } + }' >> Common/config/local.json + + - name: Create MinIO buckets + run: | + docker exec minio mc alias set myminio http://localhost:9000 minioadmin minioadmin + docker exec minio mc mb myminio/cache + + - name: Run storage tests + run: | + cd ./DocService + npx jest ../tests/integration/withServerInstance/storage.tests.js --inject-globals=false --config=../tests/jest.config.js \ No newline at end of file