Skip to content

Conversation

jankatins
Copy link
Contributor

@jankatins jankatins commented Oct 18, 2025

I found no way to convert the current container.exec() based check function to any of the currently existing WaitStartegies and so I added RunFunctionWaitStrategy which can be used to convert such container.exec() based checks.

Helps with: #874
Closes: #883

@jankatins jankatins force-pushed the feat/add-RunFunctionWaitStrategy-and-use-it-in-pg branch from b4ea0ee to d2b2200 Compare October 18, 2025 15:15
result = self.func(container)
if result:
return result
except tuple(self._transient_exceptions) as e:
Copy link
Contributor Author

@jankatins jankatins Oct 18, 2025

Choose a reason for hiding this comment

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

I actually found no reason why this shouldn't be a tuple already on self -> might be an nice refactoring on WaitStrategy and where it's used.

]
)
if result.exit_code:
raise ConnectionError("pg_isready is not ready yet")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume that the pg_isready is some missing change in an older commit. I haven't investigated more...

return returns.pop(0)

strategy = RunFunctionWaitStrategy(func).with_poll_interval(0)
strategy.wait_until_ready(mock_container) # type: ignore[arg-type]
Copy link
Contributor Author

@jankatins jankatins Oct 18, 2025

Choose a reason for hiding this comment

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

For some reason mypy didn't like passing in the mock and I had to add the ignore despite other places in the same file not having this problem with mock. No idea why :-(

@codecov
Copy link

codecov bot commented Oct 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.00%. Comparing base (5c1504c) to head (531934a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #908      +/-   ##
==========================================
+ Coverage   79.78%   80.00%   +0.21%     
==========================================
  Files          14       14              
  Lines        1182     1200      +18     
  Branches      184      186       +2     
==========================================
+ Hits          943      960      +17     
- Misses        197      199       +2     
+ Partials       42       41       -1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This is usefull for converting old wait_container_is_ready
which use container.exec() to check for a condition to become True.
@jankatins jankatins force-pushed the feat/add-RunFunctionWaitStrategy-and-use-it-in-pg branch 2 times, most recently from ca685b7 to 8c1e4f9 Compare October 18, 2025 19:45
This gets rid of a annoying depcreation warning.
@jankatins jankatins force-pushed the feat/add-RunFunctionWaitStrategy-and-use-it-in-pg branch from 8c1e4f9 to 531934a Compare October 18, 2025 22:11
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