Skip to content

Commit e8ad7c4

Browse files
committed
feat: Add upload to aws and retrieving results from aws
1 parent eb0c3a9 commit e8ad7c4

29 files changed

+2220
-61
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,13 @@ build-rbuilder:
5050

5151
.PHONY: build-binaries
5252
build-binaries: build-reth build-geth build-rbuilder
53+
54+
.PHONY: run-benchmark
55+
run-benchmark:
56+
./bin/base-bench run --config ./configs/public/basic.yml --root-dir ./data-dir --output-dir ./output \
57+
--reth-bin ./bin/op-reth --geth-bin ./bin/geth \
58+
--enable-s3=true --s3-bucket base-benchmarking-results-dev
59+
60+
.PHONY: upload-benchmark-results
61+
upload-benchmark-results:
62+
./bin/base-bench export-to-cloud --output-dir ./output --s3-bucket base-benchmarking-results-dev

S3_Backend_Integration_README.md

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
# AWS S3 Integration for Base Benchmarking
2+
3+
This document describes the AWS S3 integration features added to the Base Benchmarking system.
4+
5+
## Overview
6+
7+
The benchmarking system now supports automatic upload of benchmark results to AWS S3, including:
8+
- Automatic upload after successful benchmark runs
9+
- Metadata synchronization with S3
10+
- Standalone export command for bulk uploads
11+
- Race condition handling for concurrent runs
12+
13+
## Configuration
14+
15+
### Environment Variables
16+
17+
Set the following environment variables or CLI flags:
18+
19+
```bash
20+
# Enable S3 upload
21+
export BASE_BENCH_ENABLE_S3=true
22+
23+
# Specify S3 bucket name (follows pattern: base-benchmarking-results-{env})
24+
export BASE_BENCH_S3_BUCKET=base-benchmarking-results-dev
25+
```
26+
27+
### AWS Credentials
28+
29+
Ensure AWS credentials are configured using one of the following methods:
30+
31+
1. **AWS Credentials File** - For development
32+
2. **Environment Variables**:
33+
```bash
34+
export AWS_ACCESS_KEY_ID=your-access-key
35+
export AWS_SECRET_ACCESS_KEY=your-secret-key
36+
export AWS_REGION=us-east-1
37+
```
38+
39+
## Usage
40+
41+
### 1. Running Benchmarks with S3 Upload
42+
43+
```bash
44+
# Run benchmarks with S3 upload enabled
45+
./bin/benchmark run \
46+
--config ./configs/your-config.yml \
47+
--output-dir ./output \
48+
--enable-s3 \
49+
--s3-bucket base-benchmarking-results-dev
50+
```
51+
52+
When `--enable-s3` is set and a bucket is specified:
53+
- Successful test runs are automatically uploaded to S3
54+
- Each run gets a unique S3 path: `{run-id}/`
55+
- The `metadata.json` is synchronized with S3 after each run
56+
- Run metadata includes the `bucketPath` field pointing to S3 location
57+
58+
### 2. Standalone Export Command
59+
60+
Export an entire output directory to S3:
61+
62+
```bash
63+
# Export existing output directory to S3
64+
./bin/benchmark export-to-cloud \
65+
--output-dir ./output \
66+
--s3-bucket base-benchmarking-results-dev
67+
```
68+
69+
This command:
70+
- Reads the local `metadata.json` file
71+
- Downloads existing S3 `metadata.json` (if any)
72+
- Uploads all run directories to S3
73+
- Merges and uploads the updated metadata
74+
75+
## S3 Structure
76+
77+
### Bucket Organization
78+
79+
```
80+
base-benchmarking-results-{env}/
81+
├── metadata.json # Root metadata file
82+
|-- test-1753974569311486/ # Run directory
83+
| |-- test-1753974569311486-0/ # Run directory
84+
| | |-- metrics-sequencer.json
85+
| | |-- metrics-validator.json
86+
| | |-- result-sequencer.json
87+
| | |-- result-validator.json
88+
| | |-- logs-sequencer.gz
89+
| | |-- logs-validator.gz
90+
| |-- test-1753974569311486-1/ # Another run directory
91+
| | |-- metrics-sequencer.json
92+
| | |-- metrics-validator.json
93+
| | |-- result-sequencer.json
94+
| | |-- result-validator.json
95+
| | |-- logs-sequencer.gz
96+
| | |-- logs-validator.gz
97+
| |-- ...
98+
|-- ...
99+
```
100+
101+
### Metadata Schema
102+
103+
The `metadata.json` file contains:
104+
105+
```json
106+
{
107+
"runs": [
108+
{
109+
"id": "test-1753974569311486",
110+
"sourceFile": "config.yml",
111+
"outputDir": "test-1753974569311486-0",
112+
"bucketPath": "test-1753974569311486-0/",
113+
"testName": "Basic Test",
114+
"testDescription": "Basic benchmarking test",
115+
"testConfig": {...},
116+
"result": {...},
117+
"thresholds": {...},
118+
"createdAt": "2024-01-15T10:30:00Z"
119+
}
120+
],
121+
"createdAt": "2024-01-15T10:30:00Z"
122+
}
123+
```
124+
125+
## Features
126+
127+
### Race Condition Handling
128+
129+
The system handles concurrent runs by:
130+
1. Downloading current S3 `metadata.json` before updates
131+
2. Merging new runs with existing metadata
132+
3. Uploading the combined metadata back to S3
133+
4. Using run IDs to prevent duplicates
134+
135+
### Error Handling
136+
137+
- S3 upload failures are logged as warnings and don't fail the benchmark
138+
- Missing S3 metadata is handled gracefully (creates new metadata)
139+
- Network issues are logged but don't interrupt benchmarking
140+
141+
### File Upload
142+
143+
- All files in the run output directory are uploaded
144+
- File paths are preserved relative to the run directory
145+
- Gzipped log files are supported
146+
- JSON result and metric files are uploaded
147+
148+
## IAM Permissions
149+
150+
Required S3 permissions for the benchmark system:
151+
152+
```json
153+
{
154+
"Version": "2012-10-17",
155+
"Statement": [
156+
{
157+
"Effect": "Allow",
158+
"Action": [
159+
"s3:ListBucket",
160+
"s3:GetObject",
161+
"s3:GetObjectVersion",
162+
"s3:PutObject",
163+
"s3:DeleteObject"
164+
],
165+
"Resource": [
166+
"arn:aws:s3:::base-benchmarking-results-*",
167+
"arn:aws:s3:::base-benchmarking-results-*/*"
168+
]
169+
}
170+
]
171+
}
172+
```
173+
174+
## Troubleshooting
175+
176+
### Common Issues
177+
178+
1. **AWS Credentials Not Found**
179+
- Ensure AWS credentials are properly configured
180+
- Check IAM permissions for S3 access
181+
182+
2. **Bucket Access Denied**
183+
- Verify bucket name is correct
184+
- Check IAM permissions include the specific bucket
185+
186+
3. **Network Issues**
187+
- S3 upload failures are logged but don't fail benchmarks
188+
- Check AWS service status and network connectivity
189+
190+
### Logs
191+
192+
S3 operations are logged with the following patterns:
193+
- `"Uploading test results to S3"` - Starting upload
194+
- `"Successfully uploaded test results to S3"` - Upload completed
195+
- `"Failed to upload test results to S3"` - Upload failed
196+
- `"Syncing metadata with S3"` - Metadata sync starting
197+
- `"Successfully synced metadata with S3"` - Sync completed
198+
199+
## Examples
200+
201+
### Basic Benchmark Run with S3
202+
203+
```bash
204+
./bin/benchmark run \
205+
--config ./configs/basic.yml \
206+
--output-dir ./output \
207+
--enable-s3 \
208+
--s3-bucket base-benchmarking-results-staging
209+
```
210+
211+
### Export Existing Results
212+
213+
```bash
214+
./bin/benchmark export-to-cloud \
215+
--output-dir ./historical-results \
216+
--s3-bucket base-benchmarking-results-prod
217+
```
218+
219+
### Environment Variable Configuration
220+
221+
```bash
222+
# Set environment variables
223+
export BASE_BENCH_ENABLE_S3=true
224+
export BASE_BENCH_S3_BUCKET=base-benchmarking-results-dev
225+
export BASE_BENCH_OUTPUT_DIR=./output
226+
227+
# Run without CLI flags
228+
./bin/benchmark run --config ./configs/basic.yml
229+
```

0 commit comments

Comments
 (0)