Skip to content

Commit 0c59ad5

Browse files
add test pipeline
ISSUE: CLDSRVCLT-2x
1 parent afb3900 commit 0c59ad5

File tree

6 files changed

+218
-0
lines changed

6 files changed

+218
-0
lines changed
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

.github/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+
}
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

.github/workflows/test.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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: Start Cloudserver with MongoDB backend
32+
run: docker compose -f .github/docker-compose.cloudserver-mongo.yml up -d
33+
34+
- name: Wait for Cloudserver to be ready
35+
run: |
36+
set -o pipefail
37+
bash .github/scripts/wait_for_local_port.bash 8000 40
38+
39+
- name: Run MongoDB backend tests
40+
run: yarn test:mongo-backend
41+
42+
- name: Stop Cloudserver
43+
if: always()
44+
run: docker compose -f .github/docker-compose.cloudserver-mongo.yml down
45+
46+
test-metadata-backend:
47+
name: Test with Scality metadata backend
48+
runs-on: ubuntu-latest
49+
permissions:
50+
contents: read
51+
packages: write
52+
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@v4
56+
57+
- name: Setup Node.js
58+
uses: actions/setup-node@v4
59+
with:
60+
node-version: '20'
61+
cache: 'yarn'
62+
63+
- name: Install dependencies
64+
run: yarn install --frozen-lockfile
65+
66+
- name: Login to GitHub Container Registry
67+
uses: docker/login-action@v3
68+
with:
69+
registry: ghcr.io
70+
username: ${{ github.repository_owner }}
71+
password: ${{ github.token }}
72+
73+
- name: Start Cloudserver with Scality metadata backend
74+
run: docker compose -f .github/docker-compose.cloudserver-metadata.yml up -d
75+
76+
- name: Wait for metadata to be ready
77+
run: |
78+
set -o pipefail
79+
bash .github/scripts/wait_for_local_port.bash 9000 40
80+
81+
- name: Wait for Cloudserver to be ready
82+
run: |
83+
set -o pipefail
84+
bash .github/scripts/wait_for_local_port.bash 8000 60
85+
86+
- name: Run metadata backend tests
87+
run: yarn test:metadata-backend
88+
89+
- name: Stop Cloudserver
90+
if: always()
91+
run: docker compose -f .github/docker-compose.cloudserver-metadata.yml down

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
"build:wrapper": "tsc",
1919
"build": "yarn install && yarn clean:build && yarn build:smithy && yarn build:generated && yarn build:wrapper",
2020
"test": "jest",
21+
"test:indexes": "jest tests/testIndexesApis.test.ts",
22+
"test:error-handling": "jest tests/testErrorHandling.test.ts",
23+
"test:multiple-backend": "jest tests/testMultipleBackendApis.test.ts",
24+
"test:general": "jest tests/testApis.test.ts",
25+
"test:lifecycle": "jest tests/testLifecycleApis.test.ts",
26+
"test:metadata": "jest tests/testMetadataApis.test.ts",
27+
"test:raft": "jest tests/testRaftApis.test.ts",
28+
"test:mongo-backend": "yarn test:indexes && yarn test:error-handling && yarn test:multiple-backend",
29+
"test:metadata-backend": "yarn test:general && yarn test:lifecycle && yarn test:metadata && yarn test:raft",
2130
"lint": "eslint . --ext .ts,.tsx",
2231
"typecheck": "tsc --noEmit"
2332
},

0 commit comments

Comments
 (0)