-
Notifications
You must be signed in to change notification settings - Fork 25
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
adding support for art build #467
adding support for art build #467
Conversation
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.
This looks good, but some coverage is missing. Could you please find a way to get it to 100% coverage?
tests/koji/test_koji_vmi.py
Outdated
"hvm": "ami-02" | ||
}]}""" | ||
|
||
patch.object(os.path, "join", return_value=path) |
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.
This mocking doesn't seem like it should be necessary, because you can easily point the koji source to point at any directory you want. In fact you're already pointing it at koji_dir
, so you just need to write the meta.json file to the correct path under that dir and it should work without mocking.
Can you please do it that way? This way is really nasty, because:
-
You're not checking that 'join' is used correctly at all. The test can pass even if the code is totally broken and calls 'join' with incorrect arguments.
-
Mocking like this requires more maintenance in the long term, because perfectly correct changes in the code can cause the test to break just by not calling exactly the methods that you've mocked here.
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 have removed it, PTAL
96e0f8e
to
3b62cb4
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #467 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 53 53
Lines 2352 2392 +40
=========================================
+ Hits 2352 2392 +40 ☔ View full report in Codecov by Sentry. |
tests/koji/test_koji_vmi.py
Outdated
"hvm": "ami-02" | ||
}]}""" | ||
|
||
with patch("builtins.open", mock_open(read_data=meta_data)) as mocked_open: |
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.
What I wrote in comment #467 (comment) applies here too. Please, don't mock open
, it's completely unnecessary and it makes the test fragile as it now makes the test depend on the code-under-test calling open
exactly once and only for this purpose. If someone needs to add code later which opens something else, they will be forced to rewrite this test.
There should be no reason to mock any open
or path
methods here. Please, check the value of the koji_dir
variable while this test runs. It ought to be a directory that you can write to. Just arrange for the JSON file to really exist under that directory and then let the code under test really read it from that directory. Adding mocks unnecessarily makes the tests more complicated and fragile.
98ccdbd
to
6563677
Compare
boot_mode = BootMode(boot_mode) | ||
|
||
version = ( | ||
rhcos_meta_data["coreos-assembler.container-config-git"]["branch"].split( |
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.
You mentioned changing this to cope with the fact that this field is optional in the schema, but this is still going to crash if the field is absent or None
. Adding some test data like that could confirm it if needed.
If you want to make this tolerant against the missing field, won't it have to be written something more like this?
branch = (rhcos_meta_data.get("coreos-assembler.container-config-git") or {}).get("branch") or ""
version = branch.split("-")[-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.
my bad I missed it, sending it again.
d186072
to
eb6ef3f
Compare
I need to change the naming convention for rhcos images. I am working for it, will publish my changes once it gets completed. |
@ashwini3326 could you please confirm if this PR is complete and OK to release, or are there still changes expected? |
@rohanpm After some discussion on the way we are currently naming the rhcos packages, I need to change few things and also add a 'marketplace_target' metadata for VMs'. so we need to wait before it gets merged. |
ashwini said that some updates are expected.
69f6563
to
ad9325b
Compare
@rohanpm as Red Hat Core OS images are named differently ( it only have the name rhcos-) we need a way to identify where these images are expected to be shipped. I am adding a new attribute (marketplace_name) to VMIPushItem for this purpose. PTAL. Also let me know if we need more tests for this change. |
@ashwini3326 please run the tests again with
|
e5cffe2
to
ad9325b
Compare
on it. |
47be17a
to
eebf53d
Compare
for more information, see https://pre-commit.ci
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.
@rohanpm just to let you know: We decided to create an attribute named marketplace-name
to compose with the KojiBuildInfo.name
as we thought it wouldn't be good to mess with the KojiBuildInfo.name
by appending the -azure
or -aws
suffix to it, since the information would reflect a build which doesn't exist.
However, we need the build name to have -azure
or -aws
for StArMap as the RHCOS names doesn't quite follow the Stratosphere convention names, so instead we're adding these suffix to the new property and resolving it in our pubtools
.
This merge provides support for generating push items from ART/rhcos builds.