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

SLING-12636: Resource Resolver: add test coverage for background init #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

reschke
Copy link
Contributor

@reschke reschke commented Jan 23, 2025

No description provided.

@reschke reschke self-assigned this Jan 23, 2025
private void initializeVanityPaths() throws IOException {
getVanityPathsProcessed().set(false);
mapEntries.initializeVanityPaths();
waitForBgInit();
Copy link
Contributor

Choose a reason for hiding this comment

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

do I get it right, that you added the waitForBgInit() just in preparation for the next change, where you will run tests also with isVanityPathCacheInitInBackground = true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests (now) run with bginit as well, see parameters of the test class.


// get vanity paths (after waiting for bg init to complete)
private void initializeVanityPaths() throws IOException {
getVanityPathsProcessed().set(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need to reset the internal state here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to check whether background init has finished; otherwise the expections about the number of entries in the map will be incorrect.

Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't follow the full logic; you are replacing doInit with changing an internal flag; this IMO makes the test assume too much about the behaviour of MapEntries and is going to make evolving this class more difficult.

Have you considered adding a new protected/package-private method that will encapsulate the re-reading of vanity paths?

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'll do that in later PRs.

This change is focused on improving test coverage without refactoring MapEntries. Tests will be updated when refactoring is done.

FWIW, doinit() actually initializes aliases, not vanity paths. All of this will be improved step by step.

Copy link
Contributor Author

@reschke reschke Jan 24, 2025

Choose a reason for hiding this comment

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

Why do you need to reset the internal state here?

I checked, and it is needed. I currently do not understand what sets the state to "true", but I'll try to find out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. The reason is that the internal state of MapEntries did not account for loadVanityPaths called twice.

I added that, and was able to remove getVanityPathsProcessed().set(false); from the test.

Your point about extending MapEntries is understood; however the point of this change was to improve test coverage before doing any changes of what's being tested.

Copy link

… - fix MapEntries internal state when loadVanityPaths is called a second time
@reschke
Copy link
Contributor Author

reschke commented Jan 29, 2025

@rombert , @joerghoh - I plan to go ahead with this once https://issues.apache.org/jira/browse/SLING-12637 (release of 1.12.4) is done.

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.

3 participants