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 a bug in DynamicRelation.members() that broke BareAtlas.relationsLowerOrderFirst() #216

Merged
merged 4 commits into from
Sep 13, 2018
Merged

Fixed a bug in DynamicRelation.members() that broke BareAtlas.relationsLowerOrderFirst() #216

merged 4 commits into from
Sep 13, 2018

Conversation

lucaspcram
Copy link
Contributor

Description:

Previously, the interaction between BareAtlas, AtlasEntity, and DynamicAtlas/DynamicRelation was broken in the following way:

If you had a DynamicAtlas containing some relation R that contained at least one other relation R' as a member, calling DynamicAtlas.relationsLowerOrderFirst() (which used the implementation in BareAtlas) would drop relation R from the returned set.

This was due to a faulty AtlasEntity equality assumption made by relationsLowerOrderFirst() which did not hold in the case of DynamicAtlas.

This has now been fixed in DynamicRelation. The members function now returns entities of the correct type, so that the equality assumptions made in relationsLowerOrderFirst() are correct.

Potential Impact:

The broken version of DynamicAtlas.members() (and BareAtlas.relationsLowerOrderFirst()) was negatively impacting the functionality of WaySectionProcessor (the raw atlas version), which depends on DynamicAtlas and proper functionality of this method to work. Before the bug fix, the WaySectionProcessor would drop any relation which had at least one relation as a member.

Unit Test Approach:

I have added DynamicAtlasTest.testRelationsLowerOrderFirstConsistency(), which demonstrates the case in which the bug would occur. It utilizes a new test atlas, DynamicAtlasTestRule.atlasForRelationsTest, which is designed to trigger the bug. With the fix, this unit test now passes.

RawAtlasIntegrationTest.testSectioningFromShard() was also affected. In the previous code version, it was dropping two relations from the build, and the test was assuming that those two relations did not exist (when in reality they had actually just been dropped by the WaySectionProcessor). The test is updated, and passes with the bug fix in place.

Test Results:

I am planning on doing more extensive testing. Please reach out to me to discuss.


In doubt: Contributing Guidelines

matthieun
matthieun previously approved these changes Sep 13, 2018
Copy link
Collaborator

@matthieun matthieun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great testing again!

@matthieun matthieun merged commit 05d4bfa into osmlab:dev Sep 13, 2018
@lucaspcram lucaspcram deleted the dynamicrelation branch September 13, 2018 16:37
Copy link
Contributor

@MikeGost MikeGost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix and test - great stuff. Just a belated review to confirm the fix.

Assert.assertEquals(14, finalAtlas.numberOfRelations());

/*
* This has been updated to 16 instead of 14. This is because two of the relations in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this comment is necessary. The check here was on the data, simply changing the number is fine. Thanks for the detailed explanation!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly left it just for the purposes of explaining the change in the PR, so you guys didn't think I was just cheating to make a test pass :)

It could have been removed but we merged so fast that I didn't get a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants