Skip to content

Commit d5979d6

Browse files
committed
minor updates
1 parent 2e162ba commit d5979d6

5 files changed

Lines changed: 55 additions & 48 deletions

File tree

conftest.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
set_must_gather_collector_directory,
3030
set_must_gather_collector_values,
3131
get_must_gather_collector_dir,
32-
collect_rhoai_must_gather,
32+
collect_rhoai_must_gather, get_base_dir,
3333
)
3434

3535
LOGGER = logging.getLogger(name=__name__)
@@ -223,7 +223,8 @@ def _add_upgrade_test(_item: Item, _upgrade_deployment_modes: list[str]) -> bool
223223

224224

225225
def pytest_sessionstart(session: Session) -> None:
226-
tests_log_file = session.config.getoption("log_file") or "pytest-tests.log"
226+
log_file = session.config.getoption("log_file") or "pytest-tests.log"
227+
tests_log_file = os.path.join(get_base_dir(), log_file)
227228
if os.path.exists(tests_log_file):
228229
pathlib.Path(tests_log_file).unlink()
229230

@@ -252,7 +253,6 @@ def pytest_runtest_setup(item: Item) -> None:
252253
BASIC_LOGGER.info(f"\n{separator(symbol_='-', val=item.name)}")
253254
BASIC_LOGGER.info(f"{separator(symbol_='-', val='SETUP')}")
254255
if item.config.getoption("--collect-must-gather"):
255-
BASIC_LOGGER.info("I am here")
256256
# set must-gather collection directory:
257257
set_must_gather_collector_directory(item=item, directory_path=get_must_gather_collector_dir())
258258

@@ -342,7 +342,8 @@ def pytest_sessionfinish(session: Session, exitstatus: int) -> None:
342342
def calculate_must_gather_timer(test_start_time: int) -> int:
343343
default_duration = 300
344344
if test_start_time > 0:
345-
return int(datetime.datetime.now().strftime("%s")) - test_start_time
345+
duration = int(datetime.datetime.now().strftime("%s")) - test_start_time
346+
return duration if duration > 60 else default_duration
346347
else:
347348
LOGGER.warning(f"Could not get start time of test. Collecting must-gather for last {default_duration}s")
348349
return default_duration

tests/model_registry/test_temp.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

utilities/database.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sqlalchemy import Integer, String, create_engine
44
from sqlalchemy.orm import Mapped, Session, mapped_column
55
from sqlalchemy.orm import DeclarativeBase
6-
from utilities.must_gather_collector import get_must_gather_base_dir
6+
from utilities.must_gather_collector import get_base_dir
77

88
LOGGER = logging.getLogger(__name__)
99

@@ -24,7 +24,7 @@ class OpenDataHubTestTable(Base):
2424

2525
class Database:
2626
def __init__(self, database_file_name: str = TEST_DB, verbose: bool = True) -> None:
27-
self.database_file_path = f"{get_must_gather_base_dir()}{database_file_name}"
27+
self.database_file_path = f"{get_base_dir()}{database_file_name}"
2828
self.connection_string = f"sqlite:///{self.database_file_path}"
2929
self.verbose = verbose
3030
self.engine = create_engine(url=self.connection_string, echo=self.verbose)

utilities/must_gather_collector.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@
1111
BASE_DIRECTORY_NAME = "must-gather-collected"
1212

1313

14-
def get_must_gather_base_dir() -> str:
15-
return f"{'' if os.environ.get('LOCAL_RUN') else '/home/odh/opendatahub-tests/results/'}"
14+
def get_base_dir() -> str:
15+
if os.path.exists('/home/odh/opendatahub-tests/'):
16+
# we are running from jenkins.
17+
return "/home/odh/opendatahub-tests/results"
18+
else:
19+
# this is local run
20+
return ""
1621

1722

1823
def set_must_gather_collector_values() -> dict[str, str]:
1924
py_config["must_gather_collector"] = {
20-
"must_gather_base_directory": f"{get_must_gather_base_dir()}{BASE_DIRECTORY_NAME}",
25+
"must_gather_base_directory": f"{get_base_dir()}{BASE_DIRECTORY_NAME}",
2126
}
2227
return py_config["must_gather_collector"]
2328

0 commit comments

Comments
 (0)