Problem/Motivation

A test that creates a user and logs in will issue 3 HTTP requests:

  • GET to the login form
  • POST to submit the login form
  • GET to the user profile page

$this->drupalLogin is called thousands of times. This leads to a significant number of HTTP requests.

Instead, we can use the one-time login link, and reduce this to 2 HTTP requests per login:

  • GET to the one-time login path
  • GET to the user profile page

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3469309

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mstrelan created an issue. See original summary.

mstrelan’s picture

Status: Active » Needs work

Locally I have \Drupal\Tests\block_content\Functional\BlockContentListTest passing but it looks like there are lots of fails in other tests.

mstrelan’s picture

Status: Needs work » Needs review

Well that was fun. There are three tests remaining that use the login form. One is the UserLoginTest, so we need to keep that. The other two seem to be oddities that could probably be fixed, perhaps in a followup.

It's hard to evaluate if this is overall faster than before because there is such variability in the test suite times. I did see one run that was under five minutes. In my local testing I found a saving of around 200ms per login. So that's roughly 5 mins total savings over 1500 logins.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs followup

Follow ups appear to be mentioned in the threads.

mstrelan’s picture

Status: Needs work » Needs review
Issue tags: -Needs followup
  • Remove the duplicate ::userPassResetUrl method and updated the existing user_pass_reset_url function to use current time as discussed with @catch in Slack.
  • Updated UserLoginTest::testLoginCacheTagsAndDestination to explicitly submit the login form instead of relying on ::drupalLogin
  • Added #3471101: Further improve user login in tests (Follow up for #3469309)
smustgrave’s picture

So have re-ran twice and keep getting failures, but not entirely sure why.

mstrelan’s picture

HEAD was broken. Have rebased and it's green again.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Nice. Believe feedback has been addressed. The one thread wasn't sure about

moshe weitzman’s picture

LGTM.

  • nod_ committed 332f671c on 10.3.x
    Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time...

  • nod_ committed b16714a9 on 10.4.x
    Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time...

  • nod_ committed 39f2b9f4 on 11.0.x
    Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time...

  • nod_ committed bf4ae811 on 11.x
    Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time...
nod_’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed bf4ae81164 to 11.x and 39f2b9f40b to 11.0.x and b16714a919 to 10.4.x and 332f671c2d to 10.3.x. Thanks!

nod_’s picture

Version: 10.3.x-dev » 11.0.x-dev
Status: Fixed » Patch (to be ported)

LocaleTranslationUiTest fails on 11.0.x, 10.4.x, and 10.3.x

  • nod_ committed bff52f8e on 10.3.x
    Revert "Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-...

  • nod_ committed 80a680c5 on 10.4.x
    Revert "Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-...

  • nod_ committed 4937fac6 on 11.0.x
    Revert "Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-...
mstrelan’s picture

We can probably add

protected bool $useOneTimeLoginLinks = FALSE;

to the failing test.

mstrelan’s picture

Status: Patch (to be ported) » Needs review

Added MR for 11.0.x

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

11.0 appears to be passing

Was confused for a second why 11.0 but see that 11.x wasn't reverted

  • nod_ committed 47614c47 on 10.3.x
    Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time...

  • nod_ committed b868899b on 10.4.x
    Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time...

  • nod_ committed 104f8285 on 11.0.x
    Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time...
nod_’s picture

Version: 11.0.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 104f82857d to 11.0.x and b868899be1 to 10.4.x and 47614c4759 to 10.3.x. Thanks!

daffie’s picture

Version: 10.3.x-dev » 11.x-dev
Priority: Normal » Critical
Status: Fixed » Needs work

LocaleTranslationUiTest fails on 11.x with PostgreSQL!

Setting the priority to critical.

mstrelan’s picture

I won't get to this for a bit, but see #17 and 21 and apply this to 11.x, it was already applied to the other branches.

  • catch committed 9258113b on 11.x authored by nod_
    Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time...
catch’s picture

Status: Needs work » Fixed

I've cherry-picked 104f8285 forwards to 11.x, tentatively marking fixed but please re-open if there's still a problem.

joachim’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.