-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
BUGFIX: Dont reset escr tables or ignored tables in general #37
BUGFIX: Dont reset escr tables or ignored tables in general #37
Conversation
b7e9ca6
to
f09b2b3
Compare
Clever idea, but I'm not sure whether it is transparent that this
With "alive" you mean, that we don't truncate them, right? |
btw: maybe the generic |
I think we are talking a bit past each other. First of:
yes this is true. But the critical point are Neos.Neos tests where we mix flow entities and neos escr things.
Yeah this is kindof true. I think flow should somehow tell which tables are managed by doctrine and which are not. This setting is the place we need to set either way so there are no
yes.
but we do that explicitly via
The point with this change is that we can setup the content repository only once for all tests Why are we going through so much hassle to (hackily) setup the cr only once? Because each projection calls For our slack discussion see link |
With this change we setup the content repository only once for all tests `$contentRepository->setUp();`. The projections contents are cleared in each iteration via `$contentRepository->resetProjectionStates();` and this works quite well for the escr core tests. For tests using the `@flowEntities` annotation and database reset we must avoid to drop all the escr tables as otherwise we would need to setup the cr again. This will be fixed in neos/behat#37. Why are we going through so much hassle to (hackily) setup the cr only once? Because each projection calls `$schemaManager->createSchema()` twice when being setup and this slows down test enormously by 80%
Flow was always of the opinion that the database is it's, as in ORM land, so no need to tell anyone, so technically we should separate the two worlds. |
Hmm yes and that made sense for a time i guess. But now flow has grown up and must allow also its siblings to play with the db ^^ Every now an then a project has already non-doctrine managed tables. And i remember also using the Another alternative would be to somehow cache the
|
And to make the thing more complex: We have the same dilemma for functional tests. The "setUp" the cr once performance optimization doesnt work here, as the (and actually with way less code than behat does ^^) |
That's what I suggest to change. Partly.
I don't think, that we have to decide between the two: But we should also try to improve the performance of the Currently we do $schemaDiff = (new Comparator())->compare($schemaManager->createSchema(), $schema);
foreach ($schemaDiff->toSaveSql($connection->getDatabasePlatform()) as $statement) {
$connection->executeStatement($statement);
} (which is deprecated with If I got it right, the problematic part is |
|
Yes that would be great. I had tunnel vision and thought that was the only way 😂 even though i knew we use |
I just fiddled a bit with the whole schema diffing, and just changing $schema = $schemaManager->createSchema(); to $schema = new Schema([$schemaManager->listTableDetails($tableName)], [], $schemaManager->createSchemaConfig()); reduced the runtime of a single instance from 0.08 s to 0.0012 s. |
That is perfect. But regarding this behat package i still think this is a clever idea to respect the "ignoredTables" so that We could also rename the option
this is easier said than done. For example we create entities at many unexpected places. The routing trait creates a site for example, but what if another trait also allows the site creation?. Using the I think for testing flow should only reset doctrine managed parts. |
Yes, I agree. It's called
No no, that was not my point :)
I don't think that this is a problem at all. Just make sure that for every step that creates an entity a corresponding
And I think, Flow should not reset anything but tests that create entities should take care of cleaning up after themselves :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's fine to go with that for now, but personally I would prefer not to use truncateAndSetupFlowEntities
in the long run
With this change we setup the content repository only once for all tests `$contentRepository->setUp();`. The projections contents are cleared in each iteration via `$contentRepository->resetProjectionStates();` and this works quite well for the escr core tests. For tests using the `@flowEntities` annotation and database reset we must avoid to drop all the escr tables as otherwise we would need to setup the cr again. This will be fixed in neos/behat#37. Why are we going through so much hassle to (hackily) setup the cr only once? Because each projection calls `$schemaManager->createSchema()` twice when being setup and this slows down test enormously by 80%
With this change we setup the content repository only once for all tests `$contentRepository->setUp();`. The projections contents are cleared in each iteration via `$contentRepository->resetProjectionStates();` and this works quite well for the escr core tests. For tests using the `@flowEntities` annotation and database reset we must avoid to drop all the escr tables as otherwise we would need to setup the cr again. This will be fixed in neos/behat#37. Why are we going through so much hassle to (hackily) setup the cr only once? Because each projection calls `$schemaManager->createSchema()` twice when being setup and this slows down test enormously by 80%
With this change we setup the content repository only once for all tests `$contentRepository->setUp();`. The projections contents are cleared in each iteration via `$contentRepository->resetProjectionStates();` and this works quite well for the escr core tests. For tests using the `@flowEntities` annotation and database reset we must avoid to drop all the escr tables as otherwise we would need to setup the cr again. This will be fixed in neos/behat#37. Why are we going through so much hassle to (hackily) setup the cr only once? Because each projection calls `$schemaManager->createSchema()` twice when being setup and this slows down test enormously by 80%
With this change we setup the content repository only once for all tests `$contentRepository->setUp();`. The projections contents are cleared in each iteration via `$contentRepository->resetProjectionStates();` and this works quite well for the escr core tests. For tests using the `@flowEntities` annotation and database reset we must avoid to drop all the escr tables as otherwise we would need to setup the cr again. This will be fixed in neos/behat#37. Why are we going through so much hassle to (hackily) setup the cr only once? Because each projection calls `$schemaManager->createSchema()` twice when being setup and this slows down test enormously by 80%
We respect flows option "ignoredTables" to preserve certain tables while resetting the database.
In our case we interpret everything in "ignoredTables" as not managed by doctrine.
And this trait should only clear tables for @flowEntities.
An important use case is keeping the Neos ESCR tables
cr_*.
alive for speeding up tests.Docs for original idea of "ignoredTables": https://flowframework.readthedocs.io/en/9.0/TheDefinitiveGuide/PartIII/Persistence.html#ignoring-tables
Implementation copied from https://github.com/neos/flow-development-collection/blob/ed6a26603f682966816c71840524c7da6ed919a5/Neos.Flow/Classes/Command/DoctrineCommandController.php#L468-L474