-
Notifications
You must be signed in to change notification settings - Fork 31
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
Fix minimal images on gce and ec2 #416
Merged
blackboxsw
merged 2 commits into
canonical:main
from
a-dubs:fix-minimal-images-on-gce-and-ec2
Sep 13, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 |
---|---|---|
@@ -1 +1 @@ | ||
1!9.1.0 | ||
1!9.1.1 |
This file contains 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 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 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
Empty file.
This file contains 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,114 @@ | ||
"""Tests related to pycloudlib.gce.cloud module.""" | ||
|
||
import mock | ||
import pytest | ||
|
||
from pycloudlib.cloud import ImageType | ||
from pycloudlib.ec2.cloud import EC2 | ||
|
||
# mock module path | ||
MPATH = "pycloudlib.ec2.cloud." | ||
|
||
|
||
class FakeEC2(EC2): | ||
"""EC2 Class that doesn't load config or make requests during __init__.""" | ||
|
||
# pylint: disable=super-init-not-called | ||
def __init__(self, *_, **__): | ||
"""Fake __init__ that sets mocks for needed variables.""" | ||
|
||
|
||
# pylint: disable=protected-access,missing-function-docstring | ||
class TestEC2: | ||
"""General EC2 testing.""" | ||
|
||
@pytest.mark.parametrize( | ||
["release", "image_type", "daily", "expected_name_filter"], | ||
[ | ||
pytest.param( | ||
"focal", | ||
ImageType.GENERIC, | ||
True, | ||
"ubuntu/images-testing/hvm-ssd/ubuntu-focal-daily-*-server-*", | ||
id="generic-lts-daily", | ||
), | ||
# Test GENERIC with LTS release and daily = False | ||
pytest.param( | ||
"noble", | ||
ImageType.GENERIC, | ||
False, | ||
"ubuntu/images/hvm-ssd-gp3/ubuntu-noble-*-server-*", | ||
id="generic-lts-non-daily", | ||
), | ||
# Test MINIMAL with LTS release and daily = True | ||
pytest.param( | ||
"jammy", | ||
ImageType.MINIMAL, | ||
True, | ||
"ubuntu/images-testing/hvm-ssd/ubuntu-jammy-daily-*-server-minimal-*", | ||
id="minimal-lts-daily", | ||
), | ||
# Test MINIMAL with LTS release and daily = False | ||
pytest.param( | ||
"noble", | ||
ImageType.MINIMAL, | ||
False, | ||
"ubuntu/images/hvm-ssd-gp3/ubuntu-noble-*-server-minimal-*", | ||
id="minimal-lts-non-daily", | ||
), | ||
# Test PRO with non-LTS release | ||
pytest.param( | ||
"jammy", | ||
ImageType.PRO, | ||
False, | ||
"ubuntu-pro-server/images/hvm-ssd/ubuntu-jammy-22.04-*", | ||
id="pro-non-lts", | ||
), | ||
# Test PRO_FIPS with non-LTS release | ||
pytest.param( | ||
"noble", | ||
ImageType.PRO_FIPS, | ||
False, | ||
"ubuntu-pro-fips*/images/hvm-ssd-gp3/ubuntu-noble-24.04-*", | ||
id="pro-fips-non-lts", | ||
), | ||
], | ||
) | ||
def test_get_name_for_image_type( | ||
self, | ||
release: str, | ||
image_type: ImageType, | ||
daily: str, | ||
expected_name_filter: str, | ||
): | ||
""" | ||
Test the _get_name_for_image_type() method against various | ||
combinations of release, image_type, and daily | ||
""" | ||
ec2 = FakeEC2() | ||
result = ec2._get_name_for_image_type( | ||
release=release, image_type=image_type, daily=daily | ||
) | ||
assert result == expected_name_filter | ||
|
||
def test_get_owner_for_all_image_types(self): | ||
""" | ||
Test the _get_project() method against all possible ImageType enum values | ||
""" | ||
expected_project_per_image_type = { | ||
ImageType.GENERIC: "099720109477", | ||
ImageType.MINIMAL: "099720109477", | ||
ImageType.PRO: "099720109477", | ||
ImageType.PRO_FIPS: "aws-marketplace", | ||
} | ||
|
||
ec2 = FakeEC2() | ||
|
||
# for each value of ImageType, check if it is in the expected_project_per_image_type dict | ||
# if not, then the test will fail because a new ImageType was added | ||
for image_type in ImageType: | ||
assert image_type in expected_project_per_image_type | ||
assert ( | ||
ec2._get_owner(image_type) | ||
== expected_project_per_image_type[image_type] | ||
) |
This file contains 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
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.
I much prefer
mininal
.... But, if we prefer to be correct and all +1.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.
Bahahahah