-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Provide mechanism for managing resources across engines and executions #4281
base: main
Are you sure you want to change the base?
Conversation
f6fe9f1
to
02ef45b
Compare
I’ve drafted an initial version 02ef45b , but I think there’s still a lot of room for improvement. Even though I’ve been studying, I find it quite challenging. PS. While resolving a git conflict, I accidentally included the commit history from the main branch, So i create a new PR 😁 |
I think you must be very busy with the release of version 5.12 M1. |
I think I sounded a bit too weak.
|
* @return the store for session-level data | ||
* @since 5.13 | ||
*/ | ||
Store getSessionLevelStore(); |
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.
These also need an @API
annotation:
@API(status = EXPERIMENTAL, since = "5.13")
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.
Done in 33f5fb8
...ngine/src/main/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStore.java
Show resolved
Hide resolved
junit-platform-engine/src/main/java/org/junit/platform/engine/Namespace.java
Outdated
Show resolved
Hide resolved
junit-platform-engine/src/main/java/org/junit/platform/engine/Namespace.java
Outdated
Show resolved
Hide resolved
junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/DefaultLauncher.java
Outdated
Show resolved
Hide resolved
...platform-launcher/src/main/java/org/junit/platform/launcher/core/DefaultLauncherSession.java
Outdated
Show resolved
Hide resolved
...piter-engine/src/main/java/org/junit/jupiter/engine/descriptor/AbstractExtensionContext.java
Outdated
Show resolved
Hide resolved
c9d5ac0
to
7d98e9a
Compare
junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/LauncherFactory.java
Outdated
Show resolved
Hide resolved
...orm-launcher/src/main/java/org/junit/platform/launcher/core/EngineExecutionOrchestrator.java
Outdated
Show resolved
Hide resolved
7b47567
to
d72090c
Compare
platform-tests/src/test/java/org/junit/platform/launcher/core/DefaultLauncherTests.java
Outdated
Show resolved
Hide resolved
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.
Removing the store from the discovery process sounds like a good idea.
As the next step, I will proceed with the following task.
- Tests for Jupiter, Suite engine, EngineTestKit etc.
Thank you, Marc!
junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/DefaultLauncher.java
Show resolved
Hide resolved
...platform-launcher/src/main/java/org/junit/platform/launcher/core/DefaultLauncherSession.java
Show resolved
Hide resolved
...platform-launcher/src/main/java/org/junit/platform/launcher/core/DefaultLauncherSession.java
Show resolved
Hide resolved
junit-platform-launcher/src/main/java/org/junit/platform/launcher/LauncherSession.java
Show resolved
Hide resolved
While working on the tests, I have a question. As per your guidance, I am adding tests for Since the main focus of this PR is adding request-level and session-level stores, I am designing the tests around that. The Do you think any additional tests are needed for PS. I truly appreciate how you not only explain things but also implement the code to make communication more efficient—it’s been incredibly helpful. 👍🏻 |
...testFixtures/java/org/junit/platform/launcher/core/NamespacedHierarchicalStoreProviders.java
Outdated
Show resolved
Hide resolved
I was thinking about a very basic tests that verifies that |
Issue: junit-team#2816 Signed-off-by: yongjunhong <[email protected]>
Issue: junit-team#2816 Signed-off-by: yongjunhong <[email protected]>
Issue: junit-team#2816
Issue: junit-team#2816
Issue: junit-team#2816 Signed-off-by: yongjunhong <[email protected]>
Issue: junit-team#2816
I have a seminar presentation tomorrow, so it will be difficult for me to work on this. I will complete the work by next week or this weekend and request a review then. |
No worries! Good luck for your presentation! |
Issue: junit-team#2816
Issue: junit-team#2816
Currently, the One possible solution is to modify WDYT? |
The convention we have adopted after junit5/gradle/plugins/common/src/main/kotlin/junitbuild.testing-conventions.gradle.kts Line 67 in 0f585b2
So I'd suggest renaming |
platform-tests/src/test/java/org/junit/platform/launcher/core/LauncherFactoryTests.java
Outdated
Show resolved
Hide resolved
…LauncherFactoryTests.java Co-authored-by: Marc Philipp <[email protected]>
Done in e56946f ! |
I'm planning to move on to the documentation work. 🚀 Also, if you could recommend which part of file should be updated or where a new document should be added, that would be really helpful.
|
Issue: junit-team#2816
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.
Would it be possible to check if there's anything else that should be added to the tests?
The main thing I'm missing is integration tests that verifies AutoCloseable
objects put into the request-level store get closed after execution and those put into the session-level store get closed when the LauncherSession
is closed.
Also, if you could recommend which part of file should be updated or where a new document should be added, that would be really helpful.
We should update the usage example to store HttpServer
(or a wrapper, if necessary) in the session-level store, retrieve it from a new ParameterResolver
extension and inject it into the test rather than using system properties.
Moreover, we should add a new "Managing State Across Test Engines" subsection to JUnit Platform Launcher API where we provide an example of two test engines lazily creating and sharing a resource (maybe the same HttpServer
or a wrapper thereof as in the other example?) regardless of which is executed first.
* | ||
* @see #ClassExtensionContext(ExtensionContext, EngineExecutionListener, ClassBasedTestDescriptor, Lifecycle, JupiterConfiguration, ExtensionRegistry, LauncherStoreFacade, ThrowableCollector) | ||
*/ | ||
ClassExtensionContext(ExtensionContext parent, EngineExecutionListener engineExecutionListener, |
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.
This is unused, isn't it?
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.
It seems to be unused.
I'll remove it!
import org.apiguardian.api.API; | ||
import org.junit.platform.commons.util.Preconditions; | ||
|
||
@API(status = EXPERIMENTAL, since = "5.13") |
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.
This should be 1.13 since it's in a Platform module.
import org.junit.platform.commons.util.Preconditions; | ||
|
||
@API(status = EXPERIMENTAL, since = "5.13") | ||
public class Namespace { |
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.
Please add class-level Javadoc here.
* existing sequence of parts in this namespace. | ||
* | ||
* @return new namespace; never {@code null} | ||
* @since 5.13 |
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.
There's no need to repeat this for a method if it's identical to the class' @since
tag. Please remove it.
* @return new namespace; never {@code null} | ||
* @since 5.13 | ||
*/ | ||
@API(status = STABLE, since = "5.13") |
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.
This should also be removed to "inherit" it from the class.
static class JupiterExtensionExample implements BeforeAllCallback { | ||
@Override | ||
public void beforeAll(ExtensionContext context) { | ||
var value = context.getRoot().getStore(ExtensionContext.Namespace.GLOBAL).get("testKey"); |
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.
There should be no need to call getRoot()
here. Please also check that we can get the value from context.getSessionLevelStore(ExtensionContext.Namespace.GLOBAL)
as well.
@@ -73,11 +83,17 @@ LauncherSessionListener getListener() { | |||
public void close() { | |||
if (launcher.delegate != ClosedLauncher.INSTANCE) { | |||
launcher.delegate = ClosedLauncher.INSTANCE; | |||
store.close(); | |||
listener.launcherSessionClosed(this); |
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.
To allow the listener to read things from the store
, we should first call the listener and then close the store.
@@ -333,6 +338,29 @@ public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult | |||
})); | |||
} | |||
|
|||
@Test | |||
void extensionCanReadValueFromSessionStore() { |
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.
I think we should also test that an extension can store a value in the session-level store that can be read by a LauncherSessionListener
in launcherSessionClosed()
.
NamespacedHierarchicalStoreProviders.dummyNamespacedHierarchicalStore()); | ||
|
||
engineWriter.execute(request); | ||
engineReader.execute(request); |
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.
I think we should go through Launcher.execute
here rather than calling TestEngine.execute
directly. That way, we would also test the Launcher
's handling of the store meets our expectations.
|
||
new SuiteTestEngine().execute(request); | ||
|
||
verify(mockDescriptor).execute(listener, requestLevelStore); |
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.
I think we should make the assertion a bit stronger to avoid accidentally depending on any equals()
implementation.
verify(mockDescriptor).execute(listener, requestLevelStore); | |
verify(mockDescriptor).execute(same(listener), same(requestLevelStore)); |
Thank you so much for your detailed feedback on my work! 🙇🏻♂️🙇🏻♂️ |
Resolves #2816
Overview
EngineDiscoveryRequest and TestPlanExecutionRequestI hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations