mz668: add integration test for build context#708
Draft
mzihlmann wants to merge 8 commits into
Draft
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #668.
Background
Per codecov, only three of the seven
pkg/buildcontextimplementations are exercised by the integration suite:git://,dir://, andtar://stdin. And insidegit.go, several ref-handling branches are unhit even thoughgit://is "covered" at the package level. This PR plugs both gaps.What's added
TestHTTPSBuildcontext—integration/integration_with_https_test.goFirst integration coverage for
pkg/buildcontext/https.go.t.TempDir()viautil.CreateTarballOfDirectory./tmp/kaniko-tls-registry/tls.{crt,key}thatscripts/setup-tls-registry-creds.shalready generates forTestAlpineTLS. CN/SAN isIP:127.0.0.2.http.Serverbound to127.0.0.2:0serving the tarball.docker build - < tarball), so the docker daemon does not need to trust the self-signed cert.-c https://127.0.0.2:<port>/..., bind-mounting the cert into/kaniko/ssl/certs/(kaniko's image already setsSSL_CERT_DIRthere — same pattern asTestAlpineTLS).containerDiffhelper.CreateTarballOfDirectorystrips only the leading/, so the Dockerfile path inside the tarball is the host's absolute path minus the slash. Both docker and kaniko receive that as-f.Three new git-context tests —
integration/integration_git_refs_test.goThe existing
TestGitBuildcontext*only hit two of the four ref-handling branches inUnpackTarFromBuildContext. New coverage:TestGitBuildcontextPlainBranchrefs/heads/prefix (the trailingelsearound line 88-91)TestGitBuildcontextTagrefs/tags/<tag>— the post-clone fetch flow (lines 84-87 + 108-124)TestGitBuildcontextBranchFlag--git=branch=<name>flag →getGitReferenceName+gitRefExists(lines 94-100, 152-179)A small helper
testGitBuildcontextRawHelperis introduced because the existingKanikoGitRepoalways prependsrefs/heads/, which doesn't fit any of the three new shapes.Coverage notes
Coverage instrumentation flows through
addCoverageFlags, so the happy path ofpkg/buildcontext/https.go(status check +io.Copy+UnpackCompressedTar) and the previously-untouched branches inpkg/buildcontext/git.go(plain branch, refs/tags/, getGitReferenceName, gitRefExists tag-match) all land in codecov.Test plan
LOCAL=1 ./scripts/integration-test.sh -run 'TestHTTPSBuildcontext$' -vpasses locally, diffoci reports an empty diff.LOCAL=1 ./scripts/integration-test.sh -run 'TestGitBuildcontextPlainBranch$|TestGitBuildcontextTag$|TestGitBuildcontextBranchFlag$' -vpasses locally, all three diffoci runs are empty.integration-test-miscmatrix.Follow-ups
Other coverage gaps worth their own PRs: AzureBlob branch of the HTTPS dispatcher (cheap, no cloud),
s3://(MinIO sidecar),gs://(currently no good fake). Within git.go:GitDepth,GitSingleBranch,GitRecurseSubmodules,InsecureSkipTLS, and the third-segmentparts[2]checkout override are still untested.