-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
CURATOR-633: Fix backward compatibility in tests #409
Closed
martin-g
wants to merge
3
commits into
apache:master
from
martin-g:curator-633-execute-test-only-on-zookeeper-3.6.x
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assumptions.assumeTrue; | ||
|
||
import com.google.common.collect.Queues; | ||
import org.apache.curator.framework.CuratorFramework; | ||
|
@@ -91,7 +92,10 @@ public void stateChanged(CuratorFramework client, ConnectionState newState) | |
} | ||
|
||
@Test | ||
public void testConnectionStateRecoversFromUnexpectedExpiredConnection() throws Exception { | ||
void testConnectionStateRecoversFromUnexpectedExpiredConnection() throws Exception { | ||
final int major = getVersionPart("MAJOR"); | ||
final int minor = getVersionPart("MINOR"); | ||
assumeTrue(major == 3 && minor >= 6 || major > 4, "Zookeeper version must be 3.6 or higher"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, the boolean condition should not be |
||
Timing2 timing = new Timing2(); | ||
CuratorFramework client = CuratorFrameworkFactory.builder() | ||
.connectString(server.getConnectString()) | ||
|
@@ -128,4 +132,13 @@ public String getPath() { | |
CloseableUtils.closeQuietly(client); | ||
} | ||
} | ||
|
||
private int getVersionPart(String part) { | ||
try { | ||
return Class.forName("org.apache.zookeeper.version.Info").getDeclaredField(part).getInt(null); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return -1; | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 it's not logically incompatible.
@Test
above, this test doesn't actually run in any condition.queueEvent
here can be emulated by bringing back bridges ofqueueEvent
like CURATOR-558 - part 1 of ZK 3.6 updates #344 removed - it's not a logically incompatible.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.
Another perspective is that whether or not we want to test that it's zk35compatible. If we don't intend to do that, we can move the test to another (new) class and assign it to zk36 group.
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 am not sure why do you explain this to me. I didn't touch
@Test
and the test is still executed incurator-framework
Maven module, where Zookeeper is 3.6.3.The problem is when this test is executed in
curator-test-zk35
module (Zookeeper 3.5.7) where#queueEvent()
is not available.https://issues.apache.org/jira/browse/ZOOKEEPER-3269 is "Fixed" only for
3.6.0
+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.
Maybe @tisonkun you are suggesting to create a set of tests that run only against zk 3.6+
That is to generalise the approach of this fix.
Probably we can create a annotation a little junit extension.
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.
BTW if we don't have much time we can keep this patch an unblock ci and the upcoming release
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.
@eolivelli we have already implemented this. If you want to merge a workaround for unblocking release, it's OK to me, and I'll prepare a followup for explaining.
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.
FYI #411.
@martin-g you can integrate in this PR and close #411.