Skip to content

Conversation

@mvo5
Copy link
Contributor

@mvo5 mvo5 commented Sep 8, 2025

[includes https://github.com//pull/1828]


bootc,manifestest: use *json.RawMessage instead of
map[string]

This is an alternative idea to the previous commit, using
json.RawMessage allows us to use the "native" structs at the
expense of a bit more verbosity inside the test itself.

Thanks to Thozza and Achilleas for their suggestions her here!


bootc: convert TestInteratedBuildDiskYAML to use new
manifestest

This commit converts the TestInteratedBuildDiskYAML to use the
new helpers from manifesttest. A bit better then checking for
the raw json but still a bit unsatificatory because of the
disconnect between the osbuild types and the manifesttest types.


manifesttest: add NewManifestFromBytes() and Pipeline/Stage
etc

This commit is a step towards a more realistic manifesttest. It
will unmarshal the json into a similar structure as osbuild.Manifest
would do. Ideally this would not be needed and osbuild would do
it all via osbuild.NewManifestFromBytes. However because we
use interfaces in osbuild.Stage the unmarshal is not symetric
to the marshal and we cannot unmarshal back without writing a
bunch of code in a custom osbuild.Stage.Unmarshal handler.
Doing that just for testing seems a bit overkill. Its a bit
sad though because it means more duplication and drift.

@mvo5 mvo5 requested review from achilleas-k and thozza September 8, 2025 14:20
Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I understand why you're not entirely happy with this, but the general approach is good. The last commit seems to clean things up a bit, but the previous version wasn't bad either.

@mvo5 mvo5 marked this pull request as ready for review September 12, 2025 12:00
@mvo5 mvo5 requested a review from a team as a code owner September 12, 2025 12:00
@mvo5 mvo5 requested review from bcl and lzap September 12, 2025 12:00
lzap
lzap previously approved these changes Sep 15, 2025
require.NoError(t, err)
}

func makeUsrBinInstall(t *testing.T, buildDir string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confused by this name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for catching this as well. I will tweak the name, its indeed confusing.

output, err := cmd.CombinedOutput()
if err != nil {
require.NoError(t, err, string(output))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity why the condition? To avoid string conversion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thank you! This was just a silly oversight by me, I will fix it :)

Copy link
Contributor

@bcl bcl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@supakeen supakeen force-pushed the bootc-build-imgref-test-5 branch from f482e45 to 3ce47a1 Compare September 16, 2025 05:37
Copy link
Member

@thozza thozza 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 great. I think that it is a reasonable compromise that does the job. 👏

Comment on lines 113 to 118
type Stage struct {
Type string `json:"type"`

Inputs map[string]map[string]any `json:"inputs,omitempty"`
Options map[string]any `json:"options,omitempty"`
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While looking at this and the implementation in osbuild package, I got an idea that we could define a very basic Unmarshaler that would do basically the transformation to generic types as you do here.

For some interfaces, we could try adding the Unmarshaller to the embedded common types, i.e. (https://github.com/osbuild/images/blob/bb797792fc4007efd2ef4dfaf1e4cabc5b476ea0/pkg/osbuild/input.go#L20C6-L20C17). For other interfaces, we could simply use generic types as you do here.

My point is that IMHO we do not need to add a custom unmarshaller to all stages or inputs, but just to the top-level common structures. However, the outcome may be messier than this single and self-contained file.

assert.Contains(t, manifestJson, `{"type":"org.osbuild.write-device","inputs":{"tree":{"type":"org.osbuild.tree","origin":"org.osbuild.pipeline","references":["name:target"]}}`)
assert.Equal(t, []string{"target", "build", "image", "qcow2"}, mani.PipelineNames()[:4])

stage := mani.Pipelines[2].Stage("org.osbuild.write-device")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: given that we are starting to use the stage IDs for testing, maybe it would make sense to define those as constants in the osbuild package in stage implementation and use that instead of literal values. However, I do admit that it is a lot of busy work for no apparent benefit, since the test would fail if one makes a typo in the literal value....

@thozza thozza added this pull request to the merge queue Sep 16, 2025
@mvo5 mvo5 changed the title bootc: add integration test for disk.yaml bootc: add integration test for disk.yaml (HMS-9296) Sep 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Sep 16, 2025
@mvo5 mvo5 added this pull request to the merge queue Sep 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Sep 16, 2025
@mvo5 mvo5 closed this Sep 16, 2025
@mvo5 mvo5 force-pushed the bootc-build-imgref-test-5 branch from 3ce47a1 to ec1e12c Compare September 16, 2025 07:45
@mvo5
Copy link
Contributor Author

mvo5 commented Sep 16, 2025

This is very stange - the commits for this have landed in main (e.g. ec1e12c) but for some reason GH closed this PR with unmerged commits?!?

@supakeen
Copy link
Member

This is very stange - the commits for this have landed in main (e.g. ec1e12c) but for some reason GH closed this PR with unmerged commits?!?

It shows to me that there are 0 commits in this PR so I guess the message is just wrong?

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.

6 participants