Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/integration/actor/test_actor_api_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ async def main_outer() -> None:
assert inner_output_record['value'] == f'{test_value}_XXX_{test_value}'


@pytest.mark.skip(reason='Known failing test, pending investigation.')
@pytest.mark.skip(reason='Requires Actor permissions beyond limited permissions, see #715.')
async def test_actor_calls_task(
make_actor: MakeActorFunction,
run_actor: RunActorFunction,
Expand Down Expand Up @@ -251,7 +251,7 @@ async def main_outer() -> None:
await apify_client_async.task(task['id']).delete()


@pytest.mark.skip(reason='Known failing test, pending investigation.')
@pytest.mark.skip(reason='Requires Actor permissions beyond limited permissions, see #715.')
async def test_actor_aborts_another_actor_run(
make_actor: MakeActorFunction,
run_actor: RunActorFunction,
Expand Down
61 changes: 21 additions & 40 deletions tests/integration/actor/test_actor_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

from typing import TYPE_CHECKING

import pytest

from apify import Actor, __version__
from apify import Actor

if TYPE_CHECKING:
from .conftest import MakeActorFunction, RunActorFunction


@pytest.mark.skip(reason='Known failing test, pending investigation.')
async def test_actor_logging(
make_actor: MakeActorFunction,
run_actor: RunActorFunction,
Expand Down Expand Up @@ -53,41 +50,25 @@ async def main() -> None:

run_log_lines = run_log.splitlines()

# This should prevent issues when the test run is migrated, and it would have its log restarted
expected_log_lines_count = 24
assert len(run_log_lines) >= expected_log_lines_count
run_log_lines = run_log_lines[-expected_log_lines_count:]

# This removes the datetime from the start of log lines
# Remove the datetime from the start of log lines
run_log_lines = [line[25:] for line in run_log_lines]

# This might be way too specific and easy to break, but let's hope not
assert run_log_lines.pop(0).startswith('ACTOR: Pulling container image of build')
assert run_log_lines.pop(0) == 'ACTOR: Creating container.'
assert run_log_lines.pop(0) == 'ACTOR: Starting container.'
assert run_log_lines.pop(0) == (
'[apify._configuration] WARN Actor is running on the Apify platform,'
' `disable_browser_sandbox` was changed to True.'
)
assert run_log_lines.pop(0).startswith(
f'[apify] INFO Initializing Actor ({{"apify_sdk_version": "{__version__}", "apify_client_version": "'
)
assert run_log_lines.pop(0) == '[apify] DEBUG Debug message'
assert run_log_lines.pop(0) == '[apify] INFO Info message'
assert run_log_lines.pop(0) == '[apify] WARN Warning message'
assert run_log_lines.pop(0) == '[apify] ERROR Error message'
assert run_log_lines.pop(0) == '[apify] ERROR Exception message'
assert run_log_lines.pop(0) == ' Traceback (most recent call last):'
assert run_log_lines.pop(0) == ' File "/usr/src/app/src/main.py", line 25, in main'
assert run_log_lines.pop(0) == " raise ValueError('Dummy ValueError')"
assert run_log_lines.pop(0) == ' ValueError: Dummy ValueError'
assert run_log_lines.pop(0) == '[apify] INFO Multi'
assert run_log_lines.pop(0) == 'line'
assert run_log_lines.pop(0) == 'log'
assert run_log_lines.pop(0) == 'message'
assert run_log_lines.pop(0) == '[apify] ERROR Actor failed with an exception'
assert run_log_lines.pop(0) == ' Traceback (most recent call last):'
assert run_log_lines.pop(0) == ' File "/usr/src/app/src/main.py", line 33, in main'
assert run_log_lines.pop(0) == " raise RuntimeError('Dummy RuntimeError')"
assert run_log_lines.pop(0) == ' RuntimeError: Dummy RuntimeError'
assert run_log_lines.pop(0) == '[apify] INFO Exiting Actor ({"exit_code": 91})'
# Join all lines to make it easier to search for expected content
full_log = '\n'.join(run_log_lines)

# Verify expected log messages are present (order-independent checks)
assert '[apify] DEBUG Debug message' in full_log
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will allow this. Honestly, I'd be fine if you just removed this test 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the logging can be problematic due to our custom configuration in Actor -> https://github.com/apify/apify-sdk-python/blob/master/src/apify/_actor.py#L169-L172 . We already had cases with log statements before configure_logging, which were supposed to log info messages, but it wasn't working, and this went unnoticed for a long time. Because of that, I would prefer to keep this test :).

assert '[apify] INFO Info message' in full_log
assert '[apify] WARN Warning message' in full_log
assert '[apify] ERROR Error message' in full_log
assert '[apify] ERROR Exception message' in full_log
assert 'ValueError: Dummy ValueError' in full_log
assert '[apify] INFO Multi' in full_log
assert '[apify] ERROR Actor failed with an exception' in full_log
assert 'RuntimeError: Dummy RuntimeError' in full_log

# Verify multiline log message is present
assert 'line\nlog\nmessage' in full_log or ('line' in full_log and 'log' in full_log and 'message' in full_log)

# Verify exit message is present
assert '[apify] INFO Exiting Actor ({"exit_code": 91})' in full_log
2 changes: 1 addition & 1 deletion tests/integration/actor/test_actor_scrapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .conftest import MakeActorFunction, RunActorFunction


@pytest.mark.skip(reason='Known failing test, pending investigation.')
@pytest.mark.skip(reason='Requires Actor permissions beyond limited permissions, see #715.')
async def test_actor_scrapy_title_spider(
make_actor: MakeActorFunction,
run_actor: RunActorFunction,
Expand Down
Loading