Skip to content

Commit 26ad2e4

Browse files
Performance testing and benchmarking (#298)
* Delete all * Create basic data 1 * Helpers * Only 10 hosts * Create jobs * Create job host summary * Create events * Create events partitions * Batch insert * Logs errors * Ruff * Arguments * Run_perf script * Run_perf script - save rollups and json * Ability to save plain csv rollup data * Mkdir * Templates * Add HostId into events * Fix job template name in jobs data * More modules * Run the whole perf test from one file * Git ignore out files and add modules * 3 commands * Random item names * Print elapsed time * Print memory * Ruff line too long * Rename folder * gitignore * collector performance testing * run uvx ruff check * rename run_collector_test.py * add job_finished --------- Co-authored-by: MilanPospisil <arkanus@seznam.cz>
1 parent 4290422 commit 26ad2e4

3 files changed

Lines changed: 536 additions & 11 deletions

File tree

tools/anonymized_db_perf_data/fill_perf_db_data.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,34 +112,34 @@ def fill_perf_db_data(host_count=10, job_count=5, task_count=50, template_count=
112112

113113

114114
def fill_job_data(init_data, job_index):
115-
"""Create a job using the init_data IDs. Returns (job_id, job_created)."""
115+
"""Create a job using the init_data IDs. Returns (job_id, job_created, job_finished)."""
116116
# Randomly select a job template
117117
templates = init_data['templates']
118118
template_id = random.choice(list(templates.keys()))
119119
template_name = templates[template_id]
120120

121-
job_id, job_created = create_job(
121+
job_id, job_created, job_finished = create_job(
122122
name=template_name, # Use template name as job name (AWX behavior)
123123
inventory_id=init_data['inventory_id'],
124124
project_id=init_data['project_id'],
125125
org_id=init_data['org_id'],
126126
job_index=job_index,
127127
job_template_id=template_id,
128128
)
129-
return job_id, job_created
129+
return job_id, job_created, job_finished
130130

131131

132-
def fill_jobhostsummary(init_data, job_id):
133-
create_job_host_summaries(job_id, init_data['host_count'], unique_suffix=init_data.get('unique_suffix'))
132+
def fill_jobhostsummary(init_data, job_id, job_created, job_finished):
133+
create_job_host_summaries(job_id, init_data['host_count'], job_created, job_finished, unique_suffix=init_data.get('unique_suffix'))
134134

135135

136136
def fill_jobevent(init_data, job_id, job_index, job_created):
137137
create_job_events(job_id, init_data['host_ids'], init_data['task_count'], job_index, job_created, unique_suffix=init_data.get('unique_suffix'))
138138

139139

140140
def fill_job(init_data, job_index):
141-
job_id, job_created = fill_job_data(init_data, job_index)
142-
fill_jobhostsummary(init_data, job_id)
141+
job_id, job_created, job_finished = fill_job_data(init_data, job_index)
142+
fill_jobhostsummary(init_data, job_id, job_created, job_finished)
143143
fill_jobevent(init_data, job_id, job_index, job_created)
144144
return
145145

tools/anonymized_db_perf_data/helpers.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,18 +459,20 @@ def create_job(name='Perf Test Job', inventory_id=None, project_id=None, org_id=
459459
run(sql_job)
460460
print(f'Created job {job_index}')
461461

462-
# Return job_id and created timestamp (needed for events)
463-
return job_id, created
462+
# Return job_id, created timestamp (needed for events), and finished timestamp (needed for job host summaries)
463+
return job_id, created, finished
464464

465465

466-
def create_job_host_summaries(job_id, host_count, unique_suffix=None):
466+
def create_job_host_summaries(job_id, host_count, job_created, job_finished, unique_suffix=None):
467467
"""Create job host summaries for all hosts (batch insert).
468468
469469
Host names are generated using the same pattern as create_hosts: host-{i}-{suffix}.example.com
470470
471471
Args:
472472
job_id: Job ID to link summaries to
473473
host_count: Number of host summaries to create
474+
job_created: Job creation timestamp to use for created date
475+
job_finished: Job finished timestamp to use for modified date (aligns with real AWX behavior)
474476
unique_suffix: Optional unique suffix for host names (must match create_hosts suffix)
475477
"""
476478
print(f'Creating {host_count} job host summaries for job {job_id}...')
@@ -491,7 +493,7 @@ def create_job_host_summaries(job_id, host_count, unique_suffix=None):
491493
failed = failures > 0 or dark > 0
492494

493495
values.append(
494-
f"(NOW(), NOW(), '{host_name}', {changed}, {dark}, {failures}, "
496+
f"('{job_created}', '{job_finished}', '{host_name}', {changed}, {dark}, {failures}, "
495497
f'{ok}, {processed}, {skipped}, {str(failed).upper()}, NULL, '
496498
f'{job_id}, {ignored}, {rescued})'
497499
)

0 commit comments

Comments
 (0)