Skip to content
Closed
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
25 changes: 25 additions & 0 deletions benchmarks/ZAP/scripts/test_zap_automation_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Guards for ZAP automation plans used by GitHub Actions.
"""

from pathlib import Path
import re


ZAP_DIR = Path(__file__).resolve().parents[1]


def _automation_value(plan_name: str, job_type: str, key: str) -> int:
plan = (ZAP_DIR / plan_name).read_text()
job_start = plan.index(f"- type: {job_type}")
next_job = plan.find("\n - type:", job_start + 1)
job = plan[job_start:] if next_job == -1 else plan[job_start:next_job]
match = re.search(rf"^\s+{re.escape(key)}:\s+(\d+)\s*$", job, re.MULTILINE)
assert match is not None
return int(match.group(1))


def test_modern_ajax_spider_browser_count_is_ci_safe():
assert _automation_value(
"zap-automation-modern.yaml", "spiderAjax", "numberOfBrowsers"
) <= 2
2 changes: 1 addition & 1 deletion benchmarks/ZAP/zap-automation-modern.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
maxDuration: 120 # minutes
maxCrawlDepth: 400
maxCrawlStates: 0 # unlimited
numberOfBrowsers: 30
numberOfBrowsers: 2
reloadWait: 8000
eventWait: 2500
browserId: firefox-headless
Expand Down