Skip to content

Commit

Permalink
Add kvrocks cleanup after class in rest api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiltsov-max committed Oct 3, 2024
1 parent 398c8f8 commit c0cb1d6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cvat/apps/engine/frame_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,8 @@ def get_frame_index(self, frame_number: int) -> Optional[int]:
abs_frame_number = self._get_abs_frame_number(self._db_segment.task.data, frame_number)
frame_index = bisect(segment_frames, abs_frame_number) - 1
if not (
0 <= frame_index < len(segment_frames) and
segment_frames[frame_index] == abs_frame_number
0 <= frame_index < len(segment_frames)
and segment_frames[frame_index] == abs_frame_number
):
return None

Expand Down
9 changes: 8 additions & 1 deletion tests/python/rest_api/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ def interpolate(frame):

@pytest.mark.usefixtures("restore_db_per_class")
@pytest.mark.usefixtures("restore_redis_inmem_per_function")
@pytest.mark.usefixtures("restore_redis_ondisk_after_class")
class TestGetTaskDataset:

@staticmethod
Expand Down Expand Up @@ -987,6 +988,7 @@ def test_uses_subset_name(
@pytest.mark.usefixtures("restore_db_per_function")
@pytest.mark.usefixtures("restore_cvat_data_per_function")
@pytest.mark.usefixtures("restore_redis_ondisk_per_function")
@pytest.mark.usefixtures("restore_redis_ondisk_after_class")
class TestPostTaskData:
_USERNAME = "admin1"

Expand Down Expand Up @@ -2593,8 +2595,9 @@ def read_frame(self, i: int) -> Image.Image:


@pytest.mark.usefixtures("restore_db_per_class")
@pytest.mark.usefixtures("restore_redis_ondisk_per_class")
@pytest.mark.usefixtures("restore_cvat_data_per_class")
@pytest.mark.usefixtures("restore_redis_ondisk_per_class")
@pytest.mark.usefixtures("restore_redis_ondisk_after_class")
class TestTaskData:
_USERNAME = "admin1"

Expand Down Expand Up @@ -3571,6 +3574,8 @@ def test_work_with_task_containing_non_stable_cloud_storage_files(


@pytest.mark.usefixtures("restore_redis_inmem_per_function")
@pytest.mark.usefixtures("restore_redis_ondisk_per_class")
@pytest.mark.usefixtures("restore_redis_ondisk_after_class")
class TestTaskBackups:
@pytest.fixture(autouse=True)
def setup(
Expand Down Expand Up @@ -4379,6 +4384,8 @@ def test_task_unassigned_cannot_see_task_preview(
self._test_assigned_users_cannot_see_task_preview(tasks, users, is_task_staff)


@pytest.mark.usefixtures("restore_redis_ondisk_per_class")
@pytest.mark.usefixtures("restore_redis_ondisk_after_class")
class TestUnequalJobs:
@pytest.fixture(autouse=True)
def setup(self, restore_db_per_function, tmp_path: Path, admin_user: str):
Expand Down
11 changes: 11 additions & 0 deletions tests/python/shared/fixtures/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,3 +634,14 @@ def restore_redis_ondisk_per_class(request):
docker_restore_redis_ondisk()
else:
kube_restore_redis_ondisk()


@pytest.fixture(scope="class")
def restore_redis_ondisk_after_class(request):
yield

platform = request.config.getoption("--platform")
if platform == "local":
docker_restore_redis_ondisk()
else:
kube_restore_redis_ondisk()

0 comments on commit c0cb1d6

Please sign in to comment.