Skip to content

Commit

Permalink
adding previous version option
Browse files Browse the repository at this point in the history
rh-pre-commit.version: 2.2.0
rh-pre-commit.check-secrets: ENABLED

Signed-off-by: Paige Patton <prubenda@redhat.com>
  • Loading branch information
Auto User authored and paigerube14 committed Jan 3, 2025
1 parent 72374fa commit 4cd9e05
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Clone the current repository using git clone.
>> source venv/bin/activate
>> pip install -r requirements.txt
>> export ES_SERVER = <es_server_url>
>> export version=<ocp version>
>> pip install .
```
## Run Orion
Expand Down Expand Up @@ -198,10 +199,9 @@ POST http://127.0.0.1:8080/daemon/changepoint

- uuid (optional): The uuid of the run you want to compare with similar runs.
- baseline (optional): The runs you want to compare with.
- version (optional): The ocpVersion you want to use for metadata defaults to `4.15`
- filter_changepoints (optional): set to `true` if you only want changepoints to show up in the response
- test_name (optional): name of the test you want to perform defaults to `small-scale-cluster-density`

- previous-version (optional): Compare most recent run or given UUID with previous versions

Example
```
Expand Down
1 change: 1 addition & 0 deletions orion.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def cli(max_content_width=120): # pylint: disable=unused-argument
@click.option("--collapse", is_flag=True, help="Only outputs changepoints, previous and later runs in the xml format")
@click.option("--node-count", default=False, help="Match any node iterations count")
@click.option("--lookback-size", type=int, default=10000, help="Maximum number of entries to be looked back")
@click.option("--previous-version", is_flag=True, default=False, help="Match with previous version from metadata")
def cmd_analysis(**kwargs):
"""
Orion runs on command line mode, and helps in detecting regressions
Expand Down
42 changes: 25 additions & 17 deletions pkg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ def extract_metadata_from_test(test: Dict[str, Any]) -> Dict[Any, Any]:
return metadata





def get_datasource(data: Dict[Any, Any]) -> str:
"""Gets es url from config or env
Expand Down Expand Up @@ -178,16 +175,12 @@ def filter_uuids_on_index(
ids = uuids
return ids


def get_build_urls(index: str, uuids: List[str], match: Matcher):
"""Gets metadata of the run from each test
to get the build url
Args:
uuids (list): str list of uuid to find build urls of
match: the fmatch instance
Returns:
dict: dictionary of the metadata
"""
Expand Down Expand Up @@ -218,23 +211,38 @@ def process_test(
logger.info("The test %s has started", test["name"])
fingerprint_index = test["index"]

# getting metadata
metadata = extract_metadata_from_test(test) if options["uuid"] in ("", None) else get_metadata_with_uuid(options["uuid"], match)
# get uuids, buildUrls matching with the metadata
runs = match.get_uuid_by_metadata(metadata, fingerprint_index, lookback_date=start_timestamp, lookback_size=options['lookback_size'])
uuids = [run["uuid"] for run in runs]
buildUrls = {run["uuid"]: run["buildUrl"] for run in runs}
# get uuids if there is a baseline
# get uuids if there is a baseline and uuid set
if options["baseline"] not in ("", None):
# if baseline is set, set uuids
uuids = [uuid for uuid in re.split(r" |,", options["baseline"]) if uuid]
uuids.append(options["uuid"])
buildUrls = get_build_urls(fingerprint_index, uuids, match)
elif not uuids:
runs = match.getResults("", uuids, fingerprint_index, {})
# get metadata of one run
metadata = get_metadata_with_uuid(options["uuid"], match)
else:
# getting metadata
metadata = extract_metadata_from_test(test) if options["uuid"] in ("", None) else get_metadata_with_uuid(options["uuid"], match)
# get uuids, buildUrls matching with the metadata
# this match might not always work if UUID failed run, we still want to analyze
runs = match.get_uuid_by_metadata(metadata, fingerprint_index, lookback_date=start_timestamp, lookback_size=options['lookback_size'])

if options['previous_version']:
last_version_run = runs
metadata['ocpVersion'] = str(float(metadata['ocpVersion'][:4]) - .01)
runs = match.get_uuid_by_metadata(metadata, fingerprint_index, lookback_date=start_timestamp)

# get latest uuid as the "uuid" to compare against
last_uuid_run = last_version_run[-1]
runs.append(last_uuid_run)

if not runs:
logger.info("No UUID present for given metadata")
return None, None

benchmark_index = test["benchmarkIndex"]

#Want to set uuid list right before usage
buildUrls = {run["uuid"]: run["buildUrl"] for run in runs}
uuids = [run["uuid"] for run in runs]
uuids = filter_uuids_on_index(
metadata, benchmark_index, uuids, match, options["baseline"], options['node_count']
)
Expand Down
6 changes: 6 additions & 0 deletions test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ setup() {
export version='4.17'
}


@test "orion cmd with previous version" {
run_cmd orion cmd --config "configs/small-scale-cluster-density.yaml" --previous-version
}


@test "orion cmd label small scale cluster density with hunter-analyze " {
run_cmd orion cmd --config "examples/label-small-scale-cluster-density.yaml" --lookback 5d --hunter-analyze
}
Expand Down

0 comments on commit 4cd9e05

Please sign in to comment.