Skip to content

[RFC] test: add new manifest reference tests - #1307

Closed
mvo5 wants to merge 4 commits into
osbuild:mainfrom
mvo5:manifestdb-light
Closed

mvo5 wants to merge 4 commits into
osbuild:mainfrom
mvo5:manifestdb-light

Conversation

@mvo5

@mvo5 mvo5 commented Mar 10, 2025 •

Copy link
Copy Markdown
Contributor

TODO as a middle ground the idea of having just the list of hashes of the generated manifests was suggested and tooling to create diffs so that we can avoid carrying all the manifests in the git repo

[edit: as expected lots of resistance :) also one suggestion was to make the yaml instead of json to make them easier to diff/merge so less merge conflicts in e.g. the merge-queue (thanks @achilleas-k!)]

This PR adds new manifest reference tests to capture when we
core aspects of the generated manifests. This is inspired by the
work we did in otk [0].

The test is very fast, there is no depsolving or other network
activity, but because "fake" packages get generated we will
notice any changes in the packagelists.

This is very useful when working on the yamlification of the
package lists (and later the other parts) because this way
we will spot any differences right away.
See #1300 for how
this is used.

[0] https://github.com/osbuild/otk/blob/main/test/test_against_images_refs.py

mvo5 added 4 commits March 10, 2025 12:50
This commit adds new manifest reference tests to capture when we
core aspects of the generated manifests. This is inspired by the
work we did in `otk` [0].

The test is very fast, there is no depsolving or other network
activity, but because "fake" packages get generated we will
notice any changes in the packagelists.

This is very useful when working on the yamlification of the
package lists (and later the other parts) because this way
we will spot any differences right away.

[0] https://github.com/osbuild/otk/blob/main/test/test_against_images_refs.py
This is a mechanical commit that just adds the reference data
of centos-10 and rhel-10.0 to the "manifestdb-light".
This commit is a very naive fix to avoid writing duplicated packages
into the osbuild manifest. Writing multiple identical package ids
into the manifest is no real problem but with the new manifest
compare tooling it creates unneeded diffs.
@supakeen

Copy link
Copy Markdown
Member

This is using pytest style names and layouting for a Go project. None of the makefiles or CI is adjusted and the test cases won't get ran when I do the (expected) go test ./....

I like the approach (it worked really well in otk) but can we please run this through a normal Go testcase instead of using pytest only to run a subprocess? :)

mvo5 added a commit to mvo5/images that referenced this pull request Mar 10, 2025
gen-manifests-diff is a helper to diff the generated manifests
against what the current "main" of the images library would do.

Alternatively a revision can be given as the first argument
and with that the diff is calculated against that. All images
types and architectures are used by default. It is still
very fast (typically 3s).

Example output:
```
calculating diff against d285ec6
found differences between /tmp/tmpbjhime7p/new and reference manifests:
diff -uNr /tmp/tmpbjhime7p/ref/centos_9-aarch64-edge_ami-edge_ostree_pull_user.json /tmp/tmpbjhime7p/new/centos_9-aarch64-edge_ami-edge_ostree_pull_user.json
--- /tmp/tmpbjhime7p/ref/centos_9-aarch64-edge_ami-edge_ostree_pull_user.json   2025-03-10 20:55:20.736477268 +0100
+++ /tmp/tmpbjhime7p/new/centos_9-aarch64-edge_ami-edge_ostree_pull_user.json   2025-03-10 20:55:22.294453956 +0100
@@ -161,7 +161,13 @@
             },
             "kernel_opts": [
               "luks.uuid=e3eb0343-83b0-441c-a8aa-6a715afc1d39",
-              "console=tty0 console=ttyS0,115200n8 net.ifnames=0 nvme_core.io_timeout=4294967295 modprobe.blacklist=vc4 rw coreos.no_persist_ip",
+              "console=tty0",
+              "console=ttyS0,115200n8",
+              "net.ifnames=0",
+              "nvme_core.io_timeout=4294967295",
+              "modprobe.blacklist=vc4",
+              "rw",
+              "coreos.no_persist_ip",
               "ignition.platform.id=metal",
               "$ignition_firstboot"
             ]
...
```

This is (hopefully) the uncontroversial part of
osbuild#1307
and already useful when checking that a yamlification (or other
change) is not resulting in any regressions. Also useful to see
if a change results in the expected change(s).
github-merge-queue Bot pushed a commit that referenced this pull request Mar 11, 2025
gen-manifests-diff is a helper to diff the generated manifests
against what the current "main" of the images library would do.

Alternatively a revision can be given as the first argument
and with that the diff is calculated against that. All images
types and architectures are used by default. It is still
very fast (typically 3s).

Example output:
```
calculating diff against d285ec6
found differences between /tmp/tmpbjhime7p/new and reference manifests:
diff -uNr /tmp/tmpbjhime7p/ref/centos_9-aarch64-edge_ami-edge_ostree_pull_user.json /tmp/tmpbjhime7p/new/centos_9-aarch64-edge_ami-edge_ostree_pull_user.json
--- /tmp/tmpbjhime7p/ref/centos_9-aarch64-edge_ami-edge_ostree_pull_user.json   2025-03-10 20:55:20.736477268 +0100
+++ /tmp/tmpbjhime7p/new/centos_9-aarch64-edge_ami-edge_ostree_pull_user.json   2025-03-10 20:55:22.294453956 +0100
@@ -161,7 +161,13 @@
             },
             "kernel_opts": [
               "luks.uuid=e3eb0343-83b0-441c-a8aa-6a715afc1d39",
-              "console=tty0 console=ttyS0,115200n8 net.ifnames=0 nvme_core.io_timeout=4294967295 modprobe.blacklist=vc4 rw coreos.no_persist_ip",
+              "console=tty0",
+              "console=ttyS0,115200n8",
+              "net.ifnames=0",
+              "nvme_core.io_timeout=4294967295",
+              "modprobe.blacklist=vc4",
+              "rw",
+              "coreos.no_persist_ip",
               "ignition.platform.id=metal",
               "$ignition_firstboot"
             ]
...
```

This is (hopefully) the uncontroversial part of
#1307
and already useful when checking that a yamlification (or other
change) is not resulting in any regressions. Also useful to see
if a change results in the expected change(s).
@mvo5

mvo5 commented Mar 11, 2025

Copy link
Copy Markdown
Contributor Author

This is using pytest style names and layouting for a Go project. None of the makefiles or CI is adjusted and the test cases won't get ran when I do the (expected) go test ./....

I like the approach (it worked really well in otk) but can we please run this through a normal Go testcase instead of using pytest only to run a subprocess? :)

Yeah, happy to tweak this in whatever shape this is preferred. pytest was the quickest do demo the idea for me.

@mvo5

mvo5 commented Mar 17, 2025

Copy link
Copy Markdown
Contributor Author

We had an (offline) discussion about this last week and there was strong disagreement about diffing manifests (even non-depsolved ones as in here) so I'm closing this.

We may explore options in the fuure:

  1. a bot that posts the diff against the reference on PRs
  2. putting the hashes of the manifests into git instead of the full manifest so that we can detect and ACK changes

both need tooling which this PR does not provide so a new one will be need to be created.

@mvo5 mvo5 closed this Mar 17, 2025
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.

2 participants