Problem/Motivation

Drupal\KernelTests\Core\Entity\CreateSampleEntityTest::testSampleValueContentEntity can randomly fail.

There was 1 failure:

1) Drupal\KernelTests\Core\Entity\CreateSampleEntityTest::testSampleValueContentEntity
Failed asserting that actual size 1 matches expected size 0.

/var/www/html/core/tests/Drupal/KernelTests/Core/Entity/CreateSampleEntityTest.php:81

https://www.drupal.org/pift-ci-job/1425347
https://www.drupal.org/pift-ci-job/1425317
https://www.drupal.org/pift-ci-job/1422878

77  // Create sample entities without bundles.
78  else {
79    $entity = $this->entityTypeManager->getStorage($entity_type_id)->createWithSampleValues(FALSE, $values);
80    $violations = $entity->validate();
81    $this->assertCount(0, $violations);
82    if ($label) {
83      $this->assertEquals($title, $entity->label());
84    }
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Krzysztof Domański’s picture

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

Krzysztof Domański’s picture

Debugging...

           $entity = $this->entityTypeManager->getStorage($entity_type_id)->createWithSampleValues(FALSE, $values);
           $violations = $entity->validate();
+          if (count($violations) > 0) {
+            var_dump($values);
+          }
           $this->assertCount(0, $violations);

Sometimes the $values ​​are an empty array.

Testing Drupal\KernelTests\Core\Entity\CreateSampleEntityTest
F                                                                   1 / 1 (100%)array(0) {
}


Time: 2.81 seconds, Memory: 4.00MB

There was 1 failure:

1) Drupal\KernelTests\Core\Entity\CreateSampleEntityTest::testSampleValueContentEntity
Failed asserting that actual size 1 matches expected size 0.
Krzysztof Domański’s picture

Debugging $entity_type_id.

           $entity = $this->entityTypeManager->getStorage($entity_type_id)->createWithSampleValues(FALSE, $values);
           $violations = $entity->validate();
+          if (count($violations) > 0) {
+            var_dump($entity_type_id);
+          }
           $this->assertCount(0, $violations);

This is "path_alias".

Testing Drupal\KernelTests\Core\Entity\CreateSampleEntityTest
F                                                                   1 / 1 (100%)string(10) "path_alias"


Time: 1.89 seconds, Memory: 4.00MB

There was 1 failure:

1) Drupal\KernelTests\Core\Entity\CreateSampleEntityTest::testSampleValueContentEntity
Failed asserting that actual size 1 matches expected size 0.
plach’s picture

plach’s picture

Priority: Normal » Critical

Random test failures are usually critical.

alexpott’s picture

Status: Active » Needs review
FileSize
3.41 KB

Let's see what the violation actually is.

Status: Needs review » Needs work

The last submitted patch, 7: 3086001-6.test-only.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Needs review
FileSize
2.96 KB
737 bytes

Here's a fix. It's happening because occasionally we generate a string 255 chars long and then add a character to it :)

plach’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

  • catch committed 42034e7 on 8.8.x
    Issue #3086001 by Krzysztof Domański, alexpott: CreateSampleEntityTest::...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed b541e05 and pushed to 8.8.x. Thanks!

Status: Fixed » Closed (fixed)

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

xjm’s picture