From 2bc4fa6dae0ba06a996a5351db851ad9a3191eac Mon Sep 17 00:00:00 2001 From: Auto User Date: Wed, 21 Aug 2024 16:49:20 -0400 Subject: [PATCH] adding previous version option rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED Signed-off-by: Paige Patton --- README.md | 4 ++-- orion.py | 1 + pkg/utils.py | 42 +++++++++++++++++++++++++----------------- test.bats | 6 ++++++ 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 57ffcd1..0b0411d 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ Clone the current repository using git clone. >> source venv/bin/activate >> pip install -r requirements.txt >> export ES_SERVER = +>> export version= >> pip install . ``` ## Run Orion @@ -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 ``` diff --git a/orion.py b/orion.py index 3690213..637b5f8 100644 --- a/orion.py +++ b/orion.py @@ -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 diff --git a/pkg/utils.py b/pkg/utils.py index 94cf457..cc29d9d 100644 --- a/pkg/utils.py +++ b/pkg/utils.py @@ -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 @@ -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 """ @@ -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'] ) diff --git a/test.bats b/test.bats index fd779e3..6f4c49a 100644 --- a/test.bats +++ b/test.bats @@ -29,6 +29,12 @@ setup() { export version='4.17' } + +@test "orion cmd with previous version" { + run_cmd orion cmd --config "config/small-scale-node-density-cni.yaml" --previous-version --cmr +} + + @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 }