Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[action] [PR:15296] feat: optimise log_rotate for modular chassis #15302

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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
24 changes: 22 additions & 2 deletions tests/common/plugins/loganalyzer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,24 @@ def analyze_logs(analyzers, markers, node=None, results=None, fail_test=True, st
dut_analyzer.analyze(markers[node.hostname], fail_test, store_la_logs=store_la_logs)


@pytest.fixture(scope="module")
def log_rotate_modular_chassis(duthosts, request):
# The process of logrotate will take up to 2 minutes each test for modular chassis.
# This will add-up as the number of tests we have. As a result for modular chassis we want to run logrotate
# as "module" scope instead of "function" scope.
if request.config.getoption("--disable_loganalyzer") or "disable_loganalyzer" in request.keywords:
return

is_modular_chassis = duthosts[0].get_facts().get("modular_chassis")

if not is_modular_chassis:
return

parallel_run(analyzer_logrotate, [], {}, duthosts, timeout=120)


@pytest.fixture(autouse=True)
def loganalyzer(duthosts, request):
def loganalyzer(duthosts, request, log_rotate_modular_chassis):
if request.config.getoption("--disable_loganalyzer") or "disable_loganalyzer" in request.keywords:
logging.info("Log analyzer is disabled")
yield
Expand All @@ -57,7 +73,11 @@ def loganalyzer(duthosts, request):
store_la_logs = request.config.getoption("--store_la_logs")
analyzers = {}
should_rotate_log = request.config.getoption("--loganalyzer_rotate_logs")
if should_rotate_log:
is_modular_chassis = duthosts[0].get_facts().get("modular_chassis")

# We make sure only run logrotate as "function" scope for non-modular chassis for optimisation purpose.
# For modular chassis please refer to "log_rotate_modular_chassis" fixture
if should_rotate_log and not is_modular_chassis:
parallel_run(analyzer_logrotate, [], {}, duthosts, timeout=120)
for duthost in duthosts:
analyzer = LogAnalyzer(ansible_host=duthost, marker_prefix=request.node.name)
Expand Down
Loading