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
LUCENE-10301: make test framework a module (remove split packages) #551
Conversation
…ivate hacks. Some can be worked around, others can't be, easily.
…/ in the distribution.
…s perhaps better isolated.
@dweiss i tried it out locally, but hit a snag. I'm not even sure it relates to this change?
I've uploaded the full log of what i did in case it helps: |
so I ran And i noticed it created the files in question:
So I'm guessing this might be somehow a dependency/race condition issue? Maybe best solved for another issue as I think I can work around it to test out this change. |
If you like I can also quickly hack the StackWalker code, but if you want to merge first: let's do it. |
Hi Uwe. I wanted to do it too but eventually.... didn't. I mean - it's clearly stated these internal packages are for internal use only (much like many other methods in Lucene). And they're already not accessible in module-mode. Sure, we can add runtime restrictions for these methods but I see little point in doing so - they are already red-taped all over... Why complicate things? In the longer perspective, we can simply check inside the internal secrets if we're loaded in module-mode (this ensures isolation) and fail if they're loaded on classpath. This will force people to put the test framework (and lucene) on module path but I don't see a problem with that. |
bq. This is by the way the same like JDK does it. The JDK doesn't have any runtime checks for this, I believe - it's shifted to the module system to verify accessibility: |
Sure I was imprecise. In Java 8 they have this check. The difference: JDK 11 is always encapsulated, but lucene can be used with classpath and people will do this forever, trust me. So I will add a PR to add this, it's so simple and brings security. Trust me people will always use those methods and here they clearly should never ever do this. |
Oh, I do believe they will - no doubt about that. This said, I am a rebel who likes to touch the internals from time to time - if you let people know they're doing it without any guarantees, I think it's fine. I'll merge the conflicts against main, maybe later today, and then try to commit it in - will leave you a placeholder for the check there (or feel free to provide a PR to this branch, no problem). |
I can also commit it into the branch if you like. But a PR is also fine, working on it already (its simple, a stub method wont help (as code must be on the method itsself). |
BTW, you're right about the setters. The are one-time only, so no need for checks. |
I think the conflicts are caused by me, it's simple, I can merge in. |
…o tframework # Conflicts: # lucene/CHANGES.txt # lucene/core/src/test/org/apache/lucene/store/TestMmapDirectory.java
Done. |
My concern is not about rebels, instead I'd just rather not cause hassle: I'm suspicious of the state of tooling around modules right now :) I can imagine cases (at least for the near future until stuff matures?) where someone is running unit tests or using IDE in classpath mode, but then tries to deploy in module mode for production and gets bit? Obviously, this kind of thing is what integration tests are for, but it still feels a bit trappy. |
I have a solution that works quite well. Not with getCallerClass() as this needs a special permission. As we only need class name, I use a plain StackWalker. It just crosschecks that the methods are only called from within test framework. with or without module does not matter:
|
This is also not performance critica, as only test framework should ever call any method to get secrets. |
Here is a PR, I will just add one test: |
Hi, I also fixed a bug in the static initializer of TestSecrets: It used wrong class for initialization. You were able to see this with my new test and running ONLY this test in ISOLATION. See: https://github.com/dweiss/lucene/pull/14/files#diff-201a6e8b6ef8434184e32bf0ac679be1a372f7d95c50e6c76db099644ce47b7dR48 |
OK, if you merge that PR in, I am happy! Thanks! |
Add a check that we can only call TestSecrets from the test framework
Thanks! |
Wasn't this merged? |
I've merged it manually from command-line. Closing the PR. |
See https://issues.apache.org/jira/browse/LUCENE-10301