Skip to content
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

Merged

Conversation

ashwini3326
Copy link

This merge provides support for generating push items from ART/rhcos builds.

Copy link
Member

@rohanpm rohanpm left a 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?

src/pushsource/_impl/backend/koji_source.py Outdated Show resolved Hide resolved
"hvm": "ami-02"
}]}"""

patch.object(os.path, "join", return_value=path)
Copy link
Member

@rohanpm rohanpm Feb 29, 2024

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:

  1. 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.

  2. 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.

Copy link
Author

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

@ashwini3326 ashwini3326 force-pushed the openshiftImageSupport branch from 96e0f8e to 3b62cb4 Compare March 15, 2024 14:32
Copy link

codecov bot commented Mar 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (9ab7c98) to head (1c405af).
Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

src/pushsource/_impl/backend/koji_source.py Outdated Show resolved Hide resolved
"hvm": "ami-02"
}]}"""

with patch("builtins.open", mock_open(read_data=meta_data)) as mocked_open:
Copy link
Member

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.

@ashwini3326 ashwini3326 force-pushed the openshiftImageSupport branch 2 times, most recently from 98ccdbd to 6563677 Compare March 19, 2024 13:20
boot_mode = BootMode(boot_mode)

version = (
rhcos_meta_data["coreos-assembler.container-config-git"]["branch"].split(
Copy link
Member

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]

Copy link
Author

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.

tests/koji/test_koji_vmi.py Outdated Show resolved Hide resolved
@ashwini3326 ashwini3326 force-pushed the openshiftImageSupport branch from d186072 to eb6ef3f Compare March 21, 2024 11:05
@ashwini3326
Copy link
Author

I need to change the naming convention for rhcos images. I am working for it, will publish my changes once it gets completed.

rohanpm
rohanpm previously approved these changes Mar 24, 2024
@rohanpm
Copy link
Member

rohanpm commented Mar 25, 2024

I need to change the naming convention for rhcos images

@ashwini3326 could you please confirm if this PR is complete and OK to release, or are there still changes expected?

@ashwini3326
Copy link
Author

@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.

@rohanpm rohanpm dismissed their stale review April 4, 2024 02:49

ashwini said that some updates are expected.

@ashwini3326 ashwini3326 force-pushed the openshiftImageSupport branch from 69f6563 to ad9325b Compare April 5, 2024 07:03
@ashwini3326
Copy link
Author

@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.

@JAVGan
Copy link
Contributor

JAVGan commented Apr 5, 2024

@ashwini3326 please run the tests again with PUSHSOURCE_UPDATE_BASELINES=1 and include them into this PR as the tests are failing due to missing the new attribute marketplace_name

E       AssertionError: Output differs from baseline:
E       
E       --- 
E       +++ 
E       @@ -24,6 +24,7 @@
E            ena_support: true
E            image_id: null
E            marketplace_entity_type: AMIProduct
E       +    marketplace_name: null
E            marketplace_title_template: null
E            md5sum: null
E            name: fake-image.raw
E       
E       
E       Re-run with PUSHSOURCE_UPDATE_BASELINE=1 if this is correct.

@ashwini3326 ashwini3326 force-pushed the openshiftImageSupport branch from e5cffe2 to ad9325b Compare April 5, 2024 13:43
@ashwini3326
Copy link
Author

@ashwini3326 please run the tests again with PUSHSOURCE_UPDATE_BASELINES=1 and include them into this PR as the tests are failing due to missing the new attribute marketplace_name

E       AssertionError: Output differs from baseline:
E       
E       --- 
E       +++ 
E       @@ -24,6 +24,7 @@
E            ena_support: true
E            image_id: null
E            marketplace_entity_type: AMIProduct
E       +    marketplace_name: null
E            marketplace_title_template: null
E            md5sum: null
E            name: fake-image.raw
E       
E       
E       Re-run with PUSHSOURCE_UPDATE_BASELINE=1 if this is correct.

on it.

@ashwini3326 ashwini3326 force-pushed the openshiftImageSupport branch from 47be17a to eebf53d Compare April 5, 2024 13:53
Copy link
Contributor

@JAVGan JAVGan left a 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.

@rohanpm rohanpm self-requested a review April 8, 2024 02:55
@rohanpm rohanpm merged commit 76ec4e0 into release-engineering:master Apr 8, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants