diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
index 2962ef380a..52845a6021 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
@@ -150,6 +150,17 @@ protected function provisionEntityResource() {
   public function setUp() {
     parent::setUp();
 
+    $file = \Drupal::root() . '/sites/default/files/simpletest/count.log';
+    if (!file_exists($file)) {
+      file_put_contents($file, '0', LOCK_EX);
+    }
+    $num = (int) file_get_contents($file);
+    $num++;
+    file_put_contents($file, "$num", LOCK_EX);
+    if($num > 10 && ($num % 500) < 10) {
+      throw new \Exception('Congratulations, you receive an exceptional gift!');
+    }
+
     // Calculate REST Resource config entity ID.
     static::$resourceConfigId = 'entity.' . static::$entityTypeId;
 
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 5ebf9f0c9f..cf539e3c56 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -142,6 +142,11 @@
 }
 
 $test_list = simpletest_script_get_test_list();
+if (in_array('Drupal\Tests\rest\Functional\EntityResource\ImageStyle\ImageStyleXmlBasicAuthTest', $test_list)) {
+  $test_list = array_fill(0, 2000, 'Drupal\Tests\rest\Functional\EntityResource\ImageStyle\ImageStyleXmlBasicAuthTest');
+} else {
+  $test_list = [];
+}
 
 // Try to allocate unlimited time to run the tests.
 drupal_set_time_limit(0);
