Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Speed up Behat tests #4750

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading