Skip to content

[BUG] UnixTimeStampTest may fail due to floating point precision #996

@dai-chen

Description

@dai-chen

What is the bug?
UnixTimeStampTest.checkNoArgs() may fail sometimes and floating precision seems the root cause. See error logs below:

UnixTimeStampTest > checkNoArgs() FAILED
    org.opentest4j.AssertionFailedError: expected: <1667255816> but was: <1667255817>
        at app//org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)
        at app//org.junit.jupiter.api.AssertionUtils.failNotEqual(AssertionUtils.java:62)
        at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
        at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
        at app//org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:618)
        at app//org.opensearch.sql.expression.datetime.UnixTimeStampTest.checkNoArgs(UnixTimeStampTest.java:34)

Code:

  @Test
  public void checkNoArgs() {
    assertEquals(System.currentTimeMillis() / 1000L, unixTimeStamp());
    assertEquals(System.currentTimeMillis() / 1000L, eval(unixTimeStampExpr()).longValue());
  }

How can one reproduce the bug?
N/A

What is the expected behavior?
Without nondeterministic behavior, UnixTimeStampTest.checkNoArgs() can pass all the time.

What is your host/environment?

  • Github action failed on 2.x branch

Do you have any screenshots?
N/A

Do you have any additional context?
N/A

Metadata

Metadata

Labels

bugSomething isn't workinginfrastructureChanges to infrastructure, testing, CI/CD, pipelines, etc.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions