diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 3172109..5f026ce 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -54,6 +54,16 @@ jobs: with: node-version: ${{ matrix.node-version }} + - name: Setup MinIO + run: | + docker run -d \ + --name minio \ + -p 9000:9000 -p 9001:9001 \ + -e MINIO_ROOT_USER=layotto \ + -e MINIO_ROOT_PASSWORD=layotto_secret \ + minio/minio:latest server /data --console-address ":9001" + bash scripts/setup-minio.sh + - name: Bootstrap layotto # run: | # cd demo diff --git a/README.md b/README.md index 672244a..45a36fe 100644 --- a/README.md +++ b/README.md @@ -65,12 +65,18 @@ npm run build:grpc ### step 1. Set up the environment -- Running redis and etcd under Docker +- Running redis, etcd and MinIO under Docker ```bash docker-compose up -d ``` +- Setup MinIO bucket for OSS tests + +```bash +bash scripts/setup-minio.sh +``` + - Start a echoserver for testing the rpc api ```bash diff --git a/demo/config.json b/demo/config.json index ec049b9..5336c09 100644 --- a/demo/config.json +++ b/demo/config.json @@ -94,6 +94,17 @@ } } }, + "file": { + "oss_demo": { + "type": "minio", + "metadata": { + "endpoint": "localhost:9000", + "accessKeyID": "layotto", + "accessKeySecret": "layotto_secret", + "SSL": false + } + } + }, "app": { "app_id": "app1", "grpc_callback_port": 9999 diff --git a/docker-compose.yml b/docker-compose.yml index 9b917d7..0f5a911 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,8 +23,29 @@ services: networks: - layotto-js-sdk + minio: + image: minio/minio:latest + command: server /data --console-address ":9001" + restart: always + environment: + - MINIO_ROOT_USER=layotto + - MINIO_ROOT_PASSWORD=layotto_secret + ports: + - 9000:9000 + - 9001:9001 + volumes: + - layotto-js-sdk-minio:/data + networks: + - layotto-js-sdk + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] + interval: 10s + timeout: 5s + retries: 5 + volumes: layotto-js-sdk-redis: + layotto-js-sdk-minio: networks: layotto-js-sdk: diff --git a/scripts/setup-minio.sh b/scripts/setup-minio.sh new file mode 100755 index 0000000..57d1b49 --- /dev/null +++ b/scripts/setup-minio.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Setup MinIO for testing +# This script creates the required bucket for OSS tests + +set -e + +# Wait for MinIO to be ready +echo "Waiting for MinIO to be ready..." +for i in {1..30}; do + if curl -sf http://localhost:9000/minio/health/live > /dev/null 2>&1; then + echo "MinIO is ready!" + break + fi + if [ "$i" -eq 30 ]; then + echo "MinIO failed to start" + exit 1 + fi + echo "Waiting for MinIO... ($i/30)" + sleep 1 +done + +# Install MinIO client if not available +if ! command -v mc &> /dev/null; then + echo "Installing MinIO client..." + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + curl -sSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /tmp/mc + elif [[ "$OSTYPE" == "darwin"* ]]; then + curl -sSL https://dl.min.io/client/mc/release/darwin-amd64/mc -o /tmp/mc + else + echo "Unsupported OS: $OSTYPE" + exit 1 + fi + chmod +x /tmp/mc + MC_CMD="/tmp/mc" +else + MC_CMD="mc" +fi + +# Configure MinIO alias +echo "Configuring MinIO client..." +$MC_CMD alias set myminio http://localhost:9000 layotto layotto_secret + +# Create test bucket +echo "Creating test bucket..." +$MC_CMD mb myminio/antsys-tnpmbuild --ignore-existing + +echo "MinIO setup complete!" diff --git a/test/unit/client/Oss.test.ts b/test/unit/client/Oss.test.ts index 556ba4d..308c666 100644 --- a/test/unit/client/Oss.test.ts +++ b/test/unit/client/Oss.test.ts @@ -6,7 +6,7 @@ import crypto from 'node:crypto'; import { Client } from '../../../src'; import { randomUUID } from 'node:crypto'; -describe.skip('client/Oss.test.ts', () => { +describe('client/Oss.test.ts', () => { const client = new Client('34904', '127.0.0.1', { ossEnable: true }); it('test put object', async () => {