Skip to content

Commit

Permalink
Merge pull request #4750 from mhsdesign/task/speedupBehavioralTestByN…
Browse files Browse the repository at this point in the history
…inetyThreePercent

TASK: Speed up Behat tests
  • Loading branch information
mhsdesign authored Nov 18, 2023
2 parents 3a37216 + 0505bb2 commit 8aa5ee9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ trait CRBehavioralTestsSubjectProvider
* A runtime cache of all content repositories already set up, represented by their ID
* @var array<ContentRepositoryId>
*/
protected array $alreadySetUpContentRepositories = [];
protected static array $alreadySetUpContentRepositories = [];

protected ?ContentRepository $currentContentRepository = null;

Expand Down Expand Up @@ -169,8 +169,9 @@ protected function setUpContentRepository(ContentRepositoryId $contentRepository
* Catch Up process and the testcase reset.
*/
$contentRepository = $this->createContentRepository($contentRepositoryId);
if (!in_array($contentRepository->id, $this->alreadySetUpContentRepositories)) {
if (!in_array($contentRepository->id, self::$alreadySetUpContentRepositories)) {
$contentRepository->setUp();
self::$alreadySetUpContentRepositories[] = $contentRepository->id;
}
/** @var EventStoreInterface $eventStore */
$eventStore = (new \ReflectionClass($contentRepository))->getProperty('eventStore')->getValue($contentRepository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,13 @@ trait CRTestSuiteTrait
use WorkspaceDiscarding;
use WorkspacePublishing;

protected function setupCRTestSuiteTrait(bool $alwaysRunCrSetup = false): void
protected function setupCRTestSuiteTrait(): void
{
if (getenv('CATCHUPTRIGGER_ENABLE_SYNCHRONOUS_OPTION')) {
CatchUpTriggerWithSynchronousOption::enableSynchronicityForSpeedingUpTesting();
}
}

private static bool $wasContentRepositorySetupCalled = false;

/**
* @BeforeScenario
* @throws \Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait CRRegistrySubjectProvider
/**
* @var array<ContentRepositoryId>
*/
protected array $alreadySetUpContentRepositories = [];
protected static array $alreadySetUpContentRepositories = [];

/**
* @template T of object
Expand Down Expand Up @@ -62,8 +62,9 @@ public function iInitializeContentRepository(string $contentRepositoryId): void
$eventTableName = sprintf('cr_%s_events', $contentRepositoryId);
$databaseConnection->executeStatement('TRUNCATE ' . $eventTableName);

if (!in_array($contentRepository->id, $this->alreadySetUpContentRepositories)) {
if (!in_array($contentRepository->id, self::$alreadySetUpContentRepositories)) {
$contentRepository->setUp();
self::$alreadySetUpContentRepositories[] = $contentRepository->id;
}
$contentRepository->resetProjectionStates();
}
Expand Down
6 changes: 6 additions & 0 deletions Neos.ContentRepositoryRegistry/Configuration/Settings.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Neos:
Flow:
persistence:
doctrine:
migrations:
ignoredTables:
'cr_.*': true

# Improve debug output for node objects by ignoring large classes
error:
debugger:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/

use Behat\Behat\Context\Context as BehatContext;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Neos\Behat\FlowBootstrapTrait;
use Neos\Behat\FlowEntitiesTrait;
use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\CRBehavioralTestsSubjectProvider;
Expand Down Expand Up @@ -50,7 +49,7 @@ public function __construct()
$this->environment = $this->getObject(Environment::class);
$this->contentRepositoryRegistry = $this->getObject(ContentRepositoryRegistry::class);

$this->setupCRTestSuiteTrait(true);
$this->setupCRTestSuiteTrait();
}

/*
Expand All @@ -63,7 +62,7 @@ public function __construct()
/**
* @BeforeScenario
*/
public function resetContentRepositoryComponents(BeforeScenarioScope $scope): void
public function resetContentRepositoryComponents(): void
{
GherkinTableNodeBasedContentDimensionSourceFactory::reset();
GherkinPyStringNodeBasedNodeTypeManagerFactory::reset();
Expand All @@ -74,9 +73,6 @@ public function resetContentRepositoryComponents(BeforeScenarioScope $scope): vo
*/
public function resetPersistenceManagerAndFeedbackCollection()
{
// FIXME: we have some strange race condition between the scenarios; my theory is that
// somehow projectors still run in the background when we start from scratch...
sleep(2);
$this->getObject(\Neos\Flow\Persistence\PersistenceManagerInterface::class)->clearState();
// FIXME: FeedbackCollection is a really ugly, hacky SINGLETON; so it needs to be RESET!
$this->getObject(\Neos\Neos\Ui\Domain\Model\FeedbackCollection::class)->reset();
Expand Down

0 comments on commit 8aa5ee9

Please sign in to comment.