1313from pydantic import ValidationError
1414from sqlalchemy .ext .asyncio import AsyncSession
1515
16+ from dstack ._internal .core .errors import ServerClientError
1617from dstack ._internal .core .models .logs import LogEvent , LogEventSource
1718from dstack ._internal .server .models import ProjectModel
1819from dstack ._internal .server .schemas .logs import PollLogsRequest
@@ -206,49 +207,22 @@ async def test_poll_logs_invalid_next_token_raises_error(
206207 limit = 10 ,
207208 diagnose = True ,
208209 )
209- with pytest .raises (
210- LogStorageError , match = "Invalid next_token: invalid. Must be a valid integer."
211- ):
210+ with pytest .raises (ServerClientError ):
212211 log_storage .poll_logs (project , poll_request )
213212
214213 # Test with negative next_token
215214 poll_request .next_token = "-1"
216- with pytest .raises (
217- LogStorageError , match = "Invalid next_token: -1. Must be a non-negative integer."
218- ):
215+ with pytest .raises (ServerClientError ):
219216 log_storage .poll_logs (project , poll_request )
220217
221218 # Test with float next_token
222219 poll_request .next_token = "1.5"
223- with pytest .raises (
224- LogStorageError , match = "Invalid next_token: 1.5. Must be a valid integer."
225- ):
220+ with pytest .raises (ServerClientError ):
226221 log_storage .poll_logs (project , poll_request )
227222
228223 @pytest .mark .asyncio
229224 @pytest .mark .parametrize ("test_db" , ["sqlite" , "postgres" ], indirect = True )
230- async def test_poll_logs_descending_raises_error (
231- self , test_db , session : AsyncSession , tmp_path : Path
232- ):
233- project = await create_project (session = session )
234- log_storage = FileLogStorage (tmp_path )
235-
236- # Test that descending=True raises LogStorageError
237- poll_request = PollLogsRequest (
238- run_name = "test_run" ,
239- job_submission_id = UUID ("1b0e1b45-2f8c-4ab6-8010-a0d1a3e44e0e" ),
240- limit = 10 ,
241- diagnose = True ,
242- # Note: This bypasses schema validation for testing the implementation
243- )
244- poll_request .descending = True # Set directly to bypass validation
245-
246- with pytest .raises (LogStorageError , match = "descending: true is not supported" ):
247- log_storage .poll_logs (project , poll_request )
248-
249- @pytest .mark .asyncio
250- @pytest .mark .parametrize ("test_db" , ["sqlite" , "postgres" ], indirect = True )
251- async def test_poll_logs_file_not_found_raises_error (
225+ async def test_poll_logs_file_not_found_raises_no_error (
252226 self , test_db , session : AsyncSession , tmp_path : Path
253227 ):
254228 project = await create_project (session = session )
@@ -261,11 +235,7 @@ async def test_poll_logs_file_not_found_raises_error(
261235 limit = 10 ,
262236 diagnose = True ,
263237 )
264-
265- with pytest .raises (
266- LogStorageError , match = "Failed to read log file .* No such file or directory"
267- ):
268- log_storage .poll_logs (project , poll_request )
238+ log_storage .poll_logs (project , poll_request )
269239
270240 @pytest .mark .asyncio
271241 @pytest .mark .parametrize ("test_db" , ["sqlite" , "postgres" ], indirect = True )
0 commit comments