-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Modernize BWC testing with parameterized tests #13046
Conversation
@ParametersFactory(argumentFormatting = "Lucene-Version:%1$s; Pattern: %2$s") | ||
public static Iterable<Object[]> testVersionsFactory() { | ||
List<Object[]> params = new ArrayList<>(); | ||
// NOCOMMIT: why are we only testing one version here? |
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 somebody has an answer to that
} | ||
|
||
public void testUpgradeOldSingleSegmentIndexWithAdditions() throws Exception { | ||
// NOCOMMIT we use to have single segment indices but we stopped creating them at some point |
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 somebody has an answer to that, this puzzles me as well
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 don't know why we stopped! We should start again? But maybe as followon?
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 like the approach. I'm curious of @dweiss' opinion since he's more familiar with the testing framework.
...kward-codecs/src/test/org/apache/lucene/backward_index/TestBinaryBackwardsCompatibility.java
Outdated
Show resolved
Hide resolved
@ParametersFactory(argumentFormatting = "Lucene-Version:%1$s; Pattern: %2$s") | ||
public static Iterable<Object[]> testVersionsFactory() { | ||
List<Object[]> params = new ArrayList<>(); | ||
// NOCOMMIT: why are we only testing one version here? |
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 would guess it's because it's more about testing the upgrade logic on empty indexes than about testing the format of old empty indexes.
I like it. Whenever there is test repetition that can be driven by data, it should be driven by data. The only downside to using ParametersFactory is that it's something that is implemented by the randomizedtesting framework (not JUnit itself) and people may be unfamiliar with it - perhaps a comment on the class (or the parameterized constructor) pointing at where the arguments come from would make it easier to grasp how this thing works? Plain JUnit alternatives do exist but they rely on a different test runner (Parameterized) - you wouldn't be able to extend from LuceneTestCase anymore (and you'd be outside of the randomization context). I don't see any other, more elegant, solutions. |
Oh, one more problem is that you can't "see" the structure of tests before you actually run them (in an IDE). Don't know how much of an issue this is in practice but it's impossible to solve with JUnit4. Some IDEs may also have problems repeating a particular test if its name contains parameters and their names. But I don't think we should think in terms of IDE support - the final outcome and benefit for maintainability matters 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.
This looks great! Thank you for modernizing our ancient BWC tests @s1monw. I left minor comments. For the // nocommit
questions let's make followon issues to address? We should PnP this!
...codecs/src/test/org/apache/lucene/backward_index/TestIndexUpgradeBackwardsCompatibility.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
public void testUpgradeOldSingleSegmentIndexWithAdditions() throws Exception { | ||
// NOCOMMIT we use to have single segment indices but we stopped creating them at some point |
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 don't know why we stopped! We should start again? But maybe as followon?
What on earth means PnP? Mike, check out this search: https://www.google.com/search?q=pnp+acronym wikipedia FTW |
…ex/TestBinaryBackwardsCompatibility.java Co-authored-by: Adrien Grand <[email protected]>
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.
Looks fine to me. Theres only a forbiddenapis problem due to String#formatted
.
Replace by String.format(Locale.ROOT, indexPattern, version)
...ackward-codecs/src/test/org/apache/lucene/backward_index/BackwardsCompatibilityTestBase.java
Outdated
Show resolved
Hide resolved
PnP = progress not perfection! Not plug and play, not transistors, heh. |
We all need some drugs sometimes, especially the policeman. 💉💊💊💊 |
@uschindler I need to hear you speaking german to tell, you know that ;) |
...ackward-codecs/src/test/org/apache/lucene/backward_index/BackwardsCompatibilityTestBase.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.
Looks fine. All nocommits are todos now.
I think it's ready for a first round. P💊P
P.S.: About the code style I would prefer the list of versions as a Stream.of(...)
and converting them to those sets of versions using a stream mapping. Those array declarations look always strange.
thanks everybody... I will go and backport this to 9.x as well |
This change modernizes the BWC tests to leverage RandomizedRunners Parameterized Tests that allow us to have more structured and hopefully more extendible BWC tests in the future. This change doesn't add any new tests but tries to make the ones we have more structured and support growth down the road. Basically, every index type got it's own Test class that doesn't require to loop over all the indices in each test. Each test case is run with all versions specified. Several sanity checks are applied in the base class to make individual tests smaller and much easier to read. Co-authored-by: Michael McCandless <[email protected]> Co-authored-by: Adrien Grand <[email protected]>
So I just finished the 8.11.3 release, and had some problems with the back-compat testing code. Obviously the ant/gradle switch and jdk versions meant that I had to do a lot of it manually, but I'm pretty sure the regex matching in the I updated the files myself manually for 8.11.3 (on main and 9x), and I think they are correct (and the tests pass), but I would recommend checking them and re-checking that the python script works with these changes... |
In apache#13046 several changes broke the addBackcompatIndexes.py script to properly add and test the unreleased version. This updates the script to again properly add the new version. Closes apache#13094
…3095) In #13046 several changes broke the addBackcompatIndexes.py script to properly add and test the unreleased version. This updates the script to again properly add the new version. Closes #13094 Co-authored-by: Dawid Weiss <[email protected]>
…3095) In #13046 several changes broke the addBackcompatIndexes.py script to properly add and test the unreleased version. This updates the script to again properly add the new version. Closes #13094 Co-authored-by: Dawid Weiss <[email protected]>
…3095) In #13046 several changes broke the addBackcompatIndexes.py script to properly add and test the unreleased version. This updates the script to again properly add the new version. Closes #13094 Co-authored-by: Dawid Weiss <[email protected]>
After working on #12829 I was quite surprised about the complexity our BWC have and how ancient the appear compared to the rest of our test suite. I took a step back and tried to modernize the tests to leverage RandomizedRunner Parameterized Tests that allow us to have more structured and hopefully more extendible BWC tests in the future. This change doesn't add any new tests but tries to make the ones we have more structured and support growth down the road.
Basically, every index type got it's own Test class that doesn't require to loop over all the indices in each test. Each test case is run with all versions specified. Several sanity checks are applied in the base class to make individual tests smaller and much easier to read.