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

chore(ci): convert flask_sqli benchmark to use Flask test client instead of gunicorn #9253

Merged
merged 4 commits into from
May 14, 2024

Conversation

brettlangdon
Copy link
Member

@brettlangdon brettlangdon commented May 13, 2024

Follow up from #8902 to also convert the flask_sqli benchmark to using the Flask test client instead of gunicorn.

This cuts the benchmark runtime from 25min to 5min.

We should be testing the same code paths, but we avoid the need to spin up a subprocess/server and make network requests to it.

We also refactored some common bits from both flask_simple and flask_sqli to ensure we are configuring them the same way.

This will look like a performance improvement, but it isn't. It is the test itself getting faster.

Checklist

  • Change(s) are motivated and described in the PR description
  • Testing strategy is described if automated tests are not included in the PR
  • Risks are described (performance impact, potential for breakage, maintainability)
  • Change is maintainable (easy to change, telemetry, documentation)
  • Library release note guidelines are followed or label changelog/no-changelog is set
  • Documentation is included (in-code, generated user docs, public corp docs)
  • Backport labels are set (if applicable)
  • If this PR changes the public interface, I've notified @DataDog/apm-tees.

Reviewer Checklist

  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Description motivates each change
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Change is maintainable (easy to change, telemetry, documentation)
  • Release note makes sense to a user of the library
  • Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

@brettlangdon brettlangdon added the changelog/no-changelog A changelog entry is not required for this PR. label May 13, 2024
@brettlangdon brettlangdon requested a review from a team May 13, 2024 19:56
@brettlangdon brettlangdon requested a review from a team as a code owner May 13, 2024 19:56
@brettlangdon brettlangdon enabled auto-merge (squash) May 13, 2024 19:57
@datadog-dd-trace-py-rkomorn
Copy link

Datadog Report

Branch report: brettlangdon/slimline.flask_sqli
Commit report: 04a9d4c
Test service: dd-trace-py

❌ 162 Failed (0 Known Flaky), 157851 Passed, 3048 Skipped, 3h 53m 55.32s Total duration (18m 13.69s time saved)
❄️ 217 New Flaky

❌ Failed Tests (162)

This report shows up to 5 failed tests.

  • test_flask_processexec_subprocesscommunicateshell[flask_appsec_good_rules_env] - test_appsec_flask_snapshot.py - Details

    Expand for error
     [Errno 111] Connection refused
    
  • test_elasticsearch7 - test_async.py - Details

    Expand for error
     [Errno 111] Connection refused
    
  • test_django_iast_enabled_full_sqli_http_path_parameter - test_django_appsec_iast.py - Details

    Expand for error
     connection to server at "127.0.0.1", port 5432 failed: Connection refused
     	Is the server running on that host and accepting TCP/IP connections?
     
    
  • test_django_tainted_iast_disabled_sqli_http_cookies_name - test_django_appsec_iast.py - Details

    Expand for error
     connection to server at "127.0.0.1", port 5432 failed: Connection refused
     	Is the server running on that host and accepting TCP/IP connections?
     
    
  • test_django_tainted_iast_disabled_sqli_http_cookies_value - test_django_appsec_iast.py - Details

    Expand for error
     connection to server at "127.0.0.1", port 5432 failed: Connection refused
     	Is the server running on that host and accepting TCP/IP connections?
     
    

New Flaky Tests (217)

  • test_and_emit_get_version - test_aiohttp_jinja2_patch.py - Last Failure

    Expand for error
     Subprocess Test "python -m unittest tests.contrib.aiohttp_jinja2.test_aiohttp_jinja2_patch.TestAiohttp_Jinja2Patch.test_and_emit_get_version" Failed
    
  • test_template_rendering_snapshot - test_aiohttp_jinja2.py - Last Failure

    Expand for error
     Could not connect to test agent: [Errno 111] Connection refused
    
  • test_template_rendering_snapshot_patched_server[True] - test_aiohttp_jinja2.py - Last Failure

    Expand for error
     Could not connect to test agent: [Errno 111] Connection refused
    
  • test_flask_ipblock_match_403[flask_appsec_good_rules_env] - test_appsec_flask_snapshot.py - Last Failure

    Expand for error
     Could not connect to test agent: [Errno 111] Connection refused
    
  • test_flask_ipblock_match_403[flask_appsec_good_rules_env] - test_appsec_flask_snapshot.py - Last Failure

    Expand for error
     Could not connect to test agent: [Errno 111] Connection refused
    

benchmarks/bm/flask_utils.py Dismissed Show dismissed Hide dismissed
benchmarks/bm/flask_utils.py Dismissed Show dismissed Hide dismissed
@pr-commenter
Copy link

pr-commenter bot commented May 13, 2024

Benchmarks

Benchmark execution time: 2024-05-14 12:37:24

Comparing candidate commit 5bff0c8 in PR branch brettlangdon/slimline.flask_sqli with baseline commit ab86515 in branch main.

Found 8 performance improvements and 0 performance regressions! Performance is the same for 167 metrics, 9 unstable metrics.

scenario:flasksqli-appsec-enabled

  • 🟩 execution_time [-2.399s; -2.393s] or [-100.028%; -99.793%]
  • 🟩 max_rss_usage [-21.709MB; -21.633MB] or [-39.361%; -39.225%]

scenario:flasksqli-baseline

  • 🟩 execution_time [-1.713s; -1.708s] or [-100.128%; -99.801%]
  • 🟩 max_rss_usage [-5.203MB; -5.128MB] or [-13.556%; -13.362%]

scenario:flasksqli-iast-enabled

  • 🟩 execution_time [-2.396s; -2.391s] or [-100.013%; -99.808%]
  • 🟩 max_rss_usage [-20.150MB; -20.066MB] or [-36.849%; -36.695%]

scenario:flasksqli-tracer-enabled

  • 🟩 execution_time [-2.407s; -2.394s] or [-100.175%; -99.647%]
  • 🟩 max_rss_usage [-21.671MB; -21.614MB] or [-39.305%; -39.201%]

@brettlangdon brettlangdon merged commit cee0c7b into main May 14, 2024
52 of 53 checks passed
@brettlangdon brettlangdon deleted the brettlangdon/slimline.flask_sqli branch May 14, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants