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

8281511: java/net/ipv6tests/UdpTest.java fails with checkTime failed #23840

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

Conversation

serhiysachkov
Copy link
Contributor

@serhiysachkov serhiysachkov commented Feb 28, 2025

switching to nanoTime as suggested in ticket comments


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-8281511: java/net/ipv6tests/UdpTest.java fails with checkTime failed (Bug - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23840

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 28, 2025

👋 Welcome back serhiysachkov! 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
Copy link

openjdk bot commented Feb 28, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 28, 2025
@openjdk
Copy link

openjdk bot commented Feb 28, 2025

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

  • net

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.

@mlbridge
Copy link

mlbridge bot commented Feb 28, 2025

Webrevs

Copy link
Member

@dfuch dfuch left a comment

Choose a reason for hiding this comment

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

I'd suggest to use TimeUnit to make times more readable and less prone to typing errors.

@msheppar
Copy link

the ubiquitous update of year in Copyright is required for the test file

@msheppar
Copy link

I think the checkTime from the base class Tests, should be reviewed in the context of the reported failures, where some of the actual timeouts registered are 10699 , 16926, 17926

The timeout check is

/* check the time got is within 50% of the time expected */
public static void checkTime (long got, long expected) {
checkTime(got, expected, expected);
}

/* check the time got is between start and end, given 50% tolerance */
public static void checkTime(long got, long start, long end) {
    dprintln("checkTime: got = " + got + " start = " + start + " end = " + end);
    long upper = end + (end / 2);
    long lower = start - (start / 2);
    if (got > upper || got < lower) {
        throw new RuntimeException("checkTime failed: got " + got
                + ", expected between " + start + " and " + end);
    }
}

which uses arbitrary upper bounds and lower bounds.

If a timeout is set at 5000 milliseconds then the expectation is that, should the timeout expire and a SocketTimeoutException is thrown, then the actual elapsed time will be equal to, or greater than, the specified timeout value passed to setSoTimeout. The minimum timeout is 5000 milliseconds, that is the lower bound for any timeout expiry check. Any earlier return would indicate a spurious wakeup by the OS.

In the checkTime a lower bound of less than the expected timeout is tolerated, and then an upper bound of an additional 50% is utilised as a check. Looking at the reported failures scenarios the actual elapsed time is significantly greater than the (timeout + 50%) value.

It is proffered that in reality no upper bound, other than > timeout value should be imposed on the timeout check.

Copy link
Member

@dfuch dfuch left a comment

Choose a reason for hiding this comment

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

Additionally could you have a look at the superclass Tests.java? There is this code there:

    /* check the time got is within 50% of the time expected */
    public static void checkTime (long got, long expected) {
        checkTime(got, expected, expected);
    }

    /* check the time got is between start and end, given 50% tolerance */
    public static void checkTime(long got, long start, long end) {
        dprintln("checkTime: got = " + got + " start = " + start + " end = " + end);
        long upper = end + (end / 2);
        long lower = start - (start / 2);
        if (got > upper || got < lower) {
            throw new RuntimeException("checkTime failed: got " + got
                    + ", expected between " + start + " and " + end);
        }
    }

For the exception message, it would be better to use lower and upper instead of start and end - because when start == end the messsage lacks credibility.

Comment on lines +148 to +149
final long expectedTimeInNanos = TimeUnit.SECONDS.toNanos(4);
checkTime (System.nanoTime() - t1, expectedTimeInNanos);
Copy link
Member

Choose a reason for hiding this comment

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

Actually, maybe it would be better to keep the expectedTime in milliseconds here, and convert System.nanoTime() - t1 to milliseconds before calling checkTime. We obviously don't need the nano second precision, and milliseconds are more human readable than nanoseconds when looking at the log.

Comment on lines +181 to +183
final long startTimeInNanos = TimeUnit.SECONDS.toNanos(2);
final long endTimeInNanos = TimeUnit.SECONDS.toNanos(10);
checkTime (System.nanoTime() - t1, startTimeInNanos, endTimeInNanos);
Copy link
Member

Choose a reason for hiding this comment

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

same remark here.

@dfuch
Copy link
Member

dfuch commented Feb 28, 2025

I see my comment and @msheppar 's crossed each others. Whatever you decide to do here please fix the exception message to reflect the actual check that is being made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
net [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants