mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-02-10 18:05:07 +08:00
[test] azure test
This commit is contained in:
118
.github/workflows/azureStorageTests.yml
vendored
Normal file
118
.github/workflows/azureStorageTests.yml
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
name: Azure Storage Tests
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
paths:
|
||||
- 'tests/integration/withServerInstance/storage.tests.js'
|
||||
- 'Common/sources/storage/**'
|
||||
|
||||
jobs:
|
||||
azure-storage-tests:
|
||||
name: Azure Storage Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Run Azurite docker container
|
||||
run: |
|
||||
docker run --name azurite \
|
||||
-p 10000:10000 \
|
||||
-p 10001:10001 \
|
||||
-p 10002:10002 \
|
||||
-d mcr.microsoft.com/azure-storage/azurite \
|
||||
azurite-blob --blobHost 0.0.0.0 --loose
|
||||
|
||||
- name: Caching dependencies
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '20'
|
||||
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: Setup Azure storage test environment
|
||||
run: |
|
||||
# Wait for Azurite to be ready
|
||||
sleep 15
|
||||
|
||||
# Create Azure storage configuration
|
||||
cat > Common/config/local.json << 'EOF'
|
||||
{
|
||||
"storage": {
|
||||
"name": "storage-az",
|
||||
"region": "",
|
||||
"endpoint": "http://127.0.0.1:10000/devstoreaccount1",
|
||||
"bucketName": "test-container",
|
||||
"storageFolderName": "files",
|
||||
"cacheFolderName": "data",
|
||||
"accessKeyId": "devstoreaccount1",
|
||||
"secretAccessKey": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
|
||||
},
|
||||
"persistentStorage": {
|
||||
"name": "storage-az",
|
||||
"region": "",
|
||||
"endpoint": "http://127.0.0.1:10000/devstoreaccount1",
|
||||
"bucketName": "test-container",
|
||||
"storageFolderName": "files",
|
||||
"cacheFolderName": "data",
|
||||
"accessKeyId": "devstoreaccount1",
|
||||
"secretAccessKey": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "Azure storage configuration created"
|
||||
|
||||
- name: Create Azure container using Node.js from Common directory
|
||||
run: |
|
||||
# Wait a bit more for Azurite to be fully ready
|
||||
sleep 10
|
||||
|
||||
# Run Node.js script from Common directory where Azure dependencies are installed
|
||||
cd Common
|
||||
node -e "
|
||||
const { BlobServiceClient, StorageSharedKeyCredential } = require('@azure/storage-blob');
|
||||
|
||||
async function setupContainer() {
|
||||
try {
|
||||
const accountName = 'devstoreaccount1';
|
||||
const accountKey = 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==';
|
||||
const endpoint = 'http://127.0.0.1:10000/devstoreaccount1';
|
||||
|
||||
const credential = new StorageSharedKeyCredential(accountName, accountKey);
|
||||
const blobServiceClient = new BlobServiceClient(endpoint, credential);
|
||||
const containerClient = blobServiceClient.getContainerClient('test-container');
|
||||
|
||||
console.log('Creating container...');
|
||||
await containerClient.createIfNotExists();
|
||||
console.log('Container created successfully');
|
||||
|
||||
// Upload a test file if needed
|
||||
const blockBlobClient = containerClient.getBlockBlobClient('testfile.txt');
|
||||
await blockBlobClient.upload('Test content', Buffer.byteLength('Test content'));
|
||||
console.log('Test file uploaded');
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error setting up Azure storage:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
setupContainer();
|
||||
"
|
||||
|
||||
- name: Run storage tests
|
||||
run: |
|
||||
cd ./DocService
|
||||
npx jest ../tests/integration/withServerInstance/storage.tests.js --inject-globals=false --config=../tests/jest.config.js
|
||||
2
.github/workflows/s3storageTests.yml
vendored
2
.github/workflows/s3storageTests.yml
vendored
@ -28,7 +28,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
|
||||
|
||||
Reference in New Issue
Block a user