Skip to content

Commit 7fa7e8b

Browse files
add test pipeline
ISSUE: CLDSRVCLT-2x
1 parent afb3900 commit 7fa7e8b

File tree

5 files changed

+225
-0
lines changed

5 files changed

+225
-0
lines changed

.github/workflows/test.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main, improvement/** ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
test-mongodb-backend:
15+
name: Test with MongoDB backend
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '20'
26+
cache: 'yarn'
27+
28+
- name: Install dependencies
29+
run: yarn install --frozen-lockfile
30+
31+
- name: TypeScript typecheck
32+
run: yarn typecheck
33+
34+
- name: Lint
35+
run: yarn lint
36+
37+
- name: Start Cloudserver with MongoDB backend
38+
run: docker compose -f docker-compose.cloudserver-mongo.yml up -d
39+
40+
- name: Wait for Cloudserver to be ready
41+
run: |
42+
set -o pipefail
43+
bash .github/workflows/wait_for_local_port.bash 8000 40
44+
45+
- name: Run indexes apis tests
46+
run: yarn test tests/testIndexesApis.test.ts
47+
- name: Run error handling tests
48+
run: yarn test tests/testErrorHandling.test.ts
49+
- name: Run multiple backend apis tests
50+
run: yarn test tests/testMultipleBackendApis.test.ts
51+
52+
- name: Stop Cloudserver
53+
if: always()
54+
run: docker compose -f docker-compose.cloudserver-mongo.yml down
55+
56+
test-metadata-backend:
57+
name: Test with Scality metadata backend
58+
runs-on: ubuntu-latest
59+
permissions:
60+
contents: read
61+
packages: write
62+
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v4
66+
67+
- name: Setup Node.js
68+
uses: actions/setup-node@v4
69+
with:
70+
node-version: '20'
71+
cache: 'yarn'
72+
73+
- name: Install dependencies
74+
run: yarn install --frozen-lockfile
75+
76+
- name: Login to GitHub Container Registry
77+
uses: docker/login-action@v3
78+
with:
79+
registry: ghcr.io
80+
username: ${{ github.repository_owner }}
81+
password: ${{ github.token }}
82+
83+
- name: Start Cloudserver with Scality metadata backend
84+
run: docker compose -f docker-compose.cloudserver-metadata.yml up -d
85+
86+
- name: Wait for metadata to be ready
87+
run: |
88+
set -o pipefail
89+
bash .github/workflows/wait_for_local_port.bash 9000 40
90+
91+
- name: Wait for Cloudserver to be ready
92+
run: |
93+
set -o pipefail
94+
bash .github/workflows/wait_for_local_port.bash 8000 60
95+
96+
- name: Run general apis tests
97+
run: yarn test tests/testApis.test.ts
98+
- name: Run lifecycle apis tests
99+
run: yarn test tests/testLifecycleApis.test.ts
100+
- name: Run metadata apis tests
101+
run: yarn test tests/testMetadataApis.test.ts
102+
- name: Run raft apis tests
103+
run: yarn test tests/testRaftApis.test.ts
104+
105+
- name: Stop Cloudserver
106+
if: always()
107+
run: docker compose -f docker-compose.cloudserver-metadata.yml down
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -e
3+
4+
PORT=$1
5+
TIMEOUT=${2:-30}
6+
7+
echo "Waiting for port $PORT to be ready (timeout: ${TIMEOUT}s)..."
8+
9+
for i in $(seq 1 $TIMEOUT); do
10+
if nc -z localhost $PORT 2>/dev/null; then
11+
echo "Port $PORT is ready!"
12+
exit 0
13+
fi
14+
echo "Attempt $i/$TIMEOUT: Port $PORT not ready yet..."
15+
sleep 1
16+
done
17+
18+
echo "ERROR: Port $PORT did not become ready within ${TIMEOUT}s"
19+
exit 1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
services:
2+
metadata-standalone:
3+
image: ghcr.io/scality/metadata:8.11.0-standalone
4+
platform: linux/amd64
5+
network_mode: 'host'
6+
volumes:
7+
- ./md-config.json:/mnt/standalone_workdir/config.json:ro
8+
9+
cloudserver-metadata:
10+
image: ghcr.io/scality/cloudserver:9.1.4
11+
platform: linux/amd64
12+
network_mode: 'host'
13+
environment:
14+
- S3VAULT=mem
15+
- S3METADATA=scality
16+
- S3DATA=mem
17+
- REMOTE_MANAGEMENT_DISABLE=true
18+
- SCALITY_ACCESS_KEY_ID=accessKey1
19+
- SCALITY_SECRET_ACCESS_KEY=verySecretKey1
20+
- LOG_LEVEL=info
21+
depends_on:
22+
- metadata-standalone
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
services:
2+
mongodb:
3+
image: mongo:5.0
4+
platform: linux/amd64
5+
command: --replSet rs0 --port 27018 --bind_ip_all
6+
ports:
7+
- "27018:27018"
8+
healthcheck:
9+
test: echo 'db.runCommand("ping").ok' | mongosh --port 27018 --quiet
10+
interval: 5s
11+
timeout: 10s
12+
retries: 5
13+
start_period: 10s
14+
15+
mongo-init:
16+
image: mongo:5.0
17+
platform: linux/amd64
18+
depends_on:
19+
mongodb:
20+
condition: service_healthy
21+
command: >
22+
mongosh --host mongodb:27018 --eval
23+
'rs.initiate({_id: "rs0", members: [{_id: 0, host: "mongodb:27018"}]})'
24+
restart: "no"
25+
26+
cloudserver:
27+
image: ghcr.io/scality/cloudserver:9.1.4
28+
platform: linux/amd64
29+
ports:
30+
- "8000:8000"
31+
environment:
32+
- S3VAULT=mem
33+
- S3METADATA=mongodb
34+
- S3DATA=mem
35+
- MONGODB_HOSTS=mongodb:27018
36+
- MONGODB_RS=rs0
37+
- REMOTE_MANAGEMENT_DISABLE=true
38+
- SCALITY_ACCESS_KEY_ID=accessKey1
39+
- SCALITY_SECRET_ACCESS_KEY=verySecretKey1
40+
- LOG_LEVEL=info
41+
depends_on:
42+
mongo-init:
43+
condition: service_completed_successfully
44+
healthcheck:
45+
test: ["CMD", "curl", "-f", "http://localhost:8000/"]
46+
interval: 5s
47+
timeout: 5s
48+
retries: 12

md-config.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"raftSessions": 1,
3+
"raftMembers": 5,
4+
"bucketdCount": 1,
5+
"bucketdWorkers": 1,
6+
"basePorts": {
7+
"bucketd": 9000,
8+
"repd": 4200,
9+
"repdAdmin": 4250
10+
},
11+
"logLevel": "info",
12+
"env": {
13+
"METADATA_NEW_BUCKETS_VFORMAT": "v0",
14+
"S3_VERSION_ID_ENCODING_TYPE":"hex"
15+
},
16+
"migration": {
17+
"deploy": false,
18+
"raftSessions": 0,
19+
"raftMembers": 5,
20+
"bucketdCount": 1,
21+
"bucketdWorkers": 1,
22+
"basePorts": {
23+
"bucketd": 9001,
24+
"repd": 4700,
25+
"repdAdmin": 4750
26+
},
27+
"logLevel": "info"
28+
}
29+
}

0 commit comments

Comments
 (0)