Skip to content

Commit d8ee0ab

Browse files
authored
Merge branch 'main' into reduce_smoke
2 parents 02b545d + 3a82bc8 commit d8ee0ab

265 files changed

Lines changed: 2787 additions & 2364 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ fcn_exclude_functions =
3333
add_to_assignees,
3434
validate_inference_output, # TODO: function should be fixed to get rid of this
3535
group
36+
writelines
37+
temp_file
38+
sleep
3639

3740
enable-extensions =
3841
FCN,

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ tests/model_explainability/ @sheltoncyril @kpunwatk
1515
tests/model_registry/ @dbasunag @lugi0 @fege
1616
tests/model_serving/ @mwaykole @Raghul-M @brettmthompson @threcc @malhajfr
1717
tests/rag/ @jgarciao @jiripetrlik
18-
tests/workbenches @jstourac @andyatmiami
18+
tests/workbenches @jstourac @andyatmiami @jiridanek @harshad16
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Bug Report
3+
about: Create a report to help us improve
4+
title: '[BUG] '
5+
labels: ['bug']
6+
assignees: ''
7+
---
8+
9+
## Problem Description
10+
11+
<!-- Describe the bug or issue -->
12+
13+
## Steps to Reproduce/Stacktrace
14+
15+
<!-- Add any steps to reproduce the issue being reported or add any relevant stacktrace -->
16+
17+
## Proposed Solution
18+
19+
<!-- If you have a suggestion for how to fix this, describe it here -->
20+
21+
## Additional Context
22+
23+
<!-- Any other information that might be helpful -->

.github/pull_request_template.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Summary
2+
3+
<!-- Brief description of changes and why they are needed -->
4+
5+
## Related Issues
6+
7+
<!-- Link related issues/tickets -->
8+
- Fixes: <!-- github issue -->
9+
- JIRA: <!-- Jira information -->
10+
11+
## How it has been tested
12+
13+
- [ ] Locally
14+
- [ ] Jenkins
15+
16+
## Additional Requirements
17+
18+
- [ ] If this PR introduces a new test image, did you create a PR to mirror it in disconnected environment?
19+
- [ ] If this PR introduces new marker(s)/adds a new component, was relevant ticket created to update relevant Jenkins job?

.github/workflows/scripts/pr_workflow.py

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22
import re
33
import sys
44

5-
from github.PullRequest import PullRequest
6-
from github.Repository import Repository
7-
from github.MainClass import Github
8-
from github.GithubException import UnknownObjectException
9-
from github.Organization import Organization
10-
from github.Team import Team
11-
125
from constants import (
136
ALL_LABELS_DICT,
7+
APPROVED,
148
CANCEL_ACTION,
159
CHANGED_REQUESTED_BY_LABEL_PREFIX,
1610
COMMENTED_BY_LABEL_PREFIX,
@@ -22,8 +16,13 @@
2216
SUPPORTED_LABELS,
2317
VERIFIED_LABEL_STR,
2418
WELCOME_COMMENT,
25-
APPROVED,
2619
)
20+
from github.GithubException import UnknownObjectException
21+
from github.MainClass import Github
22+
from github.Organization import Organization
23+
from github.PullRequest import PullRequest
24+
from github.Repository import Repository
25+
from github.Team import Team
2726
from simple_logger.logger import get_logger
2827

2928
LOGGER = get_logger(name="pr_labeler")
@@ -35,7 +34,7 @@ class SupportedActions:
3534
pr_size_action_name: str = "add-pr-size-label"
3635
welcome_comment_action_name: str = "add-welcome-comment-set-assignee"
3736
build_push_pr_image_action_name: str = "push-container-on-comment"
38-
supported_actions: set[str] = {
37+
supported_actions: set[str] = { # noqa: RUF012
3938
pr_size_action_name,
4039
add_remove_labels_action_name,
4140
welcome_comment_action_name,
@@ -48,7 +47,7 @@ def __init__(self) -> None:
4847
self.gh_client: Github
4948

5049
self.repo_name = os.environ["GITHUB_REPOSITORY"]
51-
self.pr_number = int(os.getenv("GITHUB_PR_NUMBER", 0))
50+
self.pr_number = int(os.getenv("GITHUB_PR_NUMBER", "0"))
5251
self.action = os.getenv("ACTION")
5352
self.event_action = os.getenv("GITHUB_EVENT_ACTION")
5453
self.event_name = os.getenv("GITHUB_EVENT_NAME")
@@ -110,7 +109,7 @@ def verify_allowed_user(self) -> bool:
110109
# check if the user is a member of opendatahub-tests-contributors
111110
membership = team.get_team_membership(member=self.user_login)
112111
LOGGER.info(f"User {self.user_login} is a member of the test contributor team. {membership}")
113-
return True
112+
return True # noqa: TRY300
114113
except UnknownObjectException:
115114
LOGGER.error(f"User {self.user_login} is not allowed for this action. Exiting.")
116115
return False
@@ -123,23 +122,19 @@ def verify_labeler_config(self) -> None:
123122
if not self.user_login:
124123
sys.exit("`GITHUB_USER_LOGIN` is not set")
125124

126-
if (
127-
self.event_name == "issue_comment" or self.event_name == "pull_request_review"
128-
) and not self.comment_body:
125+
if (self.event_name in {"issue_comment", "pull_request_review"}) and not self.comment_body:
129126
LOGGER.info("No comment, nothing to do. Exiting.")
130127
sys.exit(0)
131128

132129
def run_pr_label_action(self) -> None:
133130
if self.action == self.SupportedActions.pr_size_action_name:
134131
self.set_pr_size()
135132

136-
if self.action == self.SupportedActions.build_push_pr_image_action_name:
137-
if not self.verify_allowed_user():
138-
sys.exit(1)
133+
if self.action == self.SupportedActions.build_push_pr_image_action_name and not self.verify_allowed_user():
134+
sys.exit(1)
139135

140-
if self.action == self.SupportedActions.add_remove_labels_action_name:
141-
if self.verify_allowed_user():
142-
self.add_remove_pr_labels()
136+
if self.action == self.SupportedActions.add_remove_labels_action_name and self.verify_allowed_user():
137+
self.add_remove_pr_labels()
143138

144139
if self.action == self.SupportedActions.welcome_comment_action_name:
145140
self.add_welcome_comment_set_assignee()
@@ -187,10 +182,9 @@ def set_label_in_repository(self, label: str) -> None:
187182
LOGGER.info(f"repo labels: {repo_labels}")
188183

189184
try:
190-
if _repo_label := self.repo.get_label(name=label):
191-
if _repo_label.color != label_color:
192-
LOGGER.info(f"Edit repository label: {label}, color: {label_color}")
193-
_repo_label.edit(name=_repo_label.name, color=label_color)
185+
if (_repo_label := self.repo.get_label(name=label)) and _repo_label.color != label_color:
186+
LOGGER.info(f"Edit repository label: {label}, color: {label_color}")
187+
_repo_label.edit(name=_repo_label.name, color=label_color)
194188

195189
except UnknownObjectException:
196190
LOGGER.info(f"Add repository label: {label}, color: {label_color}")
@@ -249,16 +243,15 @@ def add_remove_pr_labels(self) -> None:
249243

250244
return
251245

252-
elif self.event_name == "pull_request_review":
246+
elif (
247+
self.event_name == "pull_request_review"
248+
or self.event_name == "workflow_run"
249+
and self.event_action == "submitted"
250+
):
253251
self.pull_request_review_label_actions()
254252

255253
return
256254

257-
# We will only reach here if the PR was created from a fork
258-
elif self.event_name == "workflow_run" and self.event_action == "submitted":
259-
self.pull_request_review_label_actions()
260-
return
261-
262255
LOGGER.warning("`add_remove_pr_label` called without a supported event")
263256

264257
def pull_request_review_label_actions(
@@ -317,7 +310,7 @@ def issue_comment_label_actions(
317310
if not action[CANCEL_ACTION] or self.event_action == "deleted":
318311
self.approve_pr()
319312

320-
label_in_pr = any([label == _label.lower() for _label in self.pr_labels])
313+
label_in_pr = any(label == _label.lower() for _label in self.pr_labels)
321314
LOGGER.info(f"Processing label: {label}, action: {action}")
322315

323316
if action[CANCEL_ACTION] or self.event_action == "deleted":

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ repos:
3636
exclude: .*/__snapshots__/.*|.*-input\.json$
3737

3838
- repo: https://github.com/astral-sh/ruff-pre-commit
39-
rev: v0.15.1
39+
rev: v0.15.2
4040
hooks:
4141
- id: ruff
4242
- id: ruff-format
@@ -68,6 +68,7 @@ repos:
6868
- id: conventional-precommit-linter
6969
stages: [ commit-msg ]
7070
args:
71+
- --types=build,ci,chore,docs,feat,fix,perf,refactor,revert,style,test
7172
- --subject-min-length=10
7273
- --subject-max-length=80
7374
- repo: local

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ The tests are written in Python and use [pytest](https://docs.pytest.org/en/stab
77
## Getting started
88
Please follow the [Getting Started Guide](docs/GETTING_STARTED.md) on how to run the tests.
99

10+
## Example of upgrade testing
11+
Please follow the [Upgrade Guide](docs/UPGRADE.md) on how to run the upgrade tests.
12+
1013

1114
## Contribute to opendatahub-tests
1215
Please follow the [Contributing Guide](docs/CONTRIBUTING.md) and the [Developer guide](docs/DEVELOPER_GUIDE.md)

conftest.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1+
import datetime
12
import logging
23
import os
34
import pathlib
45
import shutil
5-
import datetime
66
import traceback
7+
from typing import Any
78

89
import pytest
910
import shortuuid
10-
from _pytest.runner import CallInfo
11+
from _pytest.nodes import Node
1112
from _pytest.reports import TestReport
13+
from _pytest.runner import CallInfo
14+
from _pytest.terminal import TerminalReporter
15+
from kubernetes.dynamic import DynamicClient
16+
from ocp_resources.cluster_service_version import ClusterServiceVersion
17+
from ocp_resources.resource import get_client
1218
from pytest import (
13-
Parser,
14-
Session,
15-
FixtureRequest,
16-
FixtureDef,
17-
Item,
1819
Collector,
19-
Config,
2020
CollectReport,
21+
Config,
22+
FixtureDef,
23+
FixtureRequest,
24+
Item,
25+
Parser,
26+
Session,
2127
)
22-
from _pytest.nodes import Node
23-
from _pytest.terminal import TerminalReporter
24-
from typing import Optional, Any
2528
from pytest_testconfig import config as py_config
2629

27-
from utilities.constants import KServeDeploymentType, MODEL_REGISTRY_CUSTOM_NAMESPACE
30+
from utilities.constants import MODEL_REGISTRY_CUSTOM_NAMESPACE, KServeDeploymentType
2831
from utilities.database import Database
32+
from utilities.infra import get_data_science_cluster, get_dsci_applications_namespace, get_operator_distribution
2933
from utilities.logger import separator, setup_logging
3034
from utilities.must_gather_collector import (
31-
set_must_gather_collector_directory,
32-
set_must_gather_collector_values,
33-
get_must_gather_collector_dir,
3435
collect_rhoai_must_gather,
3536
get_base_dir,
37+
get_must_gather_collector_dir,
38+
set_must_gather_collector_directory,
39+
set_must_gather_collector_values,
3640
)
37-
from kubernetes.dynamic import DynamicClient
38-
from utilities.infra import get_operator_distribution, get_dsci_applications_namespace, get_data_science_cluster
39-
from ocp_resources.resource import get_client
40-
from ocp_resources.cluster_service_version import ClusterServiceVersion
4141

4242
LOGGER = logging.getLogger(name=__name__)
4343
BASIC_LOGGER = logging.getLogger(name="basic")
@@ -229,7 +229,7 @@ def _add_upgrade_test(_item: Item, _upgrade_deployment_modes: list[str]) -> bool
229229
if not _upgrade_deployment_modes:
230230
return True
231231

232-
return any([keyword for keyword in _item.keywords if keyword in _upgrade_deployment_modes])
232+
return any(keyword for keyword in _item.keywords if keyword in _upgrade_deployment_modes)
233233

234234
pre_upgrade_tests: list[Item] = []
235235
post_upgrade_tests: list[Item] = []
@@ -310,7 +310,7 @@ def pytest_sessionstart(session: Session) -> None:
310310
value = log_cli_override.split("=", 1)[1].lower()
311311
enable_console_value = value not in ("false", "0", "no", "off")
312312

313-
except Exception as e:
313+
except Exception as e: # noqa: BLE001
314314
# If there's any issue with option detection, fall back to default behavior
315315
LOGGER.error(f"Error detecting log_cli option: {e}")
316316
enable_console_value = True
@@ -397,9 +397,9 @@ def pytest_runtest_setup(item: Item) -> None:
397397
db = item.config.option.must_gather_db
398398
db.insert_test_start_time(
399399
test_name=f"{item.fspath}::{item.name}",
400-
start_time=int(datetime.datetime.now().timestamp()),
400+
start_time=int(datetime.datetime.now().timestamp()), # noqa: DTZ005
401401
)
402-
except Exception as db_exception:
402+
except Exception as db_exception: # noqa: BLE001
403403
LOGGER.error(f"Database error: {db_exception}. Must-gather collection may not be accurate")
404404

405405
if KServeDeploymentType.RAW_DEPLOYMENT.lower() in item.keywords:
@@ -460,15 +460,15 @@ def pytest_sessionfinish(session: Session, exitstatus: int) -> None:
460460
LOGGER.info(f"Deleting pytest base dir {session.config.option.basetemp}")
461461
shutil.rmtree(path=session.config.option.basetemp, ignore_errors=True)
462462

463-
reporter: Optional[TerminalReporter] = session.config.pluginmanager.get_plugin("terminalreporter")
463+
reporter: TerminalReporter | None = session.config.pluginmanager.get_plugin("terminalreporter")
464464
if reporter:
465465
reporter.summary_stats()
466466

467467

468468
def calculate_must_gather_timer(test_start_time: int) -> int:
469469
default_duration = 300
470470
if test_start_time > 0:
471-
duration = int(datetime.datetime.now().timestamp()) - test_start_time
471+
duration = int(datetime.datetime.now().timestamp()) - test_start_time # noqa: DTZ005
472472
return duration if duration > 60 else default_duration
473473
else:
474474
LOGGER.warning(f"Could not get start time of test. Collecting must-gather for last {default_duration}s")
@@ -492,7 +492,7 @@ def pytest_exception_interact(node: Item | Collector, call: CallInfo[Any], repor
492492
try:
493493
db = node.config.option.must_gather_db
494494
test_start_time = db.get_test_start_time(test_name=test_name)
495-
except Exception as db_exception:
495+
except Exception as db_exception: # noqa: BLE001
496496
test_start_time = 0
497497
LOGGER.warning(f"Error: {db_exception} in accessing database.")
498498

@@ -503,7 +503,7 @@ def pytest_exception_interact(node: Item | Collector, call: CallInfo[Any], repor
503503
target_dir=os.path.join(get_must_gather_collector_dir(), "pytest_exception_interact"),
504504
)
505505

506-
except Exception as current_exception:
506+
except Exception as current_exception: # noqa: BLE001
507507
LOGGER.warning(f"Failed to collect logs: {test_name}: {current_exception} {traceback.format_exc()}")
508508

509509

docs/GETTING_STARTED.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ uv run pytest -o log_cli=false
106106
uv run pytest -k test_name
107107
```
108108

109+
### Running component smoke
110+
```bash
111+
uv run pytest tests/<component_name> -m "smoke and not sanity and not tier1"
112+
```
113+
109114
### LlamaStack Integration Tests
110115
For more information about LlamaStack integration tests, see [/tests/llama_stack/README.md](../tests/llama_stack/README.md).
111116

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ fix = true
55
output-format = "grouped"
66
extend-exclude = ["utilities/manifests"]
77

8+
[tool.ruff.lint]
9+
external = ["E501"]
10+
811
[tool.ruff.format]
912
exclude = [".git", ".venv", ".mypy_cache", ".tox", "__pycache__", "utilities/manifests"]
1013

0 commit comments

Comments
 (0)