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

chore(distributed-lock): refactor tests #29302

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

villebro
Copy link
Member

SUMMARY

This PR refactors the distributed lock tests in the following way:

  1. Replace assertions of mocked internals with assertions of the functional aspects of the lock
  2. Assert that the lock state is committed to the metastore during the locking process

This will make it safer to refactor SQLAlchemy session logic in accordance with SIP-99A, as the test will ensure that commits happen at the critical moments (lock is taken, lock is released). In addition, it makes the test immune to refactoring of internals of the lock.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

Copy link

codecov bot commented Jun 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.73%. Comparing base (76d897e) to head (836012e).
Report is 1094 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #29302       +/-   ##
===========================================
+ Coverage   60.48%   83.73%   +23.24%     
===========================================
  Files        1931      518     -1413     
  Lines       76236    37552    -38684     
  Branches     8568        0     -8568     
===========================================
- Hits        46114    31443    -14671     
+ Misses      28017     6109    -21908     
+ Partials     2105        0     -2105     
Flag Coverage Δ
hive 48.94% <42.85%> (-0.23%) ⬇️
javascript ?
mysql 77.20% <71.42%> (?)
postgres 77.33% <71.42%> (?)
presto 53.55% <42.85%> (-0.25%) ⬇️
python 83.73% <100.00%> (+20.24%) ⬆️
sqlite 76.79% <71.42%> (?)
unit 59.25% <85.71%> (+1.63%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -67,6 +66,6 @@ def validate(self) -> None:
def get(self) -> Optional[Any]:
filter_ = get_filter(self.resource, self.key)
entry = db.session.query(KeyValueEntry).filter_by(**filter_).first()
if entry and (entry.expires_on is None or entry.expires_on > datetime.now()):
if entry and not entry.is_expired():
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@villebro villebro merged commit 03969d5 into apache:master Jun 20, 2024
38 of 39 checks passed
@villebro villebro deleted the villebro/lock-tests branch June 20, 2024 12:58
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 4.1.0 labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 4.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants