-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[TRTLLM-7101][infra] Reuse passed tests #6894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f642d4d
Reuse passed test results from previous pipeline
yiqingy0 c03b249
fix reuse test result in slurm
yiqingy0 83067ef
test code
yiqingy0 0c200dd
test code
yiqingy0 ab29824
remove test code
yiqingy0 90eb2dc
use open search api
yiqingy0 93e94db
revert PR 8999
yiqingy0 c3d290d
review fix
yiqingy0 1a6b411
add test code
yiqingy0 af2b80e
revert test code
yiqingy0 5c9539f
Add description for param REUSE_TEST
yiqingy0 2677bdd
Update jenkins/L0_MergeRequest.groovy
yiqingy0 083973f
print reused tests content
yiqingy0 4f96a79
fix pre-commit
yiqingy0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # ============================================================================= | ||
| # open_search_query.py | ||
| # | ||
| # This module provides functions to query the OpenSearch database for passed | ||
| # test results from previous pipeline runs. It retrieves test names that have | ||
| # passed for a given commit ID and stage name, which can be reused to skip | ||
| # redundant test execution in subsequent runs. | ||
| # | ||
| # Main functionality: | ||
| # - queryJobEvents: Queries OpenSearch for job events with pagination support | ||
| # - getPassedTestList: Retrieves and deduplicates passed test names | ||
| # - writeTestListToFile: Writes test list to a file for further processing | ||
| # | ||
| # ============================================================================= | ||
|
|
||
| import argparse | ||
|
yiqingy0 marked this conversation as resolved.
|
||
| import json | ||
| import os | ||
| import sys | ||
|
|
||
| from open_search_db import OpenSearchDB | ||
|
|
||
|
|
||
| def queryJobEvents(commitID="", stageName="", onlySuccess=True): | ||
| """ | ||
| Query OpenSearch database for job events with pagination. | ||
|
|
||
| Args: | ||
| commitID: Git commit SHA to filter by (optional) | ||
| stageName: Stage name to filter by (optional) | ||
| onlySuccess: If True, only return PASSED tests (default: True) | ||
|
|
||
| Returns: | ||
| List of all matching test result records | ||
| """ | ||
| mustConditions = [] | ||
| if commitID: | ||
| mustConditions.append({"term": {"s_trigger_mr_commit": commitID}}) | ||
| if stageName: | ||
| mustConditions.append({"term": {"s_stage_name": stageName}}) | ||
| if onlySuccess: | ||
| mustConditions.append({"term": {"s_status": "PASSED"}}) | ||
|
|
||
| all_results = [] | ||
| page_size = 1000 | ||
| from_index = 0 | ||
|
|
||
| while True: | ||
| requestBody = { | ||
| "query": {"bool": {"must": mustConditions}}, | ||
| "_source": [ | ||
| "s_job_name", | ||
| "s_status", | ||
| "s_build_id", | ||
| "s_turtle_name", | ||
| "s_test_name", | ||
| "s_gpu_type", | ||
| ], | ||
| "size": page_size, | ||
| "from": from_index, | ||
| } | ||
|
|
||
| formattedRequestBody = json.dumps(requestBody) | ||
| response = OpenSearchDB.queryFromOpenSearchDB( | ||
| formattedRequestBody, "swdl-trtllm-infra-ci-prod-test_info" | ||
| ) | ||
| if response is None: | ||
| print("Failed to query from OpenSearchDB") | ||
| break | ||
| data = response.json() | ||
|
|
||
| hits = data["hits"]["hits"] | ||
| if not hits: | ||
| break | ||
|
|
||
| all_results.extend(hits) | ||
| from_index += page_size | ||
|
|
||
| print(f"Fetched {len(all_results)} records...") | ||
|
|
||
| return all_results | ||
|
|
||
|
|
||
| def writeTestListToFile(testList, fileName): | ||
| os.makedirs(os.path.dirname(fileName), exist_ok=True) | ||
|
|
||
| with open(fileName, "w") as f: | ||
| for test in testList: | ||
| f.write(test + "\n") | ||
|
|
||
|
|
||
| def getPassedTestList(commitID, stageName, outputFile): | ||
| hits = queryJobEvents(commitID=commitID, stageName=stageName, onlySuccess=True) | ||
| # Use set to automatically remove duplicates | ||
| testSet = set() | ||
| for hit in hits: | ||
| testSet.add(hit["_source"]["s_turtle_name"]) | ||
| testList = list(testSet) | ||
| writeTestListToFile(testList, outputFile) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument("--commit-id", required=True, help="Commit ID") | ||
| parser.add_argument("--stage-name", required=True, help="Stage Name") | ||
| parser.add_argument("--output-file", required=True, help="Output File") | ||
| args = parser.parse_args(sys.argv[1:]) | ||
| getPassedTestList( | ||
| commitID=args.commit_id, stageName=args.stage_name, outputFile=args.output_file | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.