Skip to content

Commit

Permalink
added generic indexes, daemon mode opinionated, and version as param
Browse files Browse the repository at this point in the history
Signed-off-by: Shashank Reddy Boyapally <[email protected]>
  • Loading branch information
shashank-boyapally committed Apr 9, 2024
1 parent 5087863 commit e1ca7c3
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 22 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Below is an illustrative example of the config and metadata that Orion can handl
```
tests :
- name : aws-small-scale-cluster-density-v2
index: ospst-perf-scale-ci-*
metadata:
platform: AWS
masterNodesType: m6a.xlarge
Expand Down
48 changes: 48 additions & 0 deletions configs/small-scale-cluster-density.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
tests :
- name : aws-small-scale-cluster-density-v2
index: ospst-perf-scale-ci-*
metadata:
platform: AWS
masterNodesType: m6a.xlarge
masterNodesCount: 3
workerNodesType: m6a.xlarge
workerNodesCount: 24
benchmark.keyword: cluster-density-v2
ocpVersion: {{ version }}
networkType: OVNKubernetes
# encrypted: true
# fips: false
# ipsec: false

metrics :
- name: podReadyLatency
metricName: podLatencyQuantilesMeasurement
quantileName: Ready
metric_of_interest: P99
not:
jobConfig.name: "garbage-collection"

- name: apiserverCPU
metricName : containerCPU
labels.namespace.keyword: openshift-kube-apiserver
metric_of_interest: value
agg:
value: cpu
agg_type: avg

- name: ovnCPU
metricName : containerCPU
labels.namespace.keyword: openshift-ovn-kubernetes
metric_of_interest: value
agg:
value: cpu
agg_type: avg

- name: etcdCPU
metricName : containerCPU
labels.namespace.keyword: openshift-etcd
metric_of_interest: value
agg:
value: cpu
agg_type: avg

1 change: 1 addition & 0 deletions examples/small-scale-cluster-density.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
tests :
- name : aws-small-scale-cluster-density-v2
index: ospst-perf-scale-ci-*
metadata:
platform: AWS
masterNodesType: m6a.xlarge
Expand Down
1 change: 1 addition & 0 deletions examples/small-scale-node-density-cni.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
tests :
- name : aws-small-scale-node-density-cni
index: ospst-perf-scale-ci-*
metadata:
platform: AWS
masterNodesType: m6a.xlarge
Expand Down
7 changes: 6 additions & 1 deletion orion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
# pylint: disable = import-error
import logging
import sys
import warnings
import click
import uvicorn
from pkg.logrus import SingletonLogger
from pkg.runTest import run
from pkg.utils import load_config

warnings.filterwarnings("ignore", message="Unverified HTTPS request.*")



Expand All @@ -26,7 +30,7 @@ def cli(max_content_width=120): # pylint: disable=unused-argument
"--output-path", default="output.csv", help="Path to save the output csv file"
)
@click.option("--debug", default=False, is_flag=True, help="log level")
@click.option("--hunter-analyze", default=True, is_flag=True, help="run hunter analyze")
@click.option("--hunter-analyze", is_flag=True, help="run hunter analyze")
@click.option(
"-o",
"--output-format",
Expand All @@ -52,6 +56,7 @@ def cmd_analysis(**kwargs):
level = logging.DEBUG if kwargs['debug'] else logging.INFO
logger_instance = SingletonLogger(debug=level).logger
logger_instance.info("🏹 Starting Orion in command-line mode")
kwargs['configMap']=load_config(kwargs["config"])
output = run(**kwargs)
for test_name, result_table in output.items():
print(test_name)
Expand Down
40 changes: 27 additions & 13 deletions pkg/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"""

import logging
import shutil
import os

from fastapi import FastAPI, File, UploadFile
from fastapi import FastAPI
from jinja2 import Template
import yaml
from pkg.logrus import SingletonLogger

from . import runTest
Expand All @@ -17,7 +17,7 @@

@app.post("/daemon")
async def daemon(
file: UploadFile = File(...),
version: str = "4.15",
uuid: str = "",
baseline: str = "",
filter_changepoints="",
Expand All @@ -30,17 +30,18 @@ async def daemon(
Returns:
json: json object of the changepoints and metrics
"""
file_name, file_extension = os.path.splitext(file.filename)
new_file_name = f"{file_name}_copy{file_extension}"
with open(new_file_name, "wb") as buffer:
shutil.copyfileobj(file.file, buffer)
config_file_name="configs/small-scale-cluster-density.yml"
parameters={
"version": version
}
argDict = {
"config": new_file_name,
"config": config_file_name,
"output_path": "output.csv",
"hunter_analyze": True,
"output_format": "json",
"uuid": uuid,
"baseline": baseline,
"configMap": render_template(config_file_name, parameters)
}
filter_changepoints = (
True if filter_changepoints == "true" else False # pylint: disable = R1719
Expand All @@ -49,8 +50,21 @@ async def daemon(
if filter_changepoints:
for key, value in result.items():
result[key] = list(filter(lambda x: x.get("is_changepoint", False), value))
try:
os.remove(new_file_name)
except OSError as e:
logger_instance.error("error %s", e.strerror)
return result

def render_template(file_name, parameters):
"""replace parameters in the config file
Args:
file_name (str): the config file
parameters (dict): parameters to be replaces
Returns:
dict: configMap in dict
"""
with open(file_name, 'r', encoding="utf-8") as template_file:
template_content = template_file.read()
template = Template(template_content)
rendered_config_yaml = template.render(parameters)
rendered_config = yaml.safe_load(rendered_config_yaml)
return rendered_config
7 changes: 4 additions & 3 deletions pkg/runTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
from fmatch.matcher import Matcher
from pkg.logrus import SingletonLogger
from pkg.utils import run_hunter_analyze, load_config, get_es_url, process_test
from pkg.utils import run_hunter_analyze, get_es_url, process_test


def run(**kwargs):
Expand All @@ -21,12 +21,13 @@ def run(**kwargs):
_type_: _description_
"""
logger_instance = SingletonLogger(debug=logging.INFO).logger
data = load_config(kwargs["config"])
data = kwargs["configMap"]

ES_URL = get_es_url(data)
result_output = {}
for test in data["tests"]:
match = Matcher(
index="perf_scale_ci", level=logger_instance.level, ES_URL=ES_URL
index=test["index"], level=logger_instance.level, ES_URL=ES_URL, verify_certs=False
)
result = process_test(
test, match, kwargs["output_path"], kwargs["uuid"], kwargs["baseline"]
Expand Down
10 changes: 6 additions & 4 deletions pkg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def get_metric_data(ids, index, metrics, match):
agg_name = agg_value + "_" + agg_type
cpu_df = match.convert_to_df(cpu, columns=["uuid", agg_name])
cpu_df = cpu_df.rename(columns={agg_name: metric_name + "_" + agg_name})
cpu_df = cpu_df.drop_duplicates()
dataframe_list.append(cpu_df)
logger_instance.debug(cpu_df)

Expand All @@ -146,6 +147,7 @@ def get_metric_data(ids, index, metrics, match):
podl_df = match.convert_to_df(
podl, columns=["uuid", "timestamp", metric_of_interest]
)
podl_df=podl_df.drop_duplicates()
dataframe_list.append(podl_df)
logger_instance.debug(podl_df)
except Exception as e: # pylint: disable=broad-exception-caught
Expand Down Expand Up @@ -227,14 +229,14 @@ def get_index_and_ids(metadata, uuids, match, baseline):
Returns:
_type_: index and uuids
"""
index_map={"k8s-netperf":"k8s-netperf",
"ingress-perf":"ingress-performance",
index_map={"k8s-netperf":"ospst-k8s-netperf",
"ingress-perf":"ospst-ingress-performance",
}
if metadata["benchmark.keyword"] in index_map:
return index_map[metadata["benchmark.keyword"]], uuids
index = "ripsaw-kube-burner"
index = "ospst-ripsaw-kube-burner*"
if baseline == "":
runs = match.match_kube_burner(uuids)
runs = match.match_kube_burner(uuids,index)
ids = match.filter_runs(runs, runs)
else:
ids = uuids
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ click==8.1.7
elastic-transport==8.11.0
elasticsearch==7.13.0
fmatch==0.0.6
Jinja2==3.1.3
python-dateutil==2.8.2
pytz==2023.3.post1
PyYAML==6.0.1
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
],
},
packages=find_packages(),
package_data={'pkg': ['utils.py',"runTest.py","daemon.py","logrus.py"],'hunter': ['*.py']},
package_data={'pkg': ['utils.py',"runTest.py","daemon.py","logrus.py"],
'hunter': ['*.py'],
'configs':['*.yml']},
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
Expand Down

0 comments on commit e1ca7c3

Please sign in to comment.