Skip to content

Commit 27bf44b

Browse files
add test pipeline
ISSUE: CLDSRVCLT-2
1 parent 62e6a9a commit 27bf44b

File tree

6 files changed

+215
-0
lines changed

6 files changed

+215
-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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'development/**'
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
test-mongodb-backend:
14+
name: Test with MongoDB backend
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
25+
cache: 'yarn'
26+
27+
- name: Install dependencies
28+
run: yarn install --frozen-lockfile
29+
30+
- name: Start Cloudserver with MongoDB backend
31+
run: docker compose -f .github/docker-compose.cloudserver-mongo.yml up -d
32+
33+
- name: Wait for Cloudserver to be ready
34+
run: |
35+
set -o pipefail
36+
bash .github/scripts/wait_for_local_port.bash 8000 40
37+
38+
- name: Run MongoDB backend tests
39+
run: yarn test:mongo-backend
40+
41+
- name: Stop Cloudserver
42+
if: always()
43+
run: docker compose -f .github/docker-compose.cloudserver-mongo.yml down
44+
45+
test-metadata-backend:
46+
name: Test with Scality metadata backend
47+
runs-on: ubuntu-latest
48+
needs: lint
49+
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v4
53+
54+
- name: Setup Node.js
55+
uses: actions/setup-node@v4
56+
with:
57+
node-version: '20'
58+
cache: 'yarn'
59+
60+
- name: Install dependencies
61+
run: yarn install --frozen-lockfile
62+
63+
- name: Login to GitHub Container Registry
64+
uses: docker/login-action@v3
65+
with:
66+
registry: ghcr.io
67+
username: ${{ github.repository_owner }}
68+
password: ${{ github.token }}
69+
70+
- name: Start Cloudserver with Scality metadata backend
71+
run: docker compose -f .github/docker-compose.cloudserver-metadata.yml up -d
72+
73+
- name: Wait for metadata to be ready
74+
run: |
75+
set -o pipefail
76+
bash .github/scripts/wait_for_local_port.bash 9000 40
77+
78+
- name: Wait for Cloudserver to be ready
79+
run: |
80+
set -o pipefail
81+
bash .github/scripts/wait_for_local_port.bash 8000 60
82+
83+
- name: Run metadata backend tests
84+
run: yarn test:metadata-backend
85+
86+
- name: Stop Cloudserver
87+
if: always()
88+
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:api": "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:api && 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)