-
-
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
Issue: junit-team#2816 Signed-off-by: yongjunhong <kevin0928@naver.com>
Issue: junit-team#2816 Signed-off-by: yongjunhong <kevin0928@naver.com>
Issue: junit-team#2816
Issue: junit-team#2816
Issue: junit-team#2816 Signed-off-by: yongjunhong <kevin0928@naver.com>
Issue: junit-team#2816
Issue: junit-team#2816
This reverts commit 4de6db8.
Issue: junit-team#2816
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
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.platform.engine; |
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.
Can we move this to the same packaged as NamespacedHierarchicalStore
?
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 9fd6fd8 !
@@ -59,6 +65,8 @@ class DefaultLauncher implements Launcher { | |||
"PostDiscoveryFilter array must not contain null elements"); | |||
this.discoveryOrchestrator = new EngineDiscoveryOrchestrator(testEngines, | |||
unmodifiableCollection(postDiscoveryFilters), listenerRegistry.launcherDiscoveryListeners); | |||
this.launcherSession = LauncherFactory.openSession(config); |
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.
We should not open a session here but pass in the sessionStore
to the constructor.
@@ -43,6 +45,7 @@ public void close() { | |||
private final LauncherInterceptor interceptor; | |||
private final LauncherSessionListener listener; | |||
private final DelegatingLauncher launcher; | |||
private final NamespacedHierarchicalStore<Namespace> store; | |||
|
|||
DefaultLauncherSession(List<LauncherInterceptor> interceptors, Supplier<LauncherSessionListener> listenerSupplier, | |||
Supplier<Launcher> launcherSupplier) { |
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 probably needs to be changed to the following:
Supplier<Launcher> launcherSupplier) { | |
Function<NamespacedHierarchicalStore<Namespace>, Launcher> launcherFactory) { |
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'm curious about the reason for changing from Supplier
to Function
.
Also, I'd like to understand the purpose of this variable.
More specifically, what kind of value is intended to be generated through the apply
method?
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 to make creating the Launcher
lazy so it can be intercepted (see else
branch below).
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.
Since it now needs to be passed the session-level store to its constructor, I think we'll need to pass that in.
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.
Based on the comments you left on the PR and the comments in the issue, I've made some progress on the implementation.
- Provide mechanism for managing resources across engines and executions #2816 (comment)
- Provide mechanism for managing resources across engines and executions #2816 (comment)
I've marked the parts where I'm still unsure about how to pass things with TODOs
.
Thanks to your help, I'm starting to get a better understanding. I'll keep working hard. Thank you!
…Namespace.java Co-authored-by: Marc Philipp <mail@marcphilipp.de>
…her/core/DefaultLauncherSession.java Co-authored-by: Marc Philipp <mail@marcphilipp.de>
@Override | ||
public Store getSessionLevelStore() { | ||
return getStore(Namespace.create("session")); | ||
} | ||
|
||
@Override | ||
public Store getRequestLevelStore() { | ||
return getStore(Namespace.create("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.
Is this the correct approach to creating session and request stores?
I understand that a Namespace
is distinguished based on its name. However, I'm not sure if it's appropriate to create a Namespace
by directly using the names of the session
and 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.
No, the namespace is an orthogonal concept here. Instead these methods should take a Namespace
parameter. Sorry for omitting that in #2816 (comment)! They should return an adapted (they use a different Namespace
type and Store
interface) version of the NamespacedHierarchicalStore
objects passed to the Jupiter engine. Please let me know if I should provide more details.
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.
Sorry for omitting that in #2816 (comment)!
No, I think I should have asked earlier. 🥹
No, the namespace is an orthogonal concept here.
May I ask about the concept of Namespace
?
Also, how does the Namespace
in jupiter.api.extension
differ from the one I created?
A more overall detailed explanation would be really helpful for my understanding. 🙂
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 studied on my own and found some answers.
Namespace
is used to define the scope of data within a Store
.
From what I understand, Jupiter uses a different Store
, which is why it also requires a different type of Namespace
. And as you suggested, I’ve modified the method to take Namespace
as a parameter. Please review it when you have a chance. 5d2c2b8
However, I still don’t fully understand the NamespacedHierarchicalStore
that is passed to the Jupiter engine.
Utilizing the request-level store in JupiterEngineExtensionContext
I expect this to be related to the following steps outlined in the ReadMe.
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.
Namespace
is used to define the scope of data within aStore
.
That's correct. The original intention was that Jupiter extensions could store data in the Store
without worrying about unintended side-effects (for example, another extension storing something else under the same key) while also allowing extensions to share state by using the same Namespace
on purpose.
From what I understand, Jupiter uses a different
Store
, which is why it also requires a different type ofNamespace
.
That's correct, but Jupiter's implementation uses NamespacedHierarchicalStore
internally.
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 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.
ExecutionRequest
is still using the wrongNamespacedHierarchicalStore
, though, and I didn't add any tests.
I’ll take care of that task myself!
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.
ExecutionRequest
is still using the wrongNamespacedHierarchicalStore
First, I decided to modify the NamespacedHierarchicalStore
in ExecutionRequest
and then implement test cases.
ExecutionRequest
is created by the EngineExecutionOrchestrator
initialized by the Launcher
. At this time, the store in ExecutionRequest
serves as a request-level storage.
Accordingly, I implemented it so that ExecutionRequest
receives the RequestLevelStore
created in DefaultLauncher
. 6b4ee03
e71438b
to
c9d5ac0
Compare
c9d5ac0
to
7d98e9a
Compare
@@ -63,6 +65,8 @@ | |||
@API(status = STABLE, since = "1.0") | |||
public class LauncherFactory { | |||
|
|||
private static final NamespacedHierarchicalStore<Namespace> SESSION_STORE = new NamespacedHierarchicalStore<>(null); |
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.
After much consideration, I’ve decided to focus on the Launcher
part first.
To proceed, I need feedback on how LauncherFactory
creates Launcher
and LauncherSession
.
My current approach is as follows:
LauncherFactory
creates a session-level store and passes it to Launcher
, setting it as the parent store for the request-level store.
And, LauncherSession
receives the session-level store.
I’d like to know if this approach makes sense and whether the code is appropriate. I’d appreciate your feedback!
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.
Since the stores need to be closed, we need to attach them to the LauncherSession
. I pushed 60f66f5 to illustrate what I mean.
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.
That was exactly the approach I had in mind!
Thank you so much. 🙇🏻
...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
@Override | ||
public NamespacedHierarchicalStore<Namespace> getStore() { | ||
return store; | ||
} |
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.
@Override | |
public NamespacedHierarchicalStore<Namespace> getStore() { | |
return store; | |
} | |
@Override | |
public NamespacedHierarchicalStore<Namespace> getSessionLevelStore() { | |
return sessionLevelStore; | |
} |
WDYT?
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'm torn. On one hand that would make it more consistent, on the other hand, what else should it be? 🤔
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.
The store in DefaultLauncherSession
is only used for creating the Launcher
.
So, setting it as store
would be fine, but for consistency, I set it as sessionLevelStore
.
Hmm... I can't think of any other approach at the moment. 😬
For now, shall we put this on hold and decide once we have a clearer answer?
private final NamespacedHierarchicalStore<Namespace> store = new NamespacedHierarchicalStore<>(null, | ||
closeAutoCloseables()); |
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.
private final NamespacedHierarchicalStore<Namespace> store = new NamespacedHierarchicalStore<>(null, | |
closeAutoCloseables()); | |
private final NamespacedHierarchicalStore<Namespace> sessionLevelStore = new NamespacedHierarchicalStore<>(null, | |
closeAutoCloseables()); |
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.
Ditto
@@ -47,4 +49,6 @@ public interface LauncherSession extends AutoCloseable { | |||
@Override | |||
void close(); | |||
|
|||
NamespacedHierarchicalStore<Namespace> getStore(); |
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.
NamespacedHierarchicalStore<Namespace> getStore(); | |
NamespacedHierarchicalStore<Namespace> 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.
Ditto
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. 👍🏻 |
Resolves #2816
Overview
EngineDiscoveryRequest and TestPlanExecutionRequestI hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations