Skip to content

Commit

Permalink
Update log_analysis_report_test.py
Browse files Browse the repository at this point in the history
  • Loading branch information
droideck committed Jan 7, 2025
1 parent a736ace commit f723c64
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion dirsrvtests/tests/suites/replication/log_analysis_report_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,28 @@ def verify_html_report(filepath: str, summary: dict) -> None:
max_lag_str = str(round(summary['maximum_lag'], 3))
assert max_lag_str in content or str(round(float(max_lag_str), 2)) in content


def verify_summary_json(filepath: str) -> None:
"""Verify summary JSON contents"""
with open(filepath, 'r') as f:
data = json.load(f)

assert 'analysis_summary' in data, "Missing analysis summary
assert 'analysis_summary' in data, "Missing analysis summary"
summary = data['analysis_summary']

required_fields = [
'total_servers', 'analyzed_logs', 'total_updates',
'average_lag', 'maximum_lag', 'minimum_lag', 'updates_by_suffix'
]
assert all(field in summary for field in required_fields)

# Verify value constraints
assert summary['minimum_lag'] >= 0, "Negative minimum lag"
assert summary['maximum_lag'] >= summary['minimum_lag'], "Invalid maximum lag"
assert (summary['average_lag'] >= summary['minimum_lag'] and
summary['average_lag'] <= summary['maximum_lag']), "Invalid average lag"

if __name__ == '__main__':
CURRENT_FILE = os.path.realpath(__file__)
pytest.main(["-s", CURRENT_FILE])

0 comments on commit f723c64

Please sign in to comment.