-
Notifications
You must be signed in to change notification settings - Fork 1
fix(gltest): support GenVM 0.3.0 runner-bundle asset rename #79
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
56e70b8
fix(gltest): pin GenVM version for direct runner via GENVM_VERSION
danieljrc888 4574ce7
ci: run direct-runner unit tests
danieljrc888 7f5d6fc
fix(gltest): support renamed genvm-runners-all bundle asset
danieljrc888 9958b6b
refactor(gltest): trim comments and docstrings in sdk_loader
danieljrc888 1b97051
fix(gltest): order cached versions numerically and warn on resolve fa…
danieljrc888 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| """Unit tests for direct-runner GenVM version resolution.""" | ||
|
|
||
| import json | ||
|
|
||
| from gltest.direct import sdk_loader | ||
|
|
||
|
|
||
| class _FakeResponse: | ||
| """Minimal context-manager stand-in for urllib's HTTP response.""" | ||
|
|
||
| def __init__(self, payload): | ||
| self._payload = payload | ||
|
|
||
| def __enter__(self): | ||
| return self | ||
|
|
||
| def __exit__(self, *exc): | ||
| return False | ||
|
|
||
| def read(self): | ||
| return json.dumps(self._payload).encode("utf-8") | ||
|
|
||
|
|
||
| class TestResolveVersion: | ||
| """resolve_version() precedence: env var > cache > latest release.""" | ||
|
|
||
| def test_env_var_takes_precedence(self, monkeypatch): | ||
| monkeypatch.setenv(sdk_loader.GENVM_VERSION_ENV, "v1.2.3") | ||
| monkeypatch.setattr(sdk_loader, "list_cached_versions", lambda: ["v0.2.16"]) | ||
| monkeypatch.setattr(sdk_loader, "get_latest_version", lambda: "v0.9.9") | ||
|
|
||
| assert sdk_loader.resolve_version() == "v1.2.3" | ||
|
|
||
| def test_falls_back_to_newest_cached_version(self, monkeypatch): | ||
| monkeypatch.delenv(sdk_loader.GENVM_VERSION_ENV, raising=False) | ||
| monkeypatch.setattr(sdk_loader, "list_cached_versions", lambda: ["v0.2.16"]) | ||
| monkeypatch.setattr(sdk_loader, "get_latest_version", lambda: "v0.9.9") | ||
|
|
||
| assert sdk_loader.resolve_version() == "v0.2.16" | ||
|
|
||
| def test_falls_back_to_latest_when_no_cache(self, monkeypatch): | ||
| monkeypatch.delenv(sdk_loader.GENVM_VERSION_ENV, raising=False) | ||
| monkeypatch.setattr(sdk_loader, "list_cached_versions", lambda: []) | ||
| monkeypatch.setattr(sdk_loader, "get_latest_version", lambda: "v0.9.9") | ||
|
|
||
| assert sdk_loader.resolve_version() == "v0.9.9" | ||
|
|
||
|
|
||
| class TestGetLatestVersion: | ||
| """get_latest_version() skips pre-releases and assetless releases.""" | ||
|
|
||
| def test_skips_releases_without_universal_asset(self, monkeypatch): | ||
| releases = [ | ||
| {"tag_name": "v0.3.0-rc0", "prerelease": False, "assets": [ | ||
| {"name": "genvm-linux-amd64.tar.xz"}, | ||
| ]}, | ||
| {"tag_name": "v0.2.16", "prerelease": False, "assets": [ | ||
| {"name": sdk_loader.UNIVERSAL_ASSET}, | ||
| ]}, | ||
| ] | ||
| monkeypatch.setattr( | ||
| "urllib.request.urlopen", lambda *a, **k: _FakeResponse(releases) | ||
| ) | ||
|
|
||
| assert sdk_loader.get_latest_version() == "v0.2.16" | ||
|
|
||
| def test_skips_prereleases(self, monkeypatch): | ||
| releases = [ | ||
| {"tag_name": "v0.3.0-rc0", "prerelease": True, "assets": [ | ||
| {"name": sdk_loader.UNIVERSAL_ASSET}, | ||
| ]}, | ||
| {"tag_name": "v0.2.16", "prerelease": False, "assets": [ | ||
| {"name": sdk_loader.UNIVERSAL_ASSET}, | ||
| ]}, | ||
| ] | ||
| monkeypatch.setattr( | ||
| "urllib.request.urlopen", lambda *a, **k: _FakeResponse(releases) | ||
| ) | ||
|
|
||
| assert sdk_loader.get_latest_version() == "v0.2.16" | ||
|
|
||
| def test_returns_fallback_when_api_unreachable(self, monkeypatch): | ||
| def _boom(*a, **k): | ||
| raise OSError("network down") | ||
|
|
||
| monkeypatch.setattr("urllib.request.urlopen", _boom) | ||
|
|
||
| assert sdk_loader.get_latest_version() == sdk_loader.FALLBACK_VERSION |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_latest_version()only fetches?per_page=100once and then falls back toFALLBACK_VERSIONif no matching asset is found in that single page. Since GitHub release listing is paginated (max 100 per page), once there are more than 100 newer releases withoutgenvm-universal.tar.xz, this code will incorrectly return the hardcoded fallback instead of the newest compatible release, leading the direct runner to use a stale pinned version (or fail if that fallback tag/asset is removed).Useful? React with 👍 / 👎.