forked from dragonflydb/dragonfly
-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (168 loc) · 6.87 KB
/
benchmark.yml
File metadata and controls
198 lines (168 loc) · 6.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: benchmark-tests
on:
schedule:
- cron: "0 9 * * *" # run at 6 AM UTC
workflow_dispatch:
permissions:
contents: read
jobs:
benchmark:
strategy:
matrix:
config:
- operator:
apiVersion: "dragonflydb.io/v1alpha1"
kind: "Dragonfly"
metadata:
labels:
app.kubernetes.io/name: "dragonfly"
app.kubernetes.io/instance: "dragonfly-sample"
app.kubernetes.io/part-of: "dragonfly-operator"
app.kubernetes.io/managed-by: "kustomize"
app.kubernetes.io/created-by: "dragonfly-operator"
name: "dragonfly-sample"
spec:
image: "ghcr.io/dragonflydb/dragonfly:latest"
args: ["--cache_mode"]
replicas: 2
resources:
requests:
cpu: "2"
memory: "2000Mi"
limits:
cpu: "2"
memory: "2000Mi"
runs-on: ubuntu-latest
container:
image: ghcr.io/romange/benchmark-dev:latest
options: --security-opt seccomp=unconfined
permissions:
id-token: write
steps:
- name: Setup namespace name
id: setup
run: echo "namespace=benchmark-$(date +"%Y-%m-%d-%s")" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
submodules: true
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ vars.AWS_REGION }}
- name: Update kube config
run: aws eks update-kubeconfig --name "$EKS_CLUSTER_NAME" --region "$AWS_REGION"
env:
AWS_REGION: ${{ vars.AWS_REGION }}
EKS_CLUSTER_NAME: dev
- name: Scale up
run: |
set -x
aws autoscaling set-desired-capacity --auto-scaling-group-name "$AUTOSCALING_GROUP" --desired-capacity "$DESIRED_CAPACITY"
env:
AUTOSCALING_GROUP: ${{ vars.DEV_EKS_AS_GROUP }}
DESIRED_CAPACITY: 1
- name: Install the CRD and Operator
run: |
# Install the CRD and Operator
kubectl apply -f https://raw.githubusercontent.com/dragonflydb/dragonfly-operator/main/manifests/dragonfly-operator.yaml
- name: Apply Configuration
run: |
set -x
kubectl create namespace ${{ steps.setup.outputs.namespace }} || true
echo '${{ toJson(matrix.config.operator) }}' | kubectl apply -n ${{ steps.setup.outputs.namespace }} -f -
- name: Wait For Service
run: |
set -x
kubectl wait -n ${{ steps.setup.outputs.namespace }} dragonfly/dragonfly-sample --for=jsonpath='{.status.phase}'=ready --timeout=180s
kubectl wait -n ${{ steps.setup.outputs.namespace }} pods --selector app=dragonfly-sample --for condition=Ready --timeout=120s
kubectl describe -n ${{ steps.setup.outputs.namespace }} pod dragonfly-sample-0
- name: Run Memtier Benchmark
shell: bash
run: |
kubectl apply -n ${{ steps.setup.outputs.namespace }} -f tools/benchmark/k8s-benchmark-job.yaml
- name: Version upgrade
shell: bash
run: |
# benchmark is running, wait for 30 seconds before version upgrade
sleep 30
kubectl patch dragonfly dragonfly-sample -n ${{ steps.setup.outputs.namespace }} --type merge -p '{"spec":{"image":"ghcr.io/dragonflydb/dragonfly-weekly:latest"}}'
- name: Wait for Memtier Benchmark fail
shell: bash
run: |
# Memtier benchmark run will fail at some point because old master shutdown on version upgrade
kubectl wait --for=condition=failed --timeout=120s -n ${{ steps.setup.outputs.namespace }} jobs/memtier-benchmark 2>/dev/null
kubectl logs -n ${{ steps.setup.outputs.namespace }} -f jobs/memtier-benchmark
kubectl delete -n ${{ steps.setup.outputs.namespace }} jobs/memtier-benchmark
- name: Run Memtier Benchmark again
shell: bash
run: |
kubectl apply -n ${{ steps.setup.outputs.namespace }} -f tools/benchmark/k8s-benchmark-job.yaml
while true; do
if kubectl wait --for=condition=complete --timeout=0 -n ${{ steps.setup.outputs.namespace }} jobs/memtier-benchmark 2>/dev/null; then
job_result=0
break
fi
if kubectl wait --for=condition=failed --timeout=0 -n ${{ steps.setup.outputs.namespace }} jobs/memtier-benchmark 2>/dev/null; then
job_result=1
break
fi
sleep 3
done
kubectl logs -n ${{ steps.setup.outputs.namespace }} -f jobs/memtier-benchmark
if [[ $job_result -eq 1 ]]; then
exit 1
fi
- name: Server checks
run: |
nohup kubectl port-forward -n ${{ steps.setup.outputs.namespace }} service/dragonfly-sample 6379:6379 &
pip install -r tools/requirements.txt
python3 tools/benchmark/post_run_checks.py
- name: Get Dragonfly logs
uses: nick-fields/retry@v3
if: always()
with:
timeout_minutes: 1
max_attempts: 3
command: |
kubectl logs -n ${{ steps.setup.outputs.namespace }} dragonfly-sample-0
- name: Get Dragonfly replica logs
uses: nick-fields/retry@v3
if: always()
with:
timeout_minutes: 1
max_attempts: 3
command: |
kubectl logs -n ${{ steps.setup.outputs.namespace }} dragonfly-sample-1
- name: Describe dragonflydb object
uses: nick-fields/retry@v3
if: always()
with:
timeout_minutes: 1
max_attempts: 3
command: |
kubectl describe dragonflies.dragonflydb.io -n ${{ steps.setup.outputs.namespace }} dragonfly-sample
- name: Scale down to zero
if: always()
run: |
set -x
aws autoscaling set-desired-capacity --auto-scaling-group-name "$AUTOSCALING_GROUP" --desired-capacity 0
env:
AUTOSCALING_GROUP: ${{ vars.DEV_EKS_AS_GROUP }}
- name: Cleanup
if: always()
run: |
set -x
kubectl delete namespace ${{ steps.setup.outputs.namespace }}
kubectl delete namespace dragonfly-operator-system
- name: Send notification on failure
if: failure() && github.ref == 'refs/heads/main'
shell: bash
run: |
job_link="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
message="Benchmark tests failed.\\n Job Link: ${job_link}\\n"
curl -s \
-X POST \
-H 'Content-Type: application/json' \
'${{ secrets.GSPACES_BOT_DF_BUILD }}' \
-d '{"text": "'"${message}"'"}'