-
Notifications
You must be signed in to change notification settings - Fork 884
153 lines (129 loc) · 5.02 KB
/
benchmark.yml
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
name: benchmark-tests
on:
schedule:
- cron: "0 9 * * *" # run at 6 AM UTC
workflow_dispatch:
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-weekly: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
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 Benchmark
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: 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