Skip to content

Commit

Permalink
abstract logic to list test executions + aggregated results
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Oviedo <[email protected]>
  • Loading branch information
OVI3D0 committed Oct 24, 2024
1 parent 43a9cc5 commit 41c7f18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 43 deletions.
2 changes: 1 addition & 1 deletion osbenchmark/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ def dispatch_list(cfg):
elif what == "test_executions":
metrics.list_test_executions(cfg)
elif what == "aggregated_results":
metrics.list_aggregated_test_results(cfg)
metrics.list_aggregated_results(cfg)
elif what == "provision_config_instances":
provision_config.list_provision_config_instances(cfg)
elif what == "opensearch-plugins":
Expand Down
50 changes: 8 additions & 42 deletions osbenchmark/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ def results_store(cfg):
return NoopResultsStore()


def list_test_executions(cfg):
def list_test_helper(store, title):
def format_dict(d):
if d:
items = sorted(d.items())
Expand All @@ -1284,7 +1284,7 @@ def format_dict(d):
return None

test_executions = []
for test_execution in test_execution_store(cfg).list():
for test_execution in store:
test_executions.append([
test_execution.test_execution_id,
time.to_iso8601(test_execution.test_execution_timestamp),
Expand All @@ -1297,7 +1297,7 @@ def format_dict(d):
test_execution.provision_config_revision])

if len(test_executions) > 0:
console.println("\nRecent test_executions:\n")
console.println(f"\nRecent {title}:\n")
console.println(tabulate.tabulate(
test_executions,
headers=[
Expand All @@ -1313,47 +1313,13 @@ def format_dict(d):
]))
else:
console.println("")
console.println("No recent test_executions found.")

def list_aggregated_test_results(cfg):
def format_dict(d):
if d:
items = sorted(d.items())
return ", ".join(["%s=%s" % (k, v) for k, v in items])
else:
return None
console.println(f"No recent {title} found.")

aggregated_test_executions = []
for test_execution in test_execution_store(cfg).list_aggregations():
aggregated_test_executions.append([
test_execution.test_execution_id,
time.to_iso8601(test_execution.test_execution_timestamp),
test_execution.workload,
format_dict(test_execution.workload_params),
test_execution.test_procedure_name,
test_execution.provision_config_instance_name,
format_dict(test_execution.user_tags),
test_execution.workload_revision,
test_execution.provision_config_revision])
def list_test_executions(cfg):
list_test_helper(test_execution_store(cfg).list(), "test_executions")

if len(aggregated_test_executions) > 0:
console.println("\nRecent aggregated test executions:\n")
console.println(tabulate.tabulate(
aggregated_test_executions,
headers=[
"TestExecution ID",
"TestExecution Timestamp",
"Workload",
"Workload Parameters",
"TestProcedure",
"ProvisionConfigInstance",
"User Tags",
"workload Revision",
"Provision Config Revision"
]))
else:
console.println("")
console.println("No recent aggregate tests found.")
def list_aggregated_results(cfg):
list_test_helper(test_execution_store(cfg).list_aggregations(), "aggregated_results")

def create_test_execution(cfg, workload, test_procedure, workload_revision=None):
provision_config_instance = cfg.opts("builder", "provision_config_instance.names")
Expand Down

0 comments on commit 41c7f18

Please sign in to comment.