Skip to content

Commit 9ccd2e0

Browse files
committed
test: test_run_.py
Changes: - Added tmp_path fixture to all four TestScheduleSuite test methods - Create the expected suite directory structure (tmp_path/suites/suite) - Update self.args.suite_dir to point to the temporary directory This ensures that when schedule_suite() constructs the suite path: suite_path = os.path.join(suite_dir, suite_relpath, 'suites', suite_name) the directory actually exists and passes the os.path.exists() check. Signed-off-by: Kamoltat Sirivadhna <ksirivad@redhat.com>
1 parent a498fef commit 9ccd2e0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

teuthology/suite/test/test_run_.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,15 @@ def test_successful_schedule(
281281
m_get_install_task_flavor,
282282
m_write_rerun_memo,
283283
m_schedule_jobs,
284+
tmp_path,
284285
):
286+
# Create the expected suite directory structure
287+
suite_path = tmp_path / 'suites' / 'suite'
288+
suite_path.mkdir(parents=True, exist_ok=True)
289+
290+
# Update args to use the temporary directory
291+
self.args.suite_dir = str(tmp_path)
292+
285293
m_get_arch.return_value = 'x86_64'
286294
m_git_validate_sha1.return_value = self.args.ceph_sha1
287295
m_package_version_for_hash.return_value = 'ceph_version'
@@ -392,7 +400,15 @@ def test_newest_failure(
392400
m_get_install_task_flavor,
393401
m_schedule_jobs,
394402
m_find_git_parents,
403+
tmp_path,
395404
):
405+
# Create the expected suite directory structure
406+
suite_path = tmp_path / 'suites' / 'suite'
407+
suite_path.mkdir(parents=True, exist_ok=True)
408+
409+
# Update args to use the temporary directory
410+
self.args.suite_dir = str(tmp_path)
411+
396412
m_get_arch.return_value = 'x86_64'
397413
m_git_validate_sha1.return_value = self.args.ceph_sha1
398414
m_package_version_for_hash.return_value = None
@@ -440,13 +456,21 @@ def test_newest_success_same_branch_same_repo(
440456
m_write_rerun_memo,
441457
m_schedule_jobs,
442458
m_find_git_parents,
459+
tmp_path,
443460
):
444461
"""
445462
Test that we can successfully schedule a job with newest
446463
backtracking when the ceph and suite branches are the same
447464
and the ceph_sha1 is not supplied. We should expect that the
448465
ceph_hash and suite_hash will be updated to the working sha1
449466
"""
467+
# Create the expected suite directory structure
468+
suite_path = tmp_path / 'suites' / 'suite'
469+
suite_path.mkdir(parents=True, exist_ok=True)
470+
471+
# Update args to use the temporary directory
472+
self.args.suite_dir = str(tmp_path)
473+
450474
m_get_arch.return_value = 'x86_64'
451475
# rig has_packages_for_distro to fail this many times, so
452476
# everything will run NUM_FAILS+1 times
@@ -548,6 +572,7 @@ def test_newest_success_diff_branch_diff_repo(
548572
m_write_rerun_memo,
549573
m_schedule_jobs,
550574
m_find_git_parents,
575+
tmp_path,
551576
):
552577
"""
553578
Test that we can successfully schedule a job with newest
@@ -556,6 +581,13 @@ def test_newest_success_diff_branch_diff_repo(
556581
ceph_hash will be updated to the working sha1,
557582
but the suite_hash will remain the original suite_sha1.
558583
"""
584+
# Create the expected suite directory structure
585+
suite_path = tmp_path / 'suites' / 'suite'
586+
suite_path.mkdir(parents=True, exist_ok=True)
587+
588+
# Update args to use the temporary directory
589+
self.args.suite_dir = str(tmp_path)
590+
559591
m_get_arch.return_value = 'x86_64'
560592
# Set different branches
561593
self.args.ceph_branch = 'ceph_different_branch'

0 commit comments

Comments
 (0)