Skip to content

Test the stated span with a key that covers now - #10

Merged
jwrosewell merged 1 commit into
mainfrom
fix/recent-minute-test-date
Oct 6, 2026
Merged

jwrosewell merged 1 commit into
mainfrom
fix/recent-minute-test-date

Conversation

@jwrosewell

@jwrosewell jwrosewell commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

DatedKeyFetchTest.aRecentMinuteIsServedWhereTheCreatorStatedTheSpan fails on main on any day from 21 September 2026. Run on main at 0022d3f on 5 October 2026 on Java 8, 11 and 17, the CI command gives the result below on each.

mvn --batch-mode --update-snapshots test
...
[ERROR]   DatedKeyFetchTest.aRecentMinuteIsServedWhereTheCreatorStatedTheSpan:884 the current key was served for every recent minute from one answer ==> expected: <1> but was: <3>
[ERROR] Tests run: 146, Failures: 1, Errors: 0, Skipped: 0

The last CI run on main was on 7 September 2026, before the date mattered, so main still shows a green tick.

Cause

The test reads the clock and asks for the key at three minutes near now. The stand in end point the test used fixes the moment of a request at 14 September 2026 and reads any later date as that moment (REQUEST_MOMENT in src/test/java/com/swancommunity/owid/KeyEndPoint.java). Up to 20 September the answer was the key in force now, with a span that held all three minutes, so one request served them. From 21 September the answer is the key for the week of 14 September, whose span holds none of the minutes asked about, so each minute is fetched and the test counts three requests.

Change

The creator in this test now states one key for the day either side of now, built with Endpoints.publicKeyAnswer, in place of the fixture schedule. The three requests and the assertion are unchanged. The assumeTrue that depended on the fixture schedule is gone, so the test also keeps checking after 30 November 2026, when the last key in the fixture starts and the old test would have been skipped.

No existing kind of answer of the stand in end point states a span that holds the present, so KeyEndPoint.Answer gains one kind, GIVEN, which serves the body passed to the existing start(Answer, String) whatever the request asks for. That parameter is renamed from redirectTo to given, because the text is now either where to redirect or the body to serve. Every other kind of answer takes the same path as before.

The .NET library's test of the same behaviour is already written this way, as ARecentMinuteIsServedWhereTheCreatorStatedTheSpan in Owid.Client.Test/PublicKeyFetchTests.cs, and the Rust and Python libraries have the same change in SWAN-community/owid-rust#13 and SWAN-community/owid-python#8.

Two files under src/test change. No library code or fixture changes.

Verification

Run on Windows on 5 October 2026 with Maven 3.9.16, using the one command of the CI workflow.

  • mvn --batch-mode --update-snapshots test ends in BUILD SUCCESS with 146 tests run and 0 failures on each of Java 8, 11 and 17, where main gives the one failure above on each.
  • With the condition in heldFor in src/main/java/com/swancommunity/owid/PublicKeyFetch.java changed from (key.explicit || recent == false) to recent == false, the changed test fails with expected: <1> but was: <3>, so the test still depends on the behaviour its name describes. That change was then put back.
  • Java 21 and Ubuntu, which the CI also uses, were not available locally, so the CI run on this pull request is the check for those.

Outstanding

The same test in the Go, Java, PHP, Python and Rust libraries has the same cause, and failed in each when the one test was run on each main on 5 October 2026. The other four are changed in SWAN-community/owid-rust#13, SWAN-community/owid-go#19, SWAN-community/owid-php#7 and SWAN-community/owid-python#8.

The test that checks a recent minute is served from a span the creator
stated read the clock, whilst the stand in end point it used answers for
no moment after 14 September 2026. From 21 September 2026 the end point
therefore answered with a key whose span did not hold the minutes asked
about, each one was fetched, and the test failed with three requests
where it expects one.

The creator in the test now states one key for the day either side of
now, as the .NET test does, so the test no longer depends on the dates in
the fixture schedule and keeps checking after the last key in the fixture
has started.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant