feat: add --reset to reset a start-only Connect to a clean state - #53
feat: add --reset to reset a start-only Connect to a clean state#53cgraham-rs wants to merge 3 commits into
Conversation
Returns a running start-only Connect to its clean, just-bootstrapped state with the same container, port, and API key, without restarting the container. Useful for test isolation, and for anyone who wants a clean Connect without a full restart.
|
We already have the ability to just start a container and not exit, with a followup |
Primarily because it is 10+ seconds faster than a stop-then-start cycle, and that quickly adds up to minutes if you want a clean environment between tests. |
nealrichardson
left a comment
There was a problem hiding this comment.
If this works for your use case, fine with me, seems like all existing tests still pass. Just left a couple of notes of things to clean up before we merge.
| print(f"Connect reset and ready at http://localhost:{port}", file=sys.stderr) | ||
|
|
||
|
|
||
| def cli() -> None: |
There was a problem hiding this comment.
This is confusing. if name in main, call cli, which wraps a function called main.
There was a problem hiding this comment.
Agreed, renamed it back so we get.
if __name__ == "__main__":
main()
|
@cgraham-rs do you have any examples of utilizing this within posit-sdk-py to do test isolation? |
…aming Removed two comments added to test-action/test-action-start-only that described jobs this PR didn't otherwise touch, which the reviewer found confusing. Renamed the old main()/cli() pair so the console-script entry point and the __main__ guard both call a function actually named main(), matching the Google Python Style Guide and Python Packaging User Guide's own convention. The former main() (core CLI logic) is now run().
|
Closing this PR. The original research that indicated The correct approach is to fix the See #56 |
Summary
Adds start-only container management and a fast in-place reset to
with-connect,so a running start-only Connect can be returned to a clean, just-bootstrapped state
on demand without a restart. Useful for test isolation, and more generally whenever
you want a fresh Connect without the cost of a full restart.
--reset [CONTAINER_ID]returns a running start-only Connect to its cleanbaseline with the same container, port, and
CONNECT_API_KEYstill valid.A matching
reset:GitHub Action input is added.place, with
docker-initas PID 1 to reap orphaned processes and forward signals./__ping__so a crashed Connect reads as unhealthy eventhough the keep-alive keeps the container running.
--stopstops Connect gracefully first, then stops the container promptly.A significant amount of the code change are from tests written during local iterative refinement and code reviews.
How reset works
After bootstrap, with-connect snapshots the clean data dir to a baseline archive,
excluding the license mount.
--resetthen, without stopping or restarting thecontainer, stops the Connect process, wipes the data dir while preserving the
license, restores that baseline, relaunches Connect, and polls
/__ping__. The APIkey survives because it lives in the restored database.
Reset supports only the default SQLite data dir. If a custom
Server.DataDiror anexternal database is configured, reset fails loudly instead of silently doing nothing.