Skip to content
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

Fixed flaky test due to use of HashSet in DatabaseLookupMetaTest#testProvidesModelerMeta #3422

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

wang3820
Copy link
Contributor

Issue

org.apache.hop.pipeline.transforms.databaselookup.DatabaseLookupMetaTest#testProvidesModelerMeta calls meta.getDatabaseFields() and meta.getStreamFields() to get the database fields nad streamfields in as a list, and the order in the list is the insertion order in to the lookup. However, inside meta.getDatabaseFields() and meta.getStreamFields(), a HashSet was used to insert the data before returned as an ArrayList. However, order in HashSet is not predictable when it is converted to ArrayList (fist toArray is called and the HashSet iterator has undeterministic order). Therefore, tests could fail when the fields are checking according to the insertion order.

assertEquals(3, meta.getDatabaseFields().size());
assertEquals("f1", meta.getDatabaseFields().get(0));
assertEquals("f2", meta.getDatabaseFields().get(1));
assertEquals("f3", meta.getDatabaseFields().get(2));
assertEquals(3, meta.getStreamFields().size());
assertEquals("s4", meta.getStreamFields().get(0));
assertEquals("s5", meta.getStreamFields().get(1));
assertEquals("s6", meta.getStreamFields().get(2));

Fix

Use LinkedHashSet in meta.getDatabaseFields() and meta.getStreamFields() to keep track of the insertion order.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Run mvn clean install apache-rat:check to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If you have a group of commits related to the same change, please squash your commits into one and force push your branch using git rebase -i.
  • Mention the appropriate issue in your description (for example: addresses #123), if applicable.

To make clear that you license your contribution under the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@hansva hansva merged commit 1a276ed into apache:master Nov 21, 2023
2 checks passed
@wang3820 wang3820 deleted the fix-flaky-databaselookup branch November 21, 2023 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants