Skip to content

cmd/image-builder: mock simple integration tests (HMS-10857)#2473

Open
supakeen wants to merge 1 commit into
osbuild:mainfrom
supakeen:mock-unit-tests
Open

cmd/image-builder: mock simple integration tests (HMS-10857)#2473
supakeen wants to merge 1 commit into
osbuild:mainfrom
supakeen:mock-unit-tests

Conversation

@supakeen

Copy link
Copy Markdown
Member

Mock the integration tests that are easy and straightforward to mock. This reduces the test time significantly as we're not performing real dependency solving anymore in most of the tests.


Note this doesn't really make things faster that much. The test suite still takes long as almost every test calls main.Run() which loads distribution definitions which takes 2-3 seconds for every test.

We also can't make the tests parallel without rewriting the entire mocking strategy since we're mocking globals 🙁

@supakeen supakeen requested a review from a team as a code owner June 29, 2026 07:26
@supakeen supakeen requested review from achilleas-k, avitova and lzap June 29, 2026 07:26
achilleas-k
achilleas-k previously approved these changes Jun 29, 2026

@achilleas-k achilleas-k left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very nice.

I'm sure we can get more improvements to the loading times once we're done with the merge and can focus on the loader.

@supakeen

Copy link
Copy Markdown
Member Author

It seems that with some (new?) tests we now have downstream failures in RPM builds or is this caused by this PR. I'll take a look in the morning.

@supakeen supakeen force-pushed the mock-unit-tests branch 5 times, most recently from c6bf538 to cc3c92e Compare July 4, 2026 07:13
@supakeen supakeen requested a review from achilleas-k July 6, 2026 12:17
@supakeen

supakeen commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Rebased to resolve conflicts.

achilleas-k
achilleas-k previously approved these changes Jul 6, 2026
@supakeen

supakeen commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Something broke during the rebase; let's only ack when it actually goes green this time 😞

achilleas-k
achilleas-k previously approved these changes Jul 6, 2026
avitova
avitova previously approved these changes Jul 9, 2026
assert.NoError(t, err)
crossArchPipeline := "bootstrap-buildroot"
crossArchWarning := `WARNING: using experimental cross-architecture building to build "aarch64"`
crossArchWarning := fmt.Sprintf(`WARNING: using experimental cross-architecture building to build %q`, crossArch.String())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No reason to call String(), I have no problem with this other than it is inconsistent with other fmt.Sprintf where you do nto call .String()

Comment on lines +1078 to +1082
func sha256For(s string) string {
h := sha256.New()
h.Write([]byte(s))
return fmt.Sprintf("%x", h.Sum(nil))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is already defined in manifestgen_test.go. If we figure out a way to share this, maybe from some helpers.go file for tests, it would look cleaner, but not a blocker.

@supakeen supakeen added this pull request to the merge queue Jul 9, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 9, 2026
Mock the integration tests that are easy and straightforward to mock.
This reduces the test time significantly as we're not performing real
dependency solving anymore in most of the tests.

The resolvers are duplicated here but could later be shared.

Signed-off-by: Simon de Vlieger <[email protected]>
@supakeen supakeen dismissed stale reviews from avitova and achilleas-k via 5ca4251 July 10, 2026 05:57
@supakeen

Copy link
Copy Markdown
Member Author

Had to rebase for conflicts.

@supakeen supakeen requested a review from achilleas-k July 10, 2026 05:57
@supakeen supakeen requested a review from avitova July 10, 2026 05:57
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