Skip to content

[BUG][TEST] Flaky test testExtractDatePartWithTimeType #3224

Closed

Description

@LantaoJin

What is the bug?
The test testExtractDatePartWithTimeType is failed today (2024-12-30)

ExtractTest > testExtractDatePartWithTimeType() FAILED
    org.opentest4j.AssertionFailedError: expected: <53> but was: <1>
        at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
        at app//org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
        at app//org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
        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:635)
        at app//org.opensearch.sql.expression.datetime.ExtractTest.datePartWithTimeArgQuery(ExtractTest.java:90)
        at app//org.opensearch.sql.expression.datetime.ExtractTest.testExtractDatePartWithTimeType(ExtractTest.java:98)

Caused by function extract(WEEK FROM ...) actually returns the number of the ISO 8601 week-of-week-based-year:

A week is considered to start on a Monday and week 1 is the first week with >3 days. In the ISO week-numbering system, it is possible for early-January dates to be part of the 52nd or 53rd week of the previous year, and for late-December dates to be part of the first week of the next year. For example, 2005-01-02 is part of the 53rd week of year 2004, while 2012-12-31 is part of the first week of 2013.

So the current expected number 53 in the test day 2024-12-30 is incorrect.

How can one reproduce the bug?

POST /_plugins/_sql
{
  "query" : """
  select extract(WEEK FROM "2024-12-30 10:11:12") from opensearch_dashboards_sample_data_logs limit 1
  """
}

Returns 1.

What is the expected behavior?
The testExtractDatePartWithTimeType() expected: <53> but was: <1>

What is your host/environment?

  • OS: [e.g. iOS]
  • Version [e.g. 22]
  • Plugins

Do you have any screenshots?
If applicable, add screenshots to help explain your problem.

Do you have any additional context?
Add any other context about the problem.

Activity

  1. added
    bug
    flaky-test
    testing
    and removed on Dec 30, 2024
  2. changed the title [-][BUG][TEST] Fix the failure test `testExtractDatePartWithTimeType`[/-] [+][BUG][TEST] Flaky test `testExtractDatePartWithTimeType`[/+] on Dec 30, 2024
  3. self-assigned this
    on Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugflaky-testtesting

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions