Repository navigation
test(examples): suspend and resume a MicroVM - #839
Merged
Merged
Conversation
The new session example lets its idle MicroVM suspend during a 60-second wait. Its cloud test reads the MicroVM ID from the launch step, sees the state SUSPENDED, and checks that the next job resumed the same MicroVM.
This addresses the review of the suspend test. The test now reads the MicroVM state only after the pause wait has started in the history.
yaythomas
requested changes
Oct 25, 2026
yaythomas
left a comment
Contributor
There was a problem hiding this comment.
The Permissions section contains internal-only review and test-account details. This repository is public, and the README already lists the public IAM actions. Can that section keep only the public permission list?
Address review: a callback named gate replaces the 60-second wait. The test completes the gate only after it sees SUSPENDED, so the suspend lies between the jobs with no timing assumption. A failed test fails the gate, so the session terminates the MicroVM.
Contributor
Author
|
Thanks. I removed the internal details from the Permissions section. It now lists only the public IAM actions. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a MicroVM example and a cloud test in which a session MicroVM suspends itself between two jobs, and the second job resumes it.
Why
SuspendMicrovmcall, the suspend and resume hooks, and the request step'sGetMicrovmandResumeMicrovmstate check.Changes
src/microvm/microvm_session_suspend.py, catalog name "MicroVM Session Suspend".microvm_sessionwithauto_suspend_on_idle=Trueand an idle time of 10 seconds./write. A callback namedgatefollows. Job 2 reads the file through/read.gateto start job 2. The gate times out after 5 minutes, so a caller that never completes it leaves the MicroVM running for 5 minutes at most.test/microvm/test_microvm_session_suspend.py.run_async.gatecallback ID.GetMicrovmuntil it seesSUSPENDED. Job 1 has ended, and job 2 cannot start whilegateis pending. So the observed suspend lies between the two jobs, whatever the timing.gate, and waits for the result.resumeBeforeDeliveryin the launch result, and that the MicroVM was terminated.gate, it fails the callback. So the session terminates the MicroVM at once.microvm_helpers.py:wait_for_history_event,find_launched_microvm_idon top of it,wait_for_microvm_state, andfail_callback_after_test_failure, with unit tests.app.py, or the image settings.Permissions
lambda:GetMicrovmandlambda:ResumeMicrovm.lambda:SuspendMicrovmon the image.Testing
TERMINATED.hatch run dev-examples:test: 189 passed, 6 skipped. The new test is skipped in local mode.hatch fmt --checkpasses.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.