Problem/Motivation

Drupal\KernelTests\Core\Entity\ConfigEntityQueryTest::testCaseSensitivity can randomly fail.

1) Drupal\KernelTests\Core\Entity\ConfigEntityQueryTest::testCaseSensitivity
Failed asserting that 4 is identical to 3.

https://www.drupal.org/pift-ci-job/1508229

This is because entities with a label containing the word 'test' (e.g. '12test78') are occasionally generated.

$entity = ConfigQueryTest::create([
  'label' => $this->randomMachineName(),
  'id' => '1',
  'number' => 31,
  'array' => $array,
]);
// Filter by label with a known containing case-sensitive word.
$this->queryResults = $this->entityStorage->getQuery()
  ->condition('label', 'TEST', 'CONTAINS')
  ->execute();
$this->assertResults(['3', '4', '5']);

Proposed resolution

Use something like 'entity_1' 'entity_2'... as each label.

Comments

Krzysztof Domański created an issue. See original summary.

krzysztof domański’s picture

Status: Active » Needs review
StatusFileSize
new2.92 KB
new1.14 KB

The last submitted patch, 2: 3101130-test-only.patch, failed testing. View results

spokje’s picture

Status: Needs review » Reviewed & tested by the community

Simple patch, probably much harder to find out where this (former) random test failure came from.

Nice catch, RTBC for me!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Well there are quite a few other uses of $this->randomMachineName() in this test. I'd remove them all an hardcode something like 'entity_1' 'entity_2'... as each label

krzysztof domański’s picture

Issue tags: +Novice
mradcliffe’s picture

I am triaging this task and I think that this is still a Novice issue. I added the Needs issue summary update to update Proposed resolution with the suggestion by @alexpott in #5.

SpringbokAgency’s picture

Assigned: Unassigned » SpringbokAgency
SpringbokAgency’s picture

Assigned: SpringbokAgency » Unassigned
Status: Needs work » Needs review
StatusFileSize
new3.04 KB

Something like this? I replaced all uses of $this->randomMachineName() as suggested in comment #5.

Test summary
------------

Drupal\KernelTests\Core\Entity\ConfigEntityQueryTest           8 passes

Test run duration: 1 min 25 sec
rakesh.gectcr’s picture

@DukeandGrace Thanks for contributing, Please add the interdiff, So that will be easy for the reviewers to review your patches.

Please see how to make interdiff https://www.drupal.org/documentation/git/interdiff

SpringbokAgency’s picture

StatusFileSize
new2.93 KB
krzysztof domański’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update +GCPoland2020, +ContributionWeekend2020
krzysztof domański’s picture

Status: Needs review » Reviewed & tested by the community

Maybe it's better to use config_entity_ but IMHO entity_ also looks good.

$entity = ConfigQueryTest::create([
  'label' => 'config_entity_1',
  'id' => '1',
  'number' => 31,
  'array' => $array,
]);
alexpott’s picture

Version: 8.9.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 45b3d06dce to 9.0.x and 9067d423cd to 8.9.x and c435596c6f to 8.8.x. Thanks!

Backported to 8.8.x as a test-only change.

  • alexpott committed 45b3d06 on 9.0.x
    Issue #3101130 by Krzysztof Domański, DukeandGrace:...

  • alexpott committed 9067d42 on 8.9.x
    Issue #3101130 by Krzysztof Domański, DukeandGrace:...

  • alexpott committed c435596 on 8.8.x
    Issue #3101130 by Krzysztof Domański, DukeandGrace:...
krzysztof domański’s picture

Issue tags: -GCPoland2020 +GCWPoland2020

Status: Fixed » Closed (fixed)

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

xjm’s picture