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

test: buildkit with defaults #682

Merged

Conversation

MiahaCybersec
Copy link
Contributor

Closes #595

Miaha Cybersec and others added 2 commits June 27, 2024 09:41
Signed-off-by: Miaha Cybersec <[email protected]>
@MiahaCybersec
Copy link
Contributor Author

It looks like the failing test is "default buildkit address", but the test runs and passes locally. Is it possible that the test is failing because GitHub actions doesn't have a locally running BuildKit client?

The test initializes bkOpts with no values, so bkOpts.Addr is an empty string when NewClient is called. It then tries to connect to a locally running BuildKit service (autoClient) which is where the errors are originating from.

@cpuguy83 mentioned at a previous LFX mentorship meeting that the old TODO is likely referring to testing BuildKit with nothing passed in, which is why this test does not perfectly match up with the old TODO in code.

@ashnamehrotra
Copy link
Contributor

@MiahaCybersec can you check what docker version is being used in the workflow? If it is not 23.0 or later, buildkit will not be enabled by default, and you would need to change the unit test workflow to enable it

Copy link
Contributor

@ashnamehrotra ashnamehrotra left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -197,6 +197,18 @@ func TestNewClient(t *testing.T) {
cancel()
checkMissingCapsError(t, err, requiredCaps...)
})
t.Run("faulty addr", func(t *testing.T) {
t.Parallel()
addr := newMockBuildkitAPI(t) // this should return a faulty addr
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you have more details on this comment?
Its not clear from the call why this should be faulty and may produce something else in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That comment was left in by mistake, the address validation in client.New does not properly parse invalid addresses. If an address such as 300.300.300.300 is passed in, it shows no errors.

I've pushed a new commit that updates the test to be named faulty key path and added additional error validation for the tests.

pkg/buildkit/buildkit_test.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jul 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 34.22%. Comparing base (1fcc6e0) to head (c68fbc4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #682      +/-   ##
==========================================
+ Coverage   33.01%   34.22%   +1.20%     
==========================================
  Files          18       18              
  Lines        1578     1578              
==========================================
+ Hits          521      540      +19     
+ Misses       1024     1007      -17     
+ Partials       33       31       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MiahaCybersec
Copy link
Contributor Author

I'm not sure why the lint is failing. It says platforms.Normalize is deprecated, but then says to use platforms.Normalize.

@sozercan
Copy link
Member

sozercan commented Jul 10, 2024

@MiahaCybersec haha that's confusing. Looks like it's deprecated in favor of platforms.Normalize in github.com/containerd/platforms. If you change the import from github.com/containerd/containerd/platforms to github.com/containerd/platforms it should work.

@sozercan sozercan requested a review from cpuguy83 July 10, 2024 01:21
@MiahaCybersec
Copy link
Contributor Author

The unit tests for GetDockerTransport have been removed because they were incomplete. The tests did not include all of the necessary checks, and mocks would be required to properly test them. The unit tests will be added in a separate pull request to increase test coverage.

@ashnamehrotra ashnamehrotra merged commit 1ea24b7 into project-copacetic:main Jul 12, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[REQ] Test buildkit with defaults
4 participants