Skip to content

Commit 6298396

Browse files
authored
Added SLO workflow (#574)
1 parent 9e4d583 commit 6298396

File tree

5 files changed

+310
-28
lines changed

5 files changed

+310
-28
lines changed

.github/workflows/slo.yml

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
name: SLO
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
inputs:
10+
github_issue:
11+
description: "GitHub issue number where the SLO results will be reported"
12+
required: true
13+
baseline_ref:
14+
description: "Baseline commit/branch/tag to compare against (leave empty to auto-detect merge-base with main)"
15+
required: false
16+
slo_workload_duration_seconds:
17+
description: "Duration of the SLO workload in seconds"
18+
required: false
19+
default: "600"
20+
slo_workload_read_max_rps:
21+
description: "Maximum read RPS for the SLO workload"
22+
required: false
23+
default: "1000"
24+
slo_workload_write_max_rps:
25+
description: "Maximum write RPS for the SLO workload"
26+
required: false
27+
default: "100"
28+
29+
jobs:
30+
ydb-slo-action:
31+
name: Run YDB SLO Tests
32+
runs-on: ubuntu-latest
33+
34+
strategy:
35+
matrix:
36+
include:
37+
- workload: table
38+
39+
concurrency:
40+
group: slo-${{ github.ref }}
41+
cancel-in-progress: true
42+
43+
steps:
44+
- name: Install dependencies
45+
run: |
46+
YQ_VERSION=v4.48.2
47+
BUILDX_VERSION=0.30.1
48+
COMPOSE_VERSION=2.40.3
49+
50+
sudo curl -L https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -o /usr/local/bin/yq && \
51+
sudo chmod +x /usr/local/bin/yq
52+
53+
echo "Updating Docker plugins..."
54+
sudo mkdir -p /usr/local/lib/docker/cli-plugins
55+
56+
echo "Installing Docker Buildx ${BUILDX_VERSION}..."
57+
sudo curl -fLo /usr/local/lib/docker/cli-plugins/docker-buildx \
58+
"https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-amd64"
59+
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx
60+
61+
echo "Installing Docker Compose ${COMPOSE_VERSION}..."
62+
sudo curl -fLo /usr/local/lib/docker/cli-plugins/docker-compose \
63+
"https://github.com/docker/compose/releases/download/v${COMPOSE_VERSION}/docker-compose-linux-x86_64"
64+
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
65+
66+
echo "Installed versions:"
67+
yq --version
68+
docker --version
69+
docker buildx version
70+
docker compose version
71+
72+
- name: Checkout current version
73+
uses: actions/checkout@v5
74+
with:
75+
path: current
76+
fetch-depth: 0
77+
submodules: true
78+
79+
- name: Determine baseline commit
80+
id: baseline
81+
run: |
82+
cd current
83+
if [[ -n "${{ inputs.baseline_ref }}" ]]; then
84+
BASELINE="${{ inputs.baseline_ref }}"
85+
else
86+
BASELINE=$(git merge-base HEAD origin/main)
87+
fi
88+
echo "sha=$BASELINE" >> $GITHUB_OUTPUT
89+
90+
# Try to determine a human-readable ref name for baseline
91+
# Check if baseline is on main
92+
if git merge-base --is-ancestor $BASELINE origin/main && \
93+
[ "$(git rev-parse origin/main)" = "$BASELINE" ]; then
94+
BASELINE_REF="main"
95+
else
96+
# Try to find a branch containing this commit
97+
BRANCH=$(git branch -r --contains $BASELINE | grep -v HEAD | head -1 | sed 's/.*\///' || echo "")
98+
if [ -n "$BRANCH" ]; then
99+
BASELINE_REF="${BRANCH}@${BASELINE:0:7}"
100+
else
101+
BASELINE_REF="${BASELINE:0:7}"
102+
fi
103+
fi
104+
echo "ref=$BASELINE_REF" >> $GITHUB_OUTPUT
105+
106+
- name: Checkout baseline version
107+
uses: actions/checkout@v5
108+
with:
109+
ref: ${{ steps.baseline.outputs.sha }}
110+
path: baseline
111+
fetch-depth: 1
112+
submodules: true
113+
114+
- name: Build Workload Image
115+
run: |
116+
echo "Cleaning up Docker system before builds..."
117+
docker system prune -af --volumes
118+
docker builder prune -af
119+
df -h
120+
121+
# Build current version
122+
if [ -f "$GITHUB_WORKSPACE/current/tests/slo_workloads/Dockerfile" ]; then
123+
echo "Building current app image..."
124+
cd "$GITHUB_WORKSPACE/current"
125+
126+
# Use SLO-specific .dockerignore
127+
cp tests/slo_workloads/.dockerignore .dockerignore
128+
129+
docker build -t ydb-app-current \
130+
--build-arg REF="${{ github.head_ref || github.ref_name }}" \
131+
-f tests/slo_workloads/Dockerfile .
132+
133+
# Clean up .dockerignore
134+
rm -f .dockerignore
135+
else
136+
echo "No current app Dockerfile found"
137+
exit 1
138+
fi
139+
140+
docker system prune -f --volumes
141+
docker builder prune -af
142+
143+
# Build baseline version
144+
if [ -f "$GITHUB_WORKSPACE/baseline/tests/slo_workloads/Dockerfile" ]; then
145+
echo "Building baseline app image..."
146+
cd "$GITHUB_WORKSPACE/baseline"
147+
148+
# Use SLO-specific .dockerignore
149+
cp tests/slo_workloads/.dockerignore .dockerignore
150+
151+
docker build -t ydb-app-baseline \
152+
--build-arg REF="${{ steps.baseline.outputs.ref }}" \
153+
-f tests/slo_workloads/Dockerfile .
154+
155+
# Clean up .dockerignore
156+
rm -f .dockerignore
157+
else
158+
echo "No baseline app Dockerfile found"
159+
exit 1
160+
fi
161+
162+
docker system prune -f --volumes
163+
docker builder prune -af
164+
165+
echo "Final disk space after builds:"
166+
df -h
167+
168+
- name: Initialize YDB SLO
169+
uses: ydb-platform/ydb-slo-action/init@main
170+
with:
171+
github_issue: ${{ github.event.inputs.github_issue }}
172+
github_token: ${{ secrets.GITHUB_TOKEN }}
173+
workload_name: ${{ matrix.workload }}
174+
workload_current_ref: ${{ github.head_ref || github.ref_name }}
175+
workload_baseline_ref: ${{ steps.baseline.outputs.ref }}
176+
177+
- name: Prepare SLO Database
178+
run: |
179+
echo "Preparing SLO database..."
180+
docker run --rm --network ydb_ydb-net \
181+
--add-host "ydb:172.28.0.11" \
182+
--add-host "ydb:172.28.0.12" \
183+
--add-host "ydb:172.28.0.13" \
184+
--add-host "ydb:172.28.0.99" \
185+
ydb-app-current --connection-string grpc://ydb:2136/?database=/Root/testdb create --dont-push
186+
187+
- name: Run SLO Tests (parallel)
188+
timeout-minutes: 15
189+
run: |
190+
DURATION=${{ inputs.slo_workload_duration_seconds || 600 }}
191+
READ_RPS=${{ inputs.slo_workload_read_max_rps || 1000 }}
192+
WRITE_RPS=${{ inputs.slo_workload_write_max_rps || 100 }}
193+
194+
ARGS="--connection-string grpc://ydb:2136/?database=/Root/testdb run \
195+
--metrics-push-url http://prometheus:9090/api/v1/otlp/v1/metrics \
196+
--time $DURATION \
197+
--read-rps $READ_RPS \
198+
--write-rps $WRITE_RPS \
199+
--read-timeout 100 \
200+
--write-timeout 100"
201+
202+
echo "Starting ydb-app-current..."
203+
docker run -d \
204+
--name ydb-app-current \
205+
--network ydb_ydb-net \
206+
--add-host "ydb:172.28.0.11" \
207+
--add-host "ydb:172.28.0.12" \
208+
--add-host "ydb:172.28.0.13" \
209+
--add-host "ydb:172.28.0.99" \
210+
ydb-app-current $ARGS
211+
212+
echo "Starting ydb-app-baseline..."
213+
docker run -d \
214+
--name ydb-app-baseline \
215+
--network ydb_ydb-net \
216+
--add-host "ydb:172.28.0.11" \
217+
--add-host "ydb:172.28.0.12" \
218+
--add-host "ydb:172.28.0.13" \
219+
--add-host "ydb:172.28.0.99" \
220+
ydb-app-baseline $ARGS
221+
222+
# Show initial logs
223+
echo ""
224+
echo "==================== INITIAL CURRENT LOGS ===================="
225+
docker logs -n 15 ydb-app-current 2>&1 || echo "No current container"
226+
echo ""
227+
echo "==================== INITIAL BASELINE LOGS ===================="
228+
docker logs -n 15 ydb-app-baseline 2>&1 || echo "No baseline container"
229+
echo ""
230+
231+
# Wait for workloads to complete
232+
echo "Waiting for workloads to complete (${DURATION}s)..."
233+
sleep ${DURATION}
234+
235+
# Stop containers after workload duration and wait for graceful shutdown
236+
echo "Stopping containers after ${DURATION}s..."
237+
docker stop --timeout=30 ydb-app-current ydb-app-baseline 2>&1 || true
238+
239+
# Force kill if still running
240+
docker kill ydb-app-current ydb-app-baseline 2>&1 || true
241+
242+
# Check exit codes
243+
CURRENT_EXIT=$(docker inspect ydb-app-current --format='{{.State.ExitCode}}' 2>/dev/null || echo "1")
244+
BASELINE_EXIT=$(docker inspect ydb-app-baseline --format='{{.State.ExitCode}}' 2>/dev/null || echo "0")
245+
246+
echo "Current container exit code: $CURRENT_EXIT"
247+
echo "Baseline container exit code: $BASELINE_EXIT"
248+
249+
# Show final logs
250+
echo ""
251+
echo "==================== FINAL CURRENT LOGS ===================="
252+
docker logs -n 15 ydb-app-current 2>&1 || echo "No current container"
253+
echo ""
254+
echo "==================== FINAL BASELINE LOGS ===================="
255+
docker logs -n 15 ydb-app-baseline 2>&1 || echo "No baseline container"
256+
echo ""
257+
258+
echo "SUCCESS: Workloads completed successfully"
259+
260+
- if: always()
261+
name: Store logs
262+
run: |
263+
docker logs ydb-app-current > current.log 2>&1 || echo "No current container"
264+
docker logs ydb-app-baseline > baseline.log 2>&1 || echo "No baseline container"
265+
266+
- if: always()
267+
uses: actions/upload-artifact@v4
268+
with:
269+
name: ${{matrix.workload}}-slo-cpp-sdk-logs
270+
path: |
271+
./current.log
272+
./baseline.log
273+
retention-days: 1

.github/workflows/slo_report.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: SLO Report
2+
3+
on:
4+
workflow_run:
5+
workflows: ["SLO CPP SDK"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
ydb-slo-action-report:
11+
runs-on: ubuntu-latest
12+
name: Publish YDB SLO Report
13+
permissions:
14+
checks: write
15+
contents: read
16+
pull-requests: write
17+
if: github.event.workflow_run.conclusion == 'success'
18+
steps:
19+
- name: Publish YDB SLO Report
20+
uses: ydb-platform/ydb-slo-action/report@main
21+
with:
22+
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
github_run_id: ${{ github.event.workflow_run.id }}

tests/slo_workloads/.dockerignore

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
.gitattributes
66

77
# IDE and editor files
8-
.vscode
9-
.idea
8+
.idea/
9+
.vscode/
10+
.cache/
11+
.cursor/
12+
.cursorrules
1013
*.swp
1114
*.swo
12-
*~
1315
.DS_Store
16+
*.dSYM
17+
.clangd
18+
compile_commands.json
1419

1520
# Build artifacts and cache
1621
*.o
@@ -29,39 +34,15 @@ node_modules/
2934
# Documentation
3035
*.md
3136
docs/
32-
*.txt
3337
!requirements.txt
3438

3539
# CI/CD
3640
.circleci
3741
.travis.yml
3842
azure-pipelines.yml
3943

40-
# Test files
41-
*_test.cpp
42-
*_test.py
43-
*_ut.cpp
44-
test_*
45-
tests/
46-
!ydb/public/sdk/cpp/tests/slo_workloads/
47-
4844
# Large directories not needed for SDK builds
4945
ydb/core/
5046
ydb/apps/
5147
ydb/services/
5248
ydb/tools/
53-
54-
# Keep only what's needed (specified in Dockerfile COPY commands):
55-
# - build/
56-
# - certs/
57-
# - contrib/
58-
# - library/cpp/
59-
# - tools/
60-
# - util/
61-
# - ydb/library/yverify_stream/
62-
# - ydb/public/api/
63-
# - ydb/public/lib/protobuf/
64-
# - ydb/public/lib/validation/
65-
# - ydb/public/sdk/cpp/
66-
# - ya
67-

tests/slo_workloads/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM ubuntu:22.04
22

33
ARG PRESET=release-test-clang
4+
ARG REF=unknown
45

56
# Install software-properties-common for add-apt-repository
67
RUN apt-get -y update && apt-get -y install software-properties-common && add-apt-repository ppa:ubuntu-toolchain-r/test
@@ -119,7 +120,7 @@ COPY . /ydb-cpp-sdk
119120
WORKDIR /ydb-cpp-sdk
120121
RUN rm -rf build
121122

122-
RUN cmake --preset ${PRESET}
123+
RUN ls -la && cmake -DSLO_BRANCH_REF=${REF} --preset ${PRESET}
123124
RUN cmake --build --preset default --target slo-key-value
124125

125126
ENTRYPOINT ["./build/tests/slo_workloads/key_value/slo-key-value"]

tests/slo_workloads/utils/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ target_link_libraries(slo-utils PUBLIC
99
opentelemetry-cpp::otlp_http_metric_exporter
1010
)
1111

12+
if (SLO_BRANCH_REF)
13+
target_compile_definitions(slo-utils PRIVATE REF="${SLO_BRANCH_REF}")
14+
endif()
15+
1216
target_sources(slo-utils PRIVATE
1317
executor.cpp
1418
generator.cpp

0 commit comments

Comments
 (0)