Skip to content

Commit

Permalink
Bexhoma: Tests for pool component
Browse files Browse the repository at this point in the history
  • Loading branch information
perdelt committed Jan 7, 2025
1 parent 496c2f5 commit 45f386f
Show file tree
Hide file tree
Showing 5 changed files with 669 additions and 35 deletions.
40 changes: 33 additions & 7 deletions bexhoma/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,7 @@ def start_sut(self, app='', component='sut', experiment='', configuration=''):
storageConfiguration = configuration
#name_pvc = self.generate_component_name(app=app, component='storage', experiment=self.storage_label, configuration=configuration)
name_pvc = self.generate_component_name(app=app, component='storage', experiment=self.storage_label, configuration=storageConfiguration)
name_pool = self.generate_component_name(app=app, component='pool', experiment=experiment, configuration=configuration)
self.logger.debug('configuration.start_sut(name={})'.format(name))
deployments = self.experiment.cluster.get_deployments(app=app, component=component, experiment=experiment, configuration=configuration)
if len(deployments) > 0:
Expand All @@ -1086,6 +1087,7 @@ def start_sut(self, app='', component='sut', experiment='', configuration=''):
list_of_workers.append(worker_full_name)
list_of_workers_as_string = ",".join(list_of_workers)
env['BEXHOMA_WORKER_LIST'] = list_of_workers_as_string
env['BEXHOMA_SUT_NAME'] = name
if self.num_worker > 0:
worker_full_name = "{name_worker}-{worker_number}.{worker_service}".format(name_worker=name_worker, worker_number=0, worker_service=name_worker)
env['BEXHOMA_WORKER_FIRST'] = worker_full_name
Expand Down Expand Up @@ -1248,7 +1250,7 @@ def start_sut(self, app='', component='sut', experiment='', configuration=''):
for i_env,e in env.items():
dep['spec']['template']['spec']['containers'][i_container]['env'].append({'name':i_env, 'value':str(e)}) #print(pvc)
if dep['kind'] == 'Service':
if dep['metadata']['name'] != 'bexhoma-service':
if dep['metadata']['name'] == 'bexhoma-worker': #!= 'bexhoma-service':
if self.num_worker == 0:
del result[key]
continue
Expand All @@ -1272,6 +1274,22 @@ def start_sut(self, app='', component='sut', experiment='', configuration=''):
if 'name' in ports and ports['name'] != 'port-dbms':
del result[key]['spec']['ports'][i]
continue
if dep['metadata']['name'] == 'bexhoma-pool': #!= 'bexhoma-service':
dep['metadata']['name'] = name_pool
dep['metadata']['labels']['app'] = app
dep['metadata']['labels']['component'] = 'pool'
dep['metadata']['labels']['configuration'] = configuration
dep['metadata']['labels']['experiment'] = experiment
dep['metadata']['labels']['dbms'] = self.docker
dep['metadata']['labels']['volume'] = self.volume
for label_key, label_value in self.additional_labels.items():
dep['metadata']['labels'][label_key] = str(label_value)
#dep['spec']['selector'] = dep['metadata']['labels'].copy()
dep['spec']['selector']['configuration'] = configuration
dep['spec']['selector']['experiment'] = experiment
dep['spec']['selector']['dbms'] = self.docker
dep['spec']['selector']['volume'] = self.volume
continue
dep['metadata']['labels']['app'] = app
dep['metadata']['labels']['component'] = component
dep['metadata']['labels']['configuration'] = configuration
Expand All @@ -1294,25 +1312,32 @@ def start_sut(self, app='', component='sut', experiment='', configuration=''):
del result[key]['spec']['ports'][i]
#print(pvc)
if dep['kind'] == 'Deployment':
yaml_deployment = result[key]
dep['metadata']['name'] = name
if dep['metadata']['name'] == 'bexhoma-pool':
dep['metadata']['name'] = name_pool
dep['metadata']['labels']['component'] = 'pool'
else:
yaml_deployment = result[key] # this will be marked 'loaded' iff pvc exists
dep['metadata']['name'] = name
dep['metadata']['labels']['component'] = component
dep['metadata']['labels']['app'] = app
dep['metadata']['labels']['component'] = component
dep['metadata']['labels']['configuration'] = configuration
dep['metadata']['labels']['experiment'] = experiment
dep['metadata']['labels']['dbms'] = self.docker
dep['metadata']['labels']['volume'] = self.volume
dep['metadata']['labels']['sut'] = name
dep['metadata']['labels']['pool'] = name_pool
for label_key, label_value in self.additional_labels.items():
dep['metadata']['labels'][label_key] = str(label_value)
dep['metadata']['labels']['experimentRun'] = str(self.num_experiment_to_apply_done+1)
dep['spec']['selector']['matchLabels'] = dep['metadata']['labels'].copy()
dep['spec']['template']['metadata']['labels'] = dep['metadata']['labels'].copy()
deployment = dep['metadata']['name']
appname = dep['spec']['template']['metadata']['labels']['app']
self.sut_containers_deployed = []
self.worker_containers_deployed = []
if dep['metadata']['name'] != 'bexhoma-pool':
self.sut_containers_deployed = []
for i_container, container in reversed(list(enumerate(dep['spec']['template']['spec']['containers']))):
self.sut_containers_deployed.append(container['name'])
if dep['metadata']['name'] != name_pool:
self.sut_containers_deployed.append(container['name'])
self.logger.debug('configuration.create_manifest_deployment({})'.format(env))
if not 'env' in dep['spec']['template']['spec']['containers'][i_container]:
dep['spec']['template']['spec']['containers'][i_container]['env'] = []
Expand Down Expand Up @@ -1522,6 +1547,7 @@ def stop_sut(self, app='', component='sut', experiment='', configuration=''):
self.stop_loading()
if component == 'sut':
self.stop_sut(app=app, component='worker', experiment=experiment, configuration=configuration)
self.stop_sut(app=app, component='pool', experiment=experiment, configuration=configuration)
def get_host_gpus(self):
"""
Returns information about the sut's host GPUs.
Expand Down
97 changes: 70 additions & 27 deletions k8s/deploymenttemplate-PGBouncer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,62 +15,71 @@ apiVersion: v1
kind: Service
metadata:
labels: {app: bexhoma, component: sut, configuration: default, experiment: default}
name: bexhoma-service
name: bexhoma-sut
spec:
type: ClusterIP
clusterIP: None
ports:
- {port: 9091, protocol: TCP, name: port-dbms, targetPort: 5432}
- {port: 9300, protocol: TCP, name: port-monitoring, targetPort: 9300}
selector: {app: bexhoma, component: sut, configuration: default, experiment: default}
selector: {app: bexhoma, component: pool, configuration: default, experiment: default}
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels: {app: bexhoma, component: sut, configuration: default, experiment: default}
name: bexhoma-deployment-postgres
name: bexhoma-pool
labels: {app: bexhoma, component: pool, configuration: default, experiment: default}
spec:
replicas: 1
replicas: 3
selector:
matchLabels: {app: bexhoma, component: sut, configuration: default, experiment: default}
matchLabels: {app: bexhoma, component: pool, configuration: default, experiment: default}
template:
metadata:
labels: {app: bexhoma, component: sut, configuration: default, experiment: default}
labels: {app: bexhoma, component: pool, configuration: default, experiment: default}
spec:
automountServiceAccountToken: false
imagePullSecrets:
- {name: dockerhub}
nodeSelector:
tolerations:
#- key: "nvidia.com/gpu"
# effect: "NoSchedule"
terminationGracePeriodSeconds: 180
containers:
- name: pool
image: edoburu/pgbouncer
# connect via 'psql -U postgres -p 5432 -h localhost pgbouncer'
# SHOW STATS;
# SHOW POOLS;
# SHOW CLIENTS;
# SHOW SERVERS;
env: # https://github.com/edoburu/docker-pgbouncer/blob/master/entrypoint.sh
- name: DB_USER
value: postgres
- name: DB_PASSWORD
value: postgres
- name: DB_HOST
value: localhost
valueFrom:
fieldRef:
fieldPath: metadata.labels['pool']
#value: $(expr $BEXHOMA_SUT_NAME)
- name: DB_PORT
value: "5433"
value: "5432"
- name: AUTH_TYPE
value: scram-sha-256 # remove/comment this line if using postgres:13 and lower
value: md5 # scram-sha-256 # remove/comment this line if using postgres:13 and lower
- name: POOL_MODE
value: session # mode = transaction not working for YCSB
value: transaction # session # mode = transaction not working for YCSB
- name: ADMIN_USERS
value: postgres
#- name: POOL_SIZE
# value: "256"
- name: DEFAULT_POOL_SIZE
value: "256"
- name: MIN_POOL_SIZE
value: "32"
- name: MAX_CLIENT_CONN
value: "256"
#- name: RESERVE_POOL_SIZE
# value: "256"
- name: LOG_CONNECTIONS
value: "0"
- name: LOG_DISCONNECTIONS
value: "0"
- name: LOG_POOLER_ERRORS
value: "0"
- name: LOG_STATS
value: "0"
- name: RESERVE_POOL_SIZE
value: "16"
- name: MAX_PREPARED_STATEMENTS
value: "256"
#readinessProbe:
# exec:
# command:
Expand All @@ -85,6 +94,40 @@ spec:
limits: {cpu: 16000m, memory: 128Gi}
requests: {cpu: 4000m, memory: 4Gi}
#, ephemeral-storage: "1536Gi"}
---
apiVersion: v1
kind: Service
metadata:
labels: {app: bexhoma, component: pool, configuration: default, experiment: default}
name: bexhoma-pool
spec:
ports:
- {port: 5432, protocol: TCP, name: port-dbms, targetPort: 5432}
- {port: 9300, protocol: TCP, name: port-monitoring, targetPort: 9300}
selector: {app: bexhoma, component: sut, configuration: default, experiment: default}
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels: {app: bexhoma, component: sut, configuration: default, experiment: default}
name: bexhoma-deployment-postgres
spec:
replicas: 1
selector:
matchLabels: {app: bexhoma, component: sut, configuration: default, experiment: default}
template:
metadata:
labels: {app: bexhoma, component: sut, configuration: default, experiment: default}
spec:
automountServiceAccountToken: false
imagePullSecrets:
- {name: dockerhub}
nodeSelector:
tolerations:
#- key: "nvidia.com/gpu"
# effect: "NoSchedule"
terminationGracePeriodSeconds: 180
containers:
- name: dbms
image: postgres:16.1
env:
Expand All @@ -93,7 +136,7 @@ spec:
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
- name: PGPORT
value: "5433" # remove/comment this line for default ports
value: "5432" # remove/comment this line for default ports
# pg_ctl: cannot be run as root
lifecycle:
#postStart:
Expand Down Expand Up @@ -121,11 +164,11 @@ spec:
- -U
- postgres
- -p
- "5433"
- "5432"
initialDelaySeconds: 15
periodSeconds: 60
ports:
- {containerPort: 5433}
- {containerPort: 5432}
securityContext:
allowPrivilegeEscalation: false
#runAsNonRoot: true
Expand Down
Loading

0 comments on commit 45f386f

Please sign in to comment.