|
6 | 6 | # the same Cinema4DAdaptor action queue, which can cause race conditions and |
7 | 7 | # test failures when tests run in parallel across multiple workers. |
8 | 8 | import json |
| 9 | +import logging |
9 | 10 | from pathlib import Path |
10 | 11 | from unittest.mock import Mock, PropertyMock, patch |
11 | 12 |
|
@@ -364,6 +365,64 @@ def test__wait_for_socket( |
364 | 365 | # THEN |
365 | 366 | assert mock_sleep.call_count == 3 |
366 | 367 |
|
| 368 | + @pytest.mark.parametrize( |
| 369 | + "license_error", |
| 370 | + [ |
| 371 | + "17:44:34 Error running authentication: IsFloating query failed.", |
| 372 | + "17:44:34 No license found. [.(2030)]", |
| 373 | + "18:38:54 No available licenses to choose.", |
| 374 | + ], |
| 375 | + ) |
| 376 | + def test_license_failure_from_stdout_interrupts_startup( |
| 377 | + self, init_data: dict, license_error: str |
| 378 | + ) -> None: |
| 379 | + """Tests that a licensing prompt fails startup without waiting for the timeout.""" |
| 380 | + # General error checking is optional, but a licensing prompt cannot recover |
| 381 | + # without interactive input and must always stop the worker. |
| 382 | + init_data["activate_error_checking"] = "0" |
| 383 | + adaptor = Cinema4DAdaptor(init_data) |
| 384 | + expected_error = ( |
| 385 | + "Cinema 4D failed to acquire a license.\n" |
| 386 | + "If you are using bring your own license (BYOL), check your license configuration " |
| 387 | + "and availability.\n" |
| 388 | + "If you are using usage-based licensing (UBL) from AWS Deadline Cloud and need a " |
| 389 | + "higher 'License sessions per license endpoint' limit, contact the AWS Deadline Cloud " |
| 390 | + "team to request an increase.\n" |
| 391 | + f"Error: {license_error}" |
| 392 | + ) |
| 393 | + |
| 394 | + def emit_license_error(*args, **kwargs): |
| 395 | + kwargs["stdout_handler"].emit( |
| 396 | + logging.LogRecord( |
| 397 | + name="cinema4d", |
| 398 | + level=logging.ERROR, |
| 399 | + pathname="", |
| 400 | + lineno=0, |
| 401 | + msg=license_error, |
| 402 | + args=(), |
| 403 | + exc_info=None, |
| 404 | + ) |
| 405 | + ) |
| 406 | + process = Mock() |
| 407 | + process.is_running = True |
| 408 | + return process |
| 409 | + |
| 410 | + with ( |
| 411 | + patch.object(adaptor, "_initialize_maxon_assets_db_connection"), |
| 412 | + patch.object(adaptor, "_start_cinema4d_server_thread"), |
| 413 | + patch.object(adaptor, "_populate_action_queue"), |
| 414 | + patch( |
| 415 | + "deadline.cinema4d_adaptor.Cinema4DAdaptor.adaptor.LoggingSubprocess", |
| 416 | + side_effect=emit_license_error, |
| 417 | + ), |
| 418 | + patch("time.sleep") as mock_sleep, |
| 419 | + pytest.raises(RuntimeError) as exc_info, |
| 420 | + ): |
| 421 | + adaptor.on_start() |
| 422 | + |
| 423 | + assert str(exc_info.value) == expected_error |
| 424 | + mock_sleep.assert_not_called() |
| 425 | + |
367 | 426 |
|
368 | 427 | @pytest.mark.xdist_group(name="adaptor_tests") |
369 | 428 | class TestCinema4DAdaptor_on_run: |
|
0 commit comments