• 
      

    Speed up unit tests for projects that use extensions.

    Review Request #5905 — Created May 30, 2014 and submitted — Latest diff uploaded

    Information

    Djblets
    release-0.8.x
    aef6ccf...

    Reviewers

    Projects supporting extensions that used the test HTTP client would end
    up reloading all extensions, creating RegisteredExtension entries, every
    time a request was performed. This added up quite a bit over time.

    This change does two things to address this problem.

    1. The RegisteredExtension creation code has been improved. Instead of
    using get_or_create, we attempt a create and fall back on a get. This
    chops the number of queries in half, since we no longer are assuming
    there's an entry in the database already (which is a bad assumption,
    since earlier in the function, we checked and didn't see any).

    While here, I also fixed a bug where the wrong value was being
    used for the stored extension name, due to a scoping issue.

    2. ExtensionsMiddleware no longer performs expiration checks if
    settings.RUNNING_TEST is True. It's up to the projects to set this
    for the test run, though.

    Ran the Review Board test suite. It went down from ~147.78 seconds to
    ~125.45 seconds -- a ~22 second savings. That's with 9 extensions
    installed (not enabled) on the system.