Repository navigation
Make sure Launch Bar Manager sends event at a correct time - #1486
DangMinhTam382 wants to merge 6 commits into
Conversation
|
Hi Mr. @betamaxbandit , Before making this PR official, could you take a quick look and let me know what you think? Thanks! |
17292ff to
aa7a299
Compare
DangMinhTam382
left a comment
There was a problem hiding this comment.
Hi Mr. @betamaxbandit ,
CC: Mr. @Kummallinen ,
I added some UTs and replied to your comments on this PR.
Please have a look at it again.
Also, build is failed atm with errors:
[ERROR] org.eclipse.linuxtools.docker.editor.ls 1.0.1.202609160755 requires Execution Environment that matches (&(osgi.ee=JavaSE)(version=25)) but the current resolution context uses [a.jre.javase 21.0.0]
[ERROR] Cannot resolve target definition:
[ERROR] Software being installed: org.eclipse.linuxtools.docker.feature.feature.group 5.25.0.202609160755
[ERROR] Missing requirement for filter properties ~= $0: org.eclipse.linuxtools.docker.editor.ls 1.0.1.202609160755 requires 'osgi.ee; (&(osgi.ee=JavaSE)(version=25)), filter=(!(org.eclipse.equinox.p2.disable.require.capability.osgi.ee=true))' but it could not be found
[ERROR] Cannot satisfy dependency: org.eclipse.linuxtools.docker.editor.ls.feature.feature.group 5.25.0.202609160755 depends on: org.eclipse.equinox.p2.iu; org.eclipse.linuxtools.docker.editor.ls [1.0.1.202609160755,1.0.1.202609160755]
[ERROR] Cannot satisfy dependency: org.eclipse.linuxtools.docker.feature.feature.group 5.25.0.202609160755 depends on: org.eclipse.equinox.p2.iu; org.eclipse.linuxtools.docker.editor.ls.feature.feature.group [5.25.0.202609160755,5.25.0.202609160755]
[ERROR]
Maybe something not working on the server?
Will look into this.
| * @throws InterruptedException | ||
| */ | ||
| @Test | ||
| public void launchBarStateTest_LaunchDescriptorChanged() throws CoreException, InterruptedException { |
There was a problem hiding this comment.
Hi @DangMinhTam382 ,
thanks for adding the regression test. I think this is good since you added launchBarStateTest_LaunchDescriptorChanged; it's a good test.
But not sure about launchBarStateTest_LaunchTargetChanged and launchBarStateTest_LaunchModeChanged. Do they fail without the current fix in? I might have misread this so check what I'm saying please.
Even though I think I guided you against doing this I think it might be better to test all three states in the single test.
Set the exact state the descriptor test currently prepares:
before switch:
descriptor2 / target2 / run
switch to:
descriptor1 / target1 / preferredMode1
Then install one listener implementing all three callbacks:
activeLaunchDescriptorChanged(...)
activeLaunchTargetChanged(...)
activeLaunchModeChanged(...)
For every callback generated by
setActiveLaunchDescriptor(desc_no1)
capture:
getActiveLaunchDescriptor()
getActiveLaunchTarget()
getActiveLaunchMode()
and afterwards verify that every captured state was:
descriptor1 / target1 / preferredMode1
That would directly test the stated design:
"Whenever an event is fired, launch bar manager is expected to have up-to-date fields."
There was a problem hiding this comment.
Hi Mr. @betamaxbandit ,
But not sure about launchBarStateTest_LaunchTargetChanged and launchBarStateTest_LaunchModeChanged. Do they fail without the current fix in? I might have misread this so check what I'm saying please.
It does not fail without fix.
I added them as an extra cover for the ILaunchBarListener.class
3 UT I added is testing for 3 checkpoint:
- Launch descriptor changed
- Launch target changed
- Launch mode changed
And after the change happens, launch bar fields is capture each time an event is catched in ILaunchBarListener.class.
That would directly test the stated design:
"Whenever an event is fired, launch bar manager is expected to have up-to-date fields."
That's a good idea.
I updated the UT.
Now, the test ILaunchBarListener captures all events and records the launch bar state at that time.
All those records are verified afterward.
betamaxbandit
left a comment
There was a problem hiding this comment.
This is looking much better now the regression has been added. I have added a few comments about the extra tests.
See what you think Tam.
DangMinhTam382
left a comment
There was a problem hiding this comment.
Hi Mr. @betamaxbandit ,
Thanks for the comments.
The suggestion you made on the UT is really on point.
I updated them and this should be ready now
| * @throws InterruptedException | ||
| */ | ||
| @Test | ||
| public void launchBarStateTest_LaunchDescriptorChanged() throws CoreException, InterruptedException { |
There was a problem hiding this comment.
Hi Mr. @betamaxbandit ,
But not sure about launchBarStateTest_LaunchTargetChanged and launchBarStateTest_LaunchModeChanged. Do they fail without the current fix in? I might have misread this so check what I'm saying please.
It does not fail without fix.
I added them as an extra cover for the ILaunchBarListener.class
3 UT I added is testing for 3 checkpoint:
- Launch descriptor changed
- Launch target changed
- Launch mode changed
And after the change happens, launch bar fields is capture each time an event is catched in ILaunchBarListener.class.
That would directly test the stated design:
"Whenever an event is fired, launch bar manager is expected to have up-to-date fields."
That's a good idea.
I updated the UT.
Now, the test ILaunchBarListener captures all events and records the launch bar state at that time.
All those records are verified afterward.
betamaxbandit
left a comment
There was a problem hiding this comment.
Tam, this is looking good. I think it could be merged now.
I only have one slight improvement for the test if you feel it would add value.
| state.put(attr_activeDesc, descriptor); | ||
| state.put(attr_activeTarget, launchBarManagerMock.getActiveLaunchTarget()); | ||
| state.put(attr_activeMode, launchBarManagerMock.getActiveLaunchMode()); | ||
| launchBarState.get().add(state); |
There was a problem hiding this comment.
This now covers the state seen by all callbacks during the descriptor transition, which looks good.
One concern: the recorded state does not identify which callback produced it. Therefore launchBarStateTest_LaunchDescriptorChanged() could still pass if activeLaunchDescriptorChanged() were never fired, provided another callback populated the list. An empty list would also pass the assertions vacuously.
Could we record the event type as well and assert that the expected event was actually received? I don't think we need to assert event ordering, just that the expected callback occurred and that every callback saw the correct Launch Bar state.
There was a problem hiding this comment.
I think that a good point, especially
An empty list would also pass the assertions vacuously.
Had some thoughts on this one, and decided the create a TestLaunchBarListener object to make the event handling record more efficient.
Each event type will be record correspondingly and verified separately.
DangMinhTam382
left a comment
There was a problem hiding this comment.
Hi Mr. @betamaxbandit ,
Thanks for the comments.
I updated the UT to cover for Event's type verification.
Could you have a look at it again and let me know what you think?
Thanks!
| state.put(attr_activeDesc, descriptor); | ||
| state.put(attr_activeTarget, launchBarManagerMock.getActiveLaunchTarget()); | ||
| state.put(attr_activeMode, launchBarManagerMock.getActiveLaunchMode()); | ||
| launchBarState.get().add(state); |
There was a problem hiding this comment.
I think that a good point, especially
An empty list would also pass the assertions vacuously.
Had some thoughts on this one, and decided the create a TestLaunchBarListener object to make the event handling record more efficient.
Each event type will be record correspondingly and verified separately.
betamaxbandit
left a comment
There was a problem hiding this comment.
Hi @Tam,
your latest change looks very good - thank you.
I'm sorry, but I only just noticed that your new test file does not have a copyright header.
Once you've added that, I think the change is ready to merge.
When active descriptor changed, and fireActiveLaunchDescriptorChanged() is called, current active mode and target are out of sync. This puts listeners at risk of handling event with false data for the changed descriptor. Changed it so that only fire event when related fields are finished updating
8c0173b to
8439da4
Compare
DangMinhTam382
left a comment
There was a problem hiding this comment.
Hi Mr. @betamaxbandit ,
Thanks for pointing this out.
I seem to keep forgetting this one.
The copyright header has been added.
Also, made this PR official as well.
Many thanks!
betamaxbandit
left a comment
There was a problem hiding this comment.
Hi @DangMinhTam382
LGTM.
Thanks for fixing the copyright. I have no further comments.
However, I'd like @Kummallinen to give a final review because he did have a previous comment.
Also you mentioned there is a test failure and I understand that you are currently attempting to identify whether this is related to your change.
requested changes have no been made.
|
Hi Mr. @betamaxbandit ,
That's correct.
So, I tried running it in my local dev environment and notice that a deadlock situation occurred at random rate (It passed sometime - looks like a racing condition case). Not entirely sure, the change's making the issue worst or more noticeable. |
Hi @DangMinhTam382 , I had a quick look at this issue and tests around it. I didn't come up with any silver bullets, I'm wondering if what this test is doing could be a clue or help? |
2965707 to
4d8f585
Compare
|
Hi Mr. @betamaxbandit, Thanks for the suggestion on the Though, this not going to be the suitable fix, as it happens in multiple Test class. Fixing for each of them is not an option here. Also, had a theory on how this PR impact the other UT: (#1533 (comment))
There's more information on the issue. Many thanks! |
4d8f585 to
8439da4
Compare


When active descriptor changed, and fireActiveLaunchDescriptorChanged() is called, current active mode and target are out of sync. This puts listeners at risk of handling event with false data for the changed descriptor.
Changed it so that only fire event when related fields are finished updating