You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "mikebridge (via GitHub)" <gi...@apache.org> on 2026/09/14 20:37:14 UTC

[PR] test(tags): make humanized-timestamp assertions deterministic [superset]

mikebridge opened a new pull request, #44260:
URL: https://github.com/apache/superset/pull/44260

   ### SUMMARY
   
   `TestTagApi::test_get_tag` is a recurring CI flake: it asserts `changed_on_delta_humanized == "now"` under `freeze_time(datetime.now())` and intermittently fails with `assert 'now' == 'a second from now'` (four re-triggers across unrelated PRs in one day).
   
   **Root cause.** The frozen clock never reaches the stored timestamp. `AuditMixinNullable` declares `created_on` / `changed_on` with `default=datetime.now` (`superset/models/helpers.py:1258-1260`), which captures the *real* `datetime.now` bound method at import time; freezegun rebinds the `datetime` class on loaded modules but cannot rebind a method object stored inside SQLAlchemy's `ColumnDefault`. `format_time_humanized` (`helpers.py:1233`), on the other hand, looks up `datetime.now()` at call time and gets the frozen clock. So the stamp is from the real clock, later than the frozen instant, and whenever the two straddle a second boundary `humanize` renders "a second from now".
   
   **Fix (test only).** Freeze at a fixed instant and stamp `created_on` / `changed_on` explicitly from the frozen clock before the first flush (an explicit value wins over the column default), so the humanized delta is exactly zero on every run. The assertion stays exact — no widening, no sleeps.
   
   **Evidence.** Reproduced deterministically by freezing one second behind the real clock → `'a second from now'`; control: freezing in 2024 *without* the explicit stamps → `'2 years from now'` (the stamp demonstrably comes from the real clock). No sibling test in the file asserts a humanized value.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A (test-only).
   
   ### TESTING INSTRUCTIONS
   
   ```
   pytest tests/integration_tests/tags/api_tests.py -k test_get_tag
   ```
   Run it in a loop; it no longer depends on where the wall clock is within a second. Full file: 27 passed on PostgreSQL; on SQLite the only failure is the pre-existing `test_post_bulk_tag_skipped_tags_perm` (fails identically on `master` in the same environment).
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01267VBWbvWTNZUg9GvXKgkC
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(tags): make humanized-timestamp assertions deterministic [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #44260:
URL: https://github.com/apache/superset/pull/44260#issuecomment-5670520913

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/44260?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 57.41%. Comparing base ([`eeafd65`](https://app.codecov.io/gh/apache/superset/commit/eeafd65b746c8cff1c424906d385fe911175661b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`b6c650c`](https://app.codecov.io/gh/apache/superset/commit/b6c650c74487569cbc1a49a4354cb008ffad093b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   > :exclamation:  There is a different number of reports uploaded between BASE (eeafd65) and HEAD (b6c650c). Click for more details.
   > 
   > <details><summary>HEAD has 53 uploads less than BASE</summary>
   >
   >| Flag | BASE (eeafd65) | HEAD (b6c650c) |
   >|------|------|------|
   >|python|47|1|
   >|presto|8|1|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #44260       +/-   ##
   ===========================================
   - Coverage   80.18%   57.41%   -22.77%     
   ===========================================
     Files        2925     2925               
     Lines      172692   172692               
     Branches    40090    40090               
   ===========================================
   - Hits       138474    99159    -39315     
   - Misses      31623    72593    +40970     
   + Partials     2595      940     -1655     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/44260/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/44260/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/44260/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/44260/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/44260/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.22% <ø> (ø)` | |
   | [python](https://app.codecov.io/gh/apache/superset/pull/44260/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.22% <ø> (-45.36%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/44260/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/44260/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/44260?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(tags): make humanized-timestamp assertions deterministic [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44260:
URL: https://github.com/apache/superset/pull/44260#issuecomment-5670468491

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(tags): make humanized-timestamp assertions deterministic [superset]

Posted by "richardfogaca (via GitHub)" <gi...@apache.org>.
richardfogaca merged PR #44260:
URL: https://github.com/apache/superset/pull/44260


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org