Skip to content

Commit f39c728

Browse files
Auto Userpaigerube14
authored andcommitted
adding previous version option
rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED Signed-off-by: Paige Patton <prubenda@redhat.com>
1 parent 72374fa commit f39c728

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ Clone the current repository using git clone.
101101
>> source venv/bin/activate
102102
>> pip install -r requirements.txt
103103
>> export ES_SERVER = <es_server_url>
104+
>> export version=<ocp version>
104105
>> pip install .
105106
```
106107
## Run Orion
@@ -198,10 +199,9 @@ POST http://127.0.0.1:8080/daemon/changepoint
198199

199200
- uuid (optional): The uuid of the run you want to compare with similar runs.
200201
- baseline (optional): The runs you want to compare with.
201-
- version (optional): The ocpVersion you want to use for metadata defaults to `4.15`
202202
- filter_changepoints (optional): set to `true` if you only want changepoints to show up in the response
203203
- test_name (optional): name of the test you want to perform defaults to `small-scale-cluster-density`
204-
204+
- previous-version (optional): Compare most recent run or given UUID with previous versions
205205

206206
Example
207207
```

orion.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def cli(max_content_width=120): # pylint: disable=unused-argument
116116
@click.option("--collapse", is_flag=True, help="Only outputs changepoints, previous and later runs in the xml format")
117117
@click.option("--node-count", default=False, help="Match any node iterations count")
118118
@click.option("--lookback-size", type=int, default=10000, help="Maximum number of entries to be looked back")
119+
@click.option("--previous-version", is_flag=True, default=False, help="Match with previous version from metadata")
119120
def cmd_analysis(**kwargs):
120121
"""
121122
Orion runs on command line mode, and helps in detecting regressions

pkg/utils.py

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ def extract_metadata_from_test(test: Dict[str, Any]) -> Dict[Any, Any]:
129129
return metadata
130130

131131

132-
133-
134-
135132
def get_datasource(data: Dict[Any, Any]) -> str:
136133
"""Gets es url from config or env
137134
@@ -178,16 +175,12 @@ def filter_uuids_on_index(
178175
ids = uuids
179176
return ids
180177

181-
182178
def get_build_urls(index: str, uuids: List[str], match: Matcher):
183179
"""Gets metadata of the run from each test
184180
to get the build url
185-
186181
Args:
187182
uuids (list): str list of uuid to find build urls of
188183
match: the fmatch instance
189-
190-
191184
Returns:
192185
dict: dictionary of the metadata
193186
"""
@@ -218,23 +211,40 @@ def process_test(
218211
logger.info("The test %s has started", test["name"])
219212
fingerprint_index = test["index"]
220213

221-
# getting metadata
222-
metadata = extract_metadata_from_test(test) if options["uuid"] in ("", None) else get_metadata_with_uuid(options["uuid"], match)
223-
# get uuids, buildUrls matching with the metadata
224-
runs = match.get_uuid_by_metadata(metadata, fingerprint_index, lookback_date=start_timestamp, lookback_size=options['lookback_size'])
225-
uuids = [run["uuid"] for run in runs]
226-
buildUrls = {run["uuid"]: run["buildUrl"] for run in runs}
227-
# get uuids if there is a baseline
214+
# get uuids if there is a baseline and uuid set
228215
if options["baseline"] not in ("", None):
216+
# if baseline is set,
229217
uuids = [uuid for uuid in re.split(r" |,", options["baseline"]) if uuid]
230218
uuids.append(options["uuid"])
231-
buildUrls = get_build_urls(fingerprint_index, uuids, match)
232-
elif not uuids:
219+
runs = match.getResults("", uuids, fingerprint_index, {})
220+
221+
# get metadata of one run
222+
metadata = get_metadata_with_uuid(options["uuid"], match)
223+
else:
224+
# getting metadata
225+
metadata = extract_metadata_from_test(test) if options["uuid"] in ("", None) else get_metadata_with_uuid(options["uuid"], match)
226+
# get uuids, buildUrls matching with the metadata
227+
# this match might not always work if UUID failed run, we still want to analyze
228+
runs = match.get_uuid_by_metadata(metadata, fingerprint_index, lookback_date=start_timestamp, lookback_size=options['lookback_size'])
229+
230+
if options['previous_version']:
231+
last_version_run = runs
232+
metadata['ocpVersion'] = str(float(metadata['ocpVersion'][:4]) - .01)
233+
runs = match.get_uuid_by_metadata(metadata, fingerprint_index, lookback_date=start_timestamp)
234+
235+
# get latest uuid as the "uuid" to compare against
236+
last_uuid_run = last_version_run[-1]
237+
runs.append(last_uuid_run)
238+
239+
240+
if not runs:
233241
logger.info("No UUID present for given metadata")
234242
return None, None
235243

236244
benchmark_index = test["benchmarkIndex"]
237-
245+
#Want to set uuid list right before usage
246+
buildUrls = {run["uuid"]: run["buildUrl"] for run in runs}
247+
uuids = [run["uuid"] for run in runs]
238248
uuids = filter_uuids_on_index(
239249
metadata, benchmark_index, uuids, match, options["baseline"], options['node_count']
240250
)

0 commit comments

Comments
 (0)