Skip to content

Commit

Permalink
FEATURE: implement speed-run mode for testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
skurfuerst committed Aug 31, 2022
1 parent 19ea5f3 commit 684ab43
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIdentifier;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIdentifiers;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath;
use Neos\ContentRepositoryRegistry\Factory\ProjectionCatchUpTrigger\CatchUpTriggerWithSynchronousOption;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\ContentRepository\Core\NodeType\NodeTypeConstraintParser;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraints;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamIdentifier;
Expand Down Expand Up @@ -174,6 +174,10 @@ protected function setupEventSourcedTrait(bool $alwaysRunCrSetup = false)
$this->nodeAuthorizationService = $this->getObjectManager()->get(AuthorizationService::class);
$this->contentRepositoryIdentifier = ContentRepositoryIdentifier::fromString('default');

if (getenv('CATCHUPTRIGGER_ENABLE_SYNCHRONOUS_OPTION')) {
CatchUpTriggerWithSynchronousOption::enableSynchonityForSpeedingUpTesting();
}

// prepare race tracking for debugging into the race log
if (class_exists(RedisInterleavingLogger::class)) { // the class must exist (the package loaded)
$raceConditionTrackerConfig = $this->getObjectManager()->get(ConfigurationManager::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ class CatchUpTriggerWithSynchronousOption implements ProjectionCatchUpTriggerInt

private static bool $synchronousEnabled = false;

/**
* INTERNAL
*/
public static function enableSynchonityForSpeedingUpTesting(): void
{
self::$synchronousEnabled = true;
}

public static function synchronously(\Closure $fn): void
{
$previousValue = self::$synchronousEnabled;
Expand Down
11 changes: 10 additions & 1 deletion Readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,13 @@ we use the right versions etc).
.. code-block:: bash
pushd Packages/Neos/Neos.ContentRepository.BehavioralTests/Tests/Behavior
../../../../../bin/behat -c behat.yml.dist Features/
popd
# To run tests in speed mode, run CATCHUPTRIGGER_ENABLE_SYNCHRONOUS_OPTION=1
CATCHUPTRIGGER_ENABLE_SYNCHRONOUS_OPTION=1 ../../../../../bin/behat -c behat.yml.dist Features/
popd
Alternatively, if you want to reproduce errors as they happen inside the CI system, but you
develop on Mac OS, you might want to run the Behat tests in a Docker container (= a linux environment)
Expand All @@ -193,5 +197,10 @@ described below also makes it easy to run the race-condition-detector:
# the following commands now run INSIDE the Neos docker container:
FLOW_CONTEXT=Testing/Behat ../../../../../flow raceConditionTracker:reset
../../../../../bin/behat -c behat.yml.dist
# To run tests in speed mode, run CATCHUPTRIGGER_ENABLE_SYNCHRONOUS_OPTION=1
CATCHUPTRIGGER_ENABLE_SYNCHRONOUS_OPTION=1 ../../../../../bin/behat -c behat.yml.dist
FLOW_CONTEXT=Testing/Behat ../../../../../flow raceConditionTracker:analyzeTrace

0 comments on commit 684ab43

Please sign in to comment.