Skip to content

Commit b515bca

Browse files
committed
Migrate hammerdb workload from benchmark-operator
Made-with: Cursor
1 parent 98c98b7 commit b515bca

File tree

355 files changed

+28437
-14584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

355 files changed

+28437
-14584
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,6 @@ terraform.tfstate
228228
# Emacs autosave and backup files
229229
*~
230230
**/#*#
231+
232+
# MacOS files
233+
**/.DS_Store

benchmark_runner/common/oc/oc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class OC(SSH):
2929
"""
3030

3131
SHORT_TIMEOUT = 600
32-
# sleep time between checks is 5 sec
32+
# sleep time between checks is 3 sec
3333
SLEEP_TIME = 3
3434
RETRIES = 10
3535
DELAY = 30

benchmark_runner/common/template_operations/template_operations.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ def __generate_yamls_internal(self, scale: str = None, scale_num: str = None, sc
118118
self.__standard_output_file = f"{'_'.join([self.__workload_name, self.__workload_template_kind, scale])}.yaml"
119119
else:
120120
self.__standard_output_file = f"{'_'.join([self.__workload_name, self.__workload_template_kind])}.yaml"
121-
self.__standard_template_file = f"{'_'.join([self.__workload_name, self.__workload_template_kind])}_template.yaml"
121+
if self.__workload_extra_name:
122+
self.__standard_template_file = f"{'_'.join([self.__workload_name, self.__workload_extra_name, self.__workload_template_kind])}_template.yaml"
123+
else:
124+
self.__standard_template_file = f"{'_'.join([self.__workload_name, self.__workload_template_kind])}_template.yaml"
122125
workload_dir_path = os.path.join((os.path.dirname(benchmark_runner.__file__)), "workloads", self.__workload, "template") \
123126
if self.__environment_variables_dict['template_in_workload_dir'] \
124127
else os.path.join(self.__dir_path, self.__workload_name)

benchmark_runner/common/template_operations/templates/hammerdb/hammerdb_data_template.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
metadata:
22
name: hammerdb
3-
{%- if kind != 'vm' %}
43
files:
5-
- name: "{{ workload_extra_name }}.yaml"
6-
{%- endif %}
4+
- name: "hammerdb_{{ kind }}_{{ workload_extra_name }}_configmap.yaml"
5+
template: "hammerdb_{{ workload_extra_name }}_configmap.yaml"
76
template_data:
87
shared:
9-
pin_node1: {{ pin_node1 }}
10-
pin_node2: {{ pin_node2 }}
8+
pin_node1: "{{ pin_node1 }}"
9+
pin_node2: "{{ pin_node2 }}"
1110
odf_pvc: {{ odf_pvc }}
12-
resources: true
1311
transactions: 100000
1412
rampup: 1
1513
runtime: 1
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Tcl benchmark params map to hammerdb_data_template.yaml:
2+
# db_warehouses, db_num_workers -> perf_ci (e.g. 96, 32) or default run_type
3+
# transactions, rampup, runtime -> shared section
4+
# K8s resources (storage, database_*cpu/memory, limits_*, requests_*) are in hammerdb_pod_template.yaml, not here.
5+
apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: hammerdb-mariadb-creator
9+
namespace: "{{ namespace }}"
10+
data:
11+
createdb_mariadb.tcl: |
12+
puts "SETTING CONFIGURATION"
13+
global complete
14+
proc wait_to_complete {} {
15+
global complete
16+
set complete [vucomplete]
17+
if {!$complete} { after 5000 wait_to_complete } else { exit }
18+
}
19+
puts "SETTING CONFIGURATION"
20+
dbset db mysql
21+
dbset bm TPC-C
22+
set mysql_host [expr {[info exists env(MYSQL_HOST)] ? $env(MYSQL_HOST) : "127.0.0.1"}]
23+
diset connection mysql_host $mysql_host
24+
diset connection mysql_port 3306
25+
if {[info exists env(MYSQL_SOCKET)] && $env(MYSQL_SOCKET) ne ""} {
26+
diset connection mysql_socket $env(MYSQL_SOCKET)
27+
}
28+
diset tpcc mysql_user root
29+
diset tpcc mysql_pass mysql
30+
diset tpcc mysql_dbase tpcc
31+
diset tpcc mysql_storage_engine innodb
32+
diset tpcc mysql_count_ware {{ db_warehouses }}
33+
diset tpcc mysql_num_vu {{ db_num_workers }}
34+
puts "CREATING SCHEMA"
35+
buildschema
36+
wait_to_complete
37+
vwait forever
38+
---
39+
apiVersion: v1
40+
kind: ConfigMap
41+
metadata:
42+
name: hammerdb-mariadb-workload
43+
namespace: "{{ namespace }}"
44+
data:
45+
workload_mariadb.tcl: |
46+
proc runtimer { seconds } {
47+
set x 0
48+
set timerstop 0
49+
while {!$timerstop} {
50+
incr x
51+
after 1000
52+
if { ![ expr {$x % 60} ] } {
53+
set y [ expr $x / 60 ]
54+
puts "Timer: $y minutes elapsed"
55+
}
56+
update
57+
if { [ vucomplete ] || $x eq $seconds } { set timerstop 1 }
58+
}
59+
return
60+
}
61+
puts "SETTING DB CONFIGURATION"
62+
dbset db mysql
63+
dbset bm TPC-C
64+
puts "SETTING CONNECTION OPTIONS"
65+
set mysql_host [expr {[info exists env(MYSQL_HOST)] ? $env(MYSQL_HOST) : "127.0.0.1"}]
66+
diset connection mysql_host $mysql_host
67+
diset connection mysql_port 3306
68+
if {[info exists env(MYSQL_SOCKET)] && $env(MYSQL_SOCKET) ne ""} {
69+
diset connection mysql_socket $env(MYSQL_SOCKET)
70+
}
71+
puts "SETTING BENCHMARK OPTIONS"
72+
diset tpcc mysql_count_ware {{ db_warehouses }}
73+
diset tpcc mysql_num_vu {{ db_num_workers }}
74+
diset tpcc mysql_user root
75+
diset tpcc mysql_pass mysql
76+
diset tpcc mysql_dbase tpcc
77+
diset tpcc mysql_storage_engine innodb
78+
diset tpcc mysql_partition false
79+
diset tpcc mysql_total_iterations {{ transactions }}
80+
diset tpcc mysql_raiseerror false
81+
diset tpcc mysql_keyandthink false
82+
diset tpcc mysql_driver timed
83+
diset tpcc mysql_rampup {{ rampup }}
84+
diset tpcc mysql_duration {{ runtime }}
85+
diset tpcc mysql_allwarehouse false
86+
diset tpcc mysql_timeprofile false
87+
diset tpcc mysql_async_scale false
88+
diset tpcc mysql_async_client 10
89+
diset tpcc mysql_async_verbose false
90+
diset tpcc mysql_async_delay 1000
91+
vuset logtotemp 1
92+
loadscript
93+
puts "SEQUENCE STARTED"
94+
set workers {{ db_num_workers }}
95+
set transactions {{ transactions }}
96+
set samples 1
97+
for {set w 1} { $w <= $workers } { set w [expr {$w*2}] } {
98+
puts "$w VU TEST"
99+
for {set i 1} {$i <= $samples} {incr i} {
100+
puts "============ RUNNING SAMPLE $i: $w WORKERS ============"
101+
vuset vu $w
102+
vucreate
103+
vurun
104+
set calculation [expr { ( {{ rampup }} + {{ runtime }} ) * 60 * 1.4 }]
105+
set runtimer_seconds [expr int($calculation)]
106+
runtimer $runtimer_seconds
107+
runtimer 350
108+
vudestroy
109+
after 5000
110+
}
111+
}
112+
puts "SEQUENCE COMPLETE"
113+
---
114+
apiVersion: v1
115+
kind: ConfigMap
116+
metadata:
117+
name: hammerdb-mariadb-results-parser
118+
namespace: "{{ namespace }}"
119+
data:
120+
parse_results.py: |
121+
import re, json
122+
results = []
123+
current_vu = 0
124+
with open('/tmp/hammerdb-workload.log') as f:
125+
for line in f:
126+
m = re.match(r'^(\d+) VU TEST', line)
127+
if m:
128+
current_vu = int(m.group(1))
129+
m = re.search(r'System achieved \d+ NOPM from (\d+) MySQL TPM', line)
130+
if m and current_vu:
131+
tpm = int(m.group(1))
132+
results.append({"current_worker": current_vu, "thread": current_vu, "tpm": tpm})
133+
output = json.dumps(results, indent=2)
134+
with open('/tmp/hammerdb-results.json', 'w') as f:
135+
f.write(output)
136+
print("=== JSON RESULTS ===")
137+
print(output)

benchmark_runner/common/template_operations/templates/hammerdb/internal_data/mariadb_template.yaml renamed to benchmark_runner/common/template_operations/templates/hammerdb/internal_data/hammerdb_mariadb_pod_template.yaml

Lines changed: 76 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
apiVersion: v1
2-
kind: Namespace
3-
metadata:
4-
name: mariadb-db
5-
---
6-
{%- if kind == 'kata' %}
7-
#This is a tweak of the restricted scc, to allow fsGroup to be specified in a deployment
8-
# workaround for kata virtiofsd permission error in ODF 4.10.5
9-
apiVersion: security.openshift.io/v1
10-
metadata:
11-
name: mariadbscc
12-
kind: SecurityContextConstraints
13-
fsGroup:
14-
type: RunAsAny
15-
runAsUser:
16-
type: MustRunAsRange
17-
seLinuxContext:
18-
type: MustRunAs
19-
users:
20-
- system:serviceaccount:mariadb-db:default
21-
---
22-
{%- endif %}
231
{%- if storage_type == 'lso' %}
242
apiVersion: local.storage.openshift.io/v1
253
kind: LocalVolume
@@ -42,12 +20,12 @@ spec:
4220
- /dev/disk/by-id/{{ lso_disk_id }}
4321
---
4422
{%- endif %}
45-
{%- if storage_type == 'lso' or odf_pvc == True %}
23+
{%- if storage_type == 'lso' or odf_pvc == True %}
4624
kind: PersistentVolumeClaim
4725
apiVersion: v1
4826
metadata:
4927
name: mariadb-persistent-storage
50-
namespace: mariadb-db
28+
namespace: benchmark-runner
5129
spec:
5230
{%- if storage_type == 'lso' %}
5331
storageClassName: local-sc
@@ -65,12 +43,9 @@ apiVersion: v1
6543
kind: ConfigMap
6644
metadata:
6745
name: mariadb-custom-config
68-
namespace: mariadb-db
46+
namespace: benchmark-runner
6947
data:
7048
custom.conf: |
71-
# This group is read both both by the client and the server
72-
# use it for options that affect everything
73-
#
7449
[client-server]
7550
!includedir /etc/my.cnf.d
7651
port=3306
@@ -81,7 +56,7 @@ data:
8156
max_allowed_packet = 200M
8257
table_open_cache = 400
8358
sort_buffer_size = 256K
84-
read_buffer_size = 16M # safer per-connection buffer
59+
read_buffer_size = 16M
8560
read_rnd_buffer_size = 256K
8661
net_buffer_length = 2K
8762
thread_stack = 256K
@@ -110,7 +85,7 @@ apiVersion: apps/v1
11085
kind: Deployment
11186
metadata:
11287
name: mariadb-deployment
113-
namespace: mariadb-db
88+
namespace: benchmark-runner
11489
spec:
11590
selector:
11691
matchLabels:
@@ -120,24 +95,15 @@ spec:
12095
labels:
12196
app: mariadb
12297
type: mariadb-database-server
123-
{%- if kind == 'kata' and kata_cpuoffline_workaround == True %}
124-
annotations:
125-
io.katacontainers.config.hypervisor.default_vcpus: "{{ database_limits_cpu }}"
126-
{%- endif %}
12798
spec:
99+
{%- if pin_node2 %}
128100
nodeSelector:
129101
kubernetes.io/hostname: "{{ pin_node2 }}"
130-
{%- if kind == 'kata' %}
131-
runtimeClassName: kata
132-
# workaround for kata virtiofsd permission error in ODF 4.10.5
133-
securityContext:
134-
fsGroup: 0
135102
{%- endif %}
136103
terminationGracePeriodSeconds: 10
137104
containers:
138105
- name: mariadb
139-
# quay.io/sclorg/mariadb-105-c9s:latest - rate limit issue
140-
image: quay.io/benchmark-runner/mariadb10.5-centos9:latest
106+
image: quay.io/benchmark-runner/mariadb:105-c9s
141107
imagePullPolicy: "IfNotPresent"
142108
ports:
143109
- containerPort: 3306
@@ -146,9 +112,7 @@ spec:
146112
cpu: {{ database_requests_cpu }}
147113
memory: {{ database_requests_memory }}
148114
limits:
149-
{%- if kind != 'kata' or kata_cpuoffline_workaround != True %}
150115
cpu: {{ database_limits_cpu }}
151-
{%- endif %}
152116
memory: {{ database_limits_memory }}
153117
env:
154118
- name: MYSQL_USER
@@ -160,7 +124,7 @@ spec:
160124
volumeMounts:
161125
- name: mariadb-custom-config
162126
mountPath: /etc/my.cnf
163-
subPath: custom.conf #should be the name used in the ConfigMap
127+
subPath: custom.conf
164128
{%- if storage_type == 'lso' or odf_pvc == True %}
165129
- name: mariadb-persistent-storage
166130
mountPath: /var/lib/mysql
@@ -180,11 +144,78 @@ apiVersion: v1
180144
kind: Service
181145
metadata:
182146
name: mariadb-deployment
183-
namespace: mariadb-db
147+
namespace: benchmark-runner
184148
spec:
185149
selector:
186150
app: mariadb
187151
ports:
188152
- protocol: TCP
189153
port: 3306
190154
targetPort: 3306
155+
---
156+
apiVersion: v1
157+
kind: Pod
158+
metadata:
159+
name: hammerdb-mariadb-pod-{{ trunc_uuid }}
160+
namespace: benchmark-runner
161+
labels:
162+
app: hammerdb-mariadb-pod-{{ trunc_uuid }}
163+
benchmark-uuid: {{ uuid }}
164+
spec:
165+
restartPolicy: Never
166+
{%- if pin_node1 %}
167+
nodeSelector:
168+
kubernetes.io/hostname: "{{ pin_node1 }}"
169+
{%- endif %}
170+
initContainers:
171+
- name: wait-for-mariadb
172+
image: quay.io/benchmark-runner/hammerdb-pod:centos10
173+
command: ["/bin/sh", "-c"]
174+
args:
175+
- until mysqladmin ping -h mariadb-deployment -P 3306 --silent 2>/dev/null; do echo "Waiting for MariaDB..."; sleep 3; done
176+
volumes:
177+
- name: hammerdb-creator
178+
configMap:
179+
name: hammerdb-mariadb-creator
180+
defaultMode: 0640
181+
- name: hammerdb-workload
182+
configMap:
183+
name: hammerdb-mariadb-workload
184+
defaultMode: 0640
185+
- name: hammerdb-mariadb-results-parser
186+
configMap:
187+
name: hammerdb-mariadb-results-parser
188+
defaultMode: 0640
189+
containers:
190+
- name: hammerdb
191+
image: quay.io/benchmark-runner/hammerdb-pod:centos10
192+
imagePullPolicy: Always
193+
env:
194+
- name: MYSQL_HOST
195+
value: "mariadb-deployment"
196+
command: ["/bin/sh", "-c"]
197+
args:
198+
- |
199+
cd /hammer
200+
echo "=== STEP 1: CREATE DB ==="
201+
./hammerdbcli auto /creator/createdb_mariadb.tcl 2>&1 | tee /tmp/hammerdb-createdb.log
202+
echo "=== STEP 2: RUN WORKLOAD ==="
203+
./hammerdbcli auto /workload/workload_mariadb.tcl 2>&1 | tee /tmp/hammerdb-workload.log
204+
python3 /parse-results/parse_results.py
205+
volumeMounts:
206+
- name: hammerdb-creator
207+
mountPath: /creator
208+
readOnly: false
209+
- name: hammerdb-workload
210+
mountPath: /workload
211+
readOnly: false
212+
- name: hammerdb-mariadb-results-parser
213+
mountPath: /parse-results
214+
readOnly: false
215+
resources:
216+
requests:
217+
cpu: "{{ requests_cpu }}"
218+
memory: "{{ requests_memory }}"
219+
limits:
220+
cpu: "{{ limits_cpu }}"
221+
memory: "{{ limits_memory }}"

0 commit comments

Comments
 (0)