Skip to content

[DI] deprecate booting the kernel twices #32056

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

Conversation

Simperfit
Copy link
Contributor

@Simperfit Simperfit commented Jun 15, 2019

Q A
Branch? 4.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets #31233
License MIT
Doc PR ?

This adds a check to see if the kernel has been booted twices in a single test, and throw a deprecation

@nicolas-grekas nicolas-grekas added this to the 4.2 milestone Jun 15, 2019
@Simperfit Simperfit force-pushed the bugfix/throw-is-the-kernel-has-already-been-booted-in-test-before branch from 25f9522 to b849aab Compare June 17, 2019 08:41
@Koc
Copy link
Contributor

Koc commented Jun 18, 2019

This looks like BC-break

@xabbuh
Copy link
Member

xabbuh commented Jun 18, 2019

And I agree with @Koc, this has potential to break lots of tests if I don't miss anything. We could deprecate this in 4.4 though and throw in 5.0 then.

@xabbuh
Copy link
Member

xabbuh commented Jun 18, 2019

By the way, our test suite contains an example of a valid test that would fail with this change (see the failing CI jobs).

@Simperfit Simperfit changed the base branch from 4.2 to 4.4 June 19, 2019 05:37
@Simperfit Simperfit force-pushed the bugfix/throw-is-the-kernel-has-already-been-booted-in-test-before branch from b849aab to 29a08ee Compare June 19, 2019 05:38
@Simperfit
Copy link
Contributor Author

PR rebase with 4.4, tests fixed and deprecation added.

@Simperfit Simperfit force-pushed the bugfix/throw-is-the-kernel-has-already-been-booted-in-test-before branch from 29a08ee to b5aabd9 Compare June 19, 2019 05:39
@Simperfit Simperfit changed the title [DI] throw an exception when the kernel has been booted twices [DI] deprecate booting the kernel twices Jun 20, 2019
@Simperfit Simperfit force-pushed the bugfix/throw-is-the-kernel-has-already-been-booted-in-test-before branch from b5aabd9 to 905bec4 Compare June 21, 2019 20:25
@Simperfit
Copy link
Contributor Author

cc @fabpot

@fabpot
Copy link
Member

fabpot commented Jul 8, 2019

Thank you @Simperfit.

@fabpot fabpot merged commit 905bec4 into symfony:4.4 Jul 8, 2019
fabpot added a commit that referenced this pull request Jul 8, 2019
This PR was merged into the 4.4 branch.

Discussion
----------

[DI] deprecate booting the kernel twices

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | yes <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #31233   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | ? <!-- required for new features -->

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against branch 4.4.
 - Legacy code removals go to the master branch.
-->

This adds a check to see if the kernel has been booted twices in a single test, and throw a deprecation

Commits
-------

905bec4 [DI] throw an exception when the kernel has been booted twices
@teohhanhui
Copy link
Contributor

teohhanhui commented Aug 26, 2019

This means we cannot boot the kernel, set some state in a service (e.g. fixture data in memory), then create the client to test requests.

WDYT about not (re)booting the kernel if it's already booted?

Edit: Never mind. This wouldn't work as createClient takes kernel options, and we can't be sure that the already booted kernel was booted with the requested options. 😞

nicolas-grekas added a commit that referenced this pull request Oct 23, 2019
…eal one instead (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle] Don't reset the test container but the real one instead

| Q             | A
| ------------- | ---
| Branch?       | 4.4 for features / 3.4 or 4.3 for bug fixes <!-- see below -->
| Bug fix?      | yes/no
| New feature?  | yes/no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | yes/no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | -

After #31202 and #32056, the tearDown method keeps throwing deprecation notices about "Getting the container from a non-booted kernel". The reason is that resetting the test-container calls `$kernel->getContainer()` while the kernel has been shut down.

This fixes it and a few other glitches found meanwhile.

Commits
-------

8e16143 [FrameworkBundle] Dont reset the test container but the real one instead
@acasademont
Copy link
Contributor

acasademont commented Nov 21, 2019

Hi @Simperfit We just upgraded to SF 4.4 and now there's this deprecation notice, but tbh, we don't know how to fix it. The docs say that you specifically need to create 2 clients here, but this is now not allowed. Actually, doing what the docs say leads to an exception in SF 5

https://symfony.com/doc/current/testing/insulating_clients.html

What's the proper upgrade path if we need multiple clients?

@chalasr
Copy link
Member

chalasr commented Nov 22, 2019

@acasademont Please open a new issue. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants