File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838import time
3939import uuid
4040
41- import boto3
4241import objgraph
43- import opentaskpy .otflogging
4442import psutil
4543import pytest
4644from opentaskpy .config .loader import ConfigLoader
5553)
5654os .environ ["OTF_NO_THREAD_SLEEP" ] = "1" # don't wait 1s between task thread creation
5755
56+
57+ @pytest .fixture (autouse = True )
58+ def _enforce_info_log_level ():
59+ """Ensure INFO log level during this test regardless of collection-time env overrides.
60+
61+ Other test modules set OTF_LOG_LEVEL=DEBUG at module level. Because pytest
62+ imports (collects) all modules before running any test, those assignments
63+ execute after this module's own module-level assignment and leave
64+ OTF_LOG_LEVEL=DEBUG in the environment by the time this test actually runs.
65+ Setting it here (at fixture execution time) guarantees INFO for the duration
66+ of the memory test, which prevents botocore/s3transfer from flooding the
67+ heap with DEBUG log objects and skewing the RSS measurement.
68+ """
69+ prev = os .environ .get ("OTF_LOG_LEVEL" )
70+ os .environ ["OTF_LOG_LEVEL" ] = "INFO"
71+ logging .getLogger ().setLevel (logging .INFO )
72+ logging .getLogger ("botocore" ).setLevel (logging .INFO )
73+ logging .getLogger ("s3transfer" ).setLevel (logging .INFO )
74+ yield
75+ if prev is None :
76+ os .environ .pop ("OTF_LOG_LEVEL" , None )
77+ else :
78+ os .environ ["OTF_LOG_LEVEL" ] = prev
79+
80+
5881# ---------------------------------------------------------------------------
5982# Constants
6083# ---------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments