Skip to content

8287902: UnreadableRB case in MissingResourceCauseTest is not working reliably on Windows #9061

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

Closed
wants to merge 2 commits into from

Conversation

magicus
Copy link
Member

@magicus magicus commented Jun 7, 2022

The test test/jdk/java/util/ResourceBundle/Control/MissingResourceCauseTest.java verifies different failure modes of resource bundles. One of the failures is that the runner class, MissingResourceCauseTestRun.java, creates a file UnreadableRB, and runs chmod 000 on it, to make it unreadable by the test. Then MissingResourceCauseTest is called, and the UnreadableRB file is removed.

This does not work reliably on Windows. On msys2, chmod is essentially a no-op, so the file is not made unreadable, and hence the test fails. In my personal cygwin test environment, the chmod command does have some effect, but it is still not enough to make the file unreadable, and so the test fails.

The test was originally a shell script test that got converted to Java in JDK-4354216. The original shell script code explicitly excluded Windows from testing. This was changed in the rewrite, for reasons I cannot determine.

What suprises me, though, is the "how can this ever has worked???" factor. Apparently the test passes on the current Cygwin setup on GHA. I have failed to reproduce the working conditions that makes a file actually unreadable for the owner on Windows, neither on my GHA test repo, nor locally. I've searched the web to figure out how to properly set file permissions on Windows to make the file unreadable, using Windows native tools, to no avail. I've even asked a Stack Overflow question; which as of yet is still unanswered.

Since I feel I've spent far more time than reasonable trying to get this to work properly, I suggest we instead skip the unreadable test on Windows. It is clearly unstable and highly depending on the Windows environment, the test was never originally supported or intended for Windows, and at the of the day, testing file unreadability is not an important regression test for JDK-4354216.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8287902: UnreadableRB case in MissingResourceCauseTest is not working reliably on Windows

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9061/head:pull/9061
$ git checkout pull/9061

Update a local copy of the PR:
$ git checkout pull/9061
$ git pull https://git.openjdk.org/jdk pull/9061/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9061

View PR using the GUI difftool:
$ git pr show -t 9061

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9061.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 7, 2022

👋 Welcome back ihse! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 7, 2022
@openjdk
Copy link

openjdk bot commented Jun 7, 2022

@magicus The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Jun 7, 2022
@mlbridge
Copy link

mlbridge bot commented Jun 7, 2022

Webrevs

@magicus
Copy link
Member Author

magicus commented Jun 7, 2022

/label i18n

@openjdk openjdk bot added the i18n i18n-dev@openjdk.org label Jun 7, 2022
@openjdk
Copy link

openjdk bot commented Jun 7, 2022

@magicus
The i18n label was successfully added.

@@ -45,6 +45,9 @@ private static void callGetBundle(String baseName,

private static void callGetBundle(String baseName, Locale locale,
Class<? extends Throwable> expectedCause) {
if (baseName.equals("UnreadableRB") && System.getProperty("os.name").startsWith("Windows")) {
Copy link
Member

Choose a reason for hiding this comment

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

Hello @magicus, perhaps we could do this check in the main of this class (line 37) before calling the callGetBundle for the UnreadableRB base name? That way this method doesn't have to bother about which baseName is being passed.

I had a quick look at how other tests do the OS name checks and they use the Platform.isWindows() API which is part of the test library. I suspect you may not be able to use it here though since this MissingResourceCauseTest class gets launched manually through the MissingResourceCauseTestRun. So using System.getProperty I think is fine. Nit - perhaps we could match this check to do whatever Platform.isWindows() is doing (which seems to be checking that the os name starts with win, ignoring the case).

@jaikiran
Copy link
Member

jaikiran commented Jun 8, 2022

I have failed to reproduce the working conditions that makes a file actually unreadable for the owner on Windows, neither on my GHA test repo, nor locally.

I had quick look at the CI setup we have access to. It appears that this test passes there successfully on Windows. Could it be something to do with Windows version being used?

@naotoj
Copy link
Member

naotoj commented Jun 8, 2022

Thanks for the investigation, Magnus. I believe it is a bug to include the Windows environment in refactoring the shell script to Java. Why it's been working? No idea. Could be IOException has been thrown not by unreadable but for some other reason?

@magicus
Copy link
Member Author

magicus commented Jun 9, 2022

@naotoj Yes, that could be a likely possibility. Perhaps the file were never created, or not in the expected place?

@naotoj
Copy link
Member

naotoj commented Jun 9, 2022

@naotoj Yes, that could be a likely possibility. Perhaps the file were never created, or not in the expected place?

I'd guess something like that too. Anyways, eliminating this unreliability in test is a good clean up. Approving the fix assuming Jai's comment is addressed.

@openjdk
Copy link

openjdk bot commented Jun 9, 2022

@magicus This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8287902: UnreadableRB case in MissingResourceCauseTest is not working reliably on Windows

Reviewed-by: naoto

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 76 new commits pushed to the master branch:

  • 0901548: 8283724: Incorrect description for jtreg-failure-handler option
  • dae4c49: 8286197: C2: Optimize MemorySegment shape in int loop
  • 94b473e: 8280454: G1: ClassLoaderData verification keeps CLDs live that causes problems with VerifyDuringGC during Remark
  • 900d967: 8287924: Avoid redundant HashMap.containsKey call in EnvHelp.mapToHashtable
  • d482d7f: 8286160: (fs) Files.exists returns unexpected results with C:\pagefile.sys because it's not readable
  • edff51e: 8284858: Start of release updates for JDK 20
  • 2671443: 8286171: HttpClient/2 : Expect:100-Continue blocks indefinitely when response is not 100
  • 59b0de6: 8288048: Build failure with GCC 6 after JDK-8286562
  • db4405d: 8288078: linux-aarch64-optimized build fails in Tier5 after JDK-8287567
  • 7e948f7: 8287903: Reduce runtime of java.math microbenchmarks
  • ... and 66 more: https://git.openjdk.org/jdk/compare/2d8c6490540e3ccea23b81129b2e4073915071e0...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 9, 2022
@magicus
Copy link
Member Author

magicus commented Jun 10, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Jun 10, 2022

Going to push as commit 975316e.
Since your change was applied there have been 76 commits pushed to the master branch:

  • 0901548: 8283724: Incorrect description for jtreg-failure-handler option
  • dae4c49: 8286197: C2: Optimize MemorySegment shape in int loop
  • 94b473e: 8280454: G1: ClassLoaderData verification keeps CLDs live that causes problems with VerifyDuringGC during Remark
  • 900d967: 8287924: Avoid redundant HashMap.containsKey call in EnvHelp.mapToHashtable
  • d482d7f: 8286160: (fs) Files.exists returns unexpected results with C:\pagefile.sys because it's not readable
  • edff51e: 8284858: Start of release updates for JDK 20
  • 2671443: 8286171: HttpClient/2 : Expect:100-Continue blocks indefinitely when response is not 100
  • 59b0de6: 8288048: Build failure with GCC 6 after JDK-8286562
  • db4405d: 8288078: linux-aarch64-optimized build fails in Tier5 after JDK-8287567
  • 7e948f7: 8287903: Reduce runtime of java.math microbenchmarks
  • ... and 66 more: https://git.openjdk.org/jdk/compare/2d8c6490540e3ccea23b81129b2e4073915071e0...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 10, 2022
@openjdk openjdk bot closed this Jun 10, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 10, 2022
@openjdk
Copy link

openjdk bot commented Jun 10, 2022

@magicus Pushed as commit 975316e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@magicus magicus deleted the msys-test-resourcebundles branch June 14, 2022 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants