Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentGoderre committed Nov 29, 2024
1 parent 858ebe8 commit ba57483
Showing 1 changed file with 104 additions and 54 deletions.
158 changes: 104 additions & 54 deletions cmd/buildctl/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,64 +120,114 @@ func testBuildMetadataFile(t *testing.T, sb integration.Sandbox) {
rdr, err := marshal(sb.Context(), st.Root())
require.NoError(t, err)

tmpDir := t.TempDir()

imageName := "example.com/moby/metadata:test"
metadataFile := filepath.Join(tmpDir, "metadata.json")

buildCmd := []string{
"build", "--progress=plain",
"--output type=image,name=" + imageName + ",push=false",
"--metadata-file", metadataFile,
cases := []struct {
name string
buildCmd []string
// TODO: Add descriptors counts
}{
{
name: "single architecture",
buildCmd: []string{
"build", "--progress=plain",
"--output type=image,name=" + imageName + ",push=false",
},
},
{
name: "multiple architecture",
buildCmd: []string{
"build", "--progress=plain",
"--output type=image,name=" + imageName + ",push=false",
"--opt", "platform=linux/amd64,linux/arm64",
},
},
{
name: "single architecture attestation",
buildCmd: []string{
"build", "--progress=plain",
"--output type=image,name=" + imageName + ",push=false",
"--opt", "attest:provenance=mode=max",
},
},
{
name: "multi architecture attestations",
buildCmd: []string{
"build", "--progress=plain",
"--output type=image,name=" + imageName + ",push=false",
"--opt", "platform=linux/amd64,linux/arm64",
"--opt", "attest:provenance=mode=max",
},
},
}

cmd := sb.Cmd(strings.Join(buildCmd, " "))
cmd.Stdin = rdr
err = cmd.Run()
require.NoError(t, err)

require.FileExists(t, metadataFile)
metadataBytes, err := os.ReadFile(metadataFile)
require.NoError(t, err)

var metadata map[string]json.RawMessage
err = json.Unmarshal(metadataBytes, &metadata)
require.NoError(t, err)

require.Contains(t, metadata, "image.name")
require.Equal(t, imageName, metadata["image.name"])

require.Contains(t, metadata, exptypes.ExporterImageDigestKey)
digest := metadata[exptypes.ExporterImageDigestKey]
require.NotEmpty(t, digest)

require.Contains(t, metadata, exptypes.ExporterImageDescriptorKey)
var desc *ocispecs.Descriptor
err = json.Unmarshal(metadata[exptypes.ExporterImageDescriptorKey], &desc)
require.NoError(t, err)
require.NotEmpty(t, desc.MediaType)
require.NotEmpty(t, desc.Digest.String())

require.Contains(t, metadata, exptypes.ExporterImageDescriptorsKey)
var descList []*ocispecs.Descriptor
require.NoError(t, err)
err = json.Unmarshal(metadata[exptypes.ExporterImageDescriptorsKey], &descList)
require.NoError(t, err)

cdAddress := sb.ContainerdAddress()
if cdAddress == "" {
t.Log("no containerd worker, skipping digest verification")
} else {
client, err := containerd.New(cdAddress, containerd.WithTimeout(60*time.Second))
require.NoError(t, err)
defer client.Close()

ctx := namespaces.WithNamespace(context.Background(), "buildkit")

img, err := client.GetImage(ctx, imageName)
require.NoError(t, err)

require.Equal(t, img.Metadata().Target.Digest.String(), digest)
for _, tt := range cases {
t.Run(tt.name, func(t *testing.T) {
tmpDir := t.TempDir()
metadataFile := filepath.Join(tmpDir, "metadata.json")

buildCmd := append(
tt.buildCmd,
"--metadata-file", metadataFile,
)
cmd := sb.Cmd(strings.Join(buildCmd, " "))
cmd.Stdin = rdr
err = cmd.Run()
require.NoError(t, err)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd/multiple_architecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd/multiple_architecture build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd/multiple_architecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd/multiple_architecture (0.04s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd/single_architecture_attestation

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd/single_architecture_attestation build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd/single_architecture_attestation --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd/single_architecture_attestation (0.04s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd/multi_architecture_attestations

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd/multi_architecture_attestations build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd/multi_architecture_attestations --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd/multi_architecture_attestations (0.06s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-rootless, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integr...

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/multiple_architecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/multiple_architecture build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/multiple_architecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/multiple_architecture (0.04s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-rootless, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integr...

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/single_architecture_attestation

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/single_architecture_attestation build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/single_architecture_attestation --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/single_architecture_attestation (0.08s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-rootless, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integr...

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/multi_architecture_attestations

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/multi_architecture_attestations build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/multi_architecture_attestations --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/multi_architecture_attestations (0.06s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-1.6, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/multiple_architecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/multiple_architecture build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/multiple_architecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/multiple_architecture (0.09s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-1.6, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/single_architecture_attestation

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/single_architecture_attestation build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/single_architecture_attestation --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/single_architecture_attestation (0.08s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-1.6, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/multi_architecture_attestations

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/multi_architecture_attestations build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/multi_architecture_attestations --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/multi_architecture_attestations (0.06s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-1.7, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/multiple_architecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/multiple_architecture build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/multiple_architecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/multiple_architecture (0.06s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-1.7, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/single_architecture_attestation

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/single_architecture_attestation build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/single_architecture_attestation --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/single_architecture_attestation (0.06s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-1.7, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/multi_architecture_attestations

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/multi_architecture_attestations build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/multi_architecture_attestations --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/multi_architecture_attestations (0.06s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-snapshotter-stargz, ./client ./cmd/buildctl ./worker/containerd ./solver ./fronte...

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/multiple_architecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/multiple_architecture build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/multiple_architecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/multiple_architecture (0.05s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-snapshotter-stargz, ./client ./cmd/buildctl ./worker/containerd ./solver ./fronte...

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/single_architecture_attestation

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/single_architecture_attestation build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/single_architecture_attestation --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/single_architecture_attestation (0.02s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-snapshotter-stargz, ./client ./cmd/buildctl ./worker/containerd ./solver ./fronte...

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/multi_architecture_attestations

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/multi_architecture_attestations build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/multi_architecture_attestations --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/multi_architecture_attestations (0.05s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=oci/multiple_architecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci/multiple_architecture build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci/multiple_architecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci/multiple_architecture (0.08s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=oci/single_architecture_attestation

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci/single_architecture_attestation build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci/single_architecture_attestation --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci/single_architecture_attestation (0.06s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=oci/multi_architecture_attestations

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci/multi_architecture_attestations build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci/multi_architecture_attestations --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci/multi_architecture_attestations (0.06s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-rootless, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/multiple_architecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/multiple_architecture build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/multiple_architecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/multiple_architecture (0.04s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-rootless, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/single_architecture_attestation

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/single_architecture_attestation build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/single_architecture_attestation --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/single_architecture_attestation (0.05s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-rootless, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/multi_architecture_attestations

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/multi_architecture_attestations build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/multi_architecture_attestations --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/multi_architecture_attestations (0.05s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-rootless-slirp4netns-detachnetns, ./client ./cmd/buildctl ./worker/containerd ./solver ....

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/multiple_architecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/multiple_architecture build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/multiple_architecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/multiple_architecture (0.05s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-rootless-slirp4netns-detachnetns, ./client ./cmd/buildctl ./worker/containerd ./solver ....

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/single_architecture_attestation

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/single_architecture_attestation build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/single_architecture_attestation --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/single_architecture_attestation (0.05s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-rootless-slirp4netns-detachnetns, ./client ./cmd/buildctl ./worker/containerd ./solver ....

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/multi_architecture_attestations

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/multi_architecture_attestations build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/multi_architecture_attestations --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/multi_architecture_attestations (0.04s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-snapshotter-stargz, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, int...

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/multiple_architecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/multiple_architecture build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/multiple_architecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/multiple_architecture (0.04s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-snapshotter-stargz, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, int...

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/single_architecture_attestation

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/single_architecture_attestation build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/single_architecture_attestation --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/single_architecture_attestation (0.06s)

Check failure on line 176 in cmd/buildctl/build_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-snapshotter-stargz, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, int...

Failed: cmd/buildctl/TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/multi_architecture_attestations

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/multi_architecture_attestations build_test.go:176: Error Trace: /src/cmd/buildctl/build_test.go:176 Error: Received unexpected error: exit status 1 Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/multi_architecture_attestations --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/multi_architecture_attestations (0.08s)

require.FileExists(t, metadataFile)
metadataBytes, err := os.ReadFile(metadataFile)
require.NoError(t, err)

var metadata map[string]json.RawMessage
err = json.Unmarshal(metadataBytes, &metadata)
require.NoError(t, err)

require.Contains(t, metadata, "image.name")
var name string
err = json.Unmarshal(metadata["image.name"], &name)
require.NoError(t, err)
require.Equal(t, imageName, string(name))

var digest string
require.Contains(t, metadata, exptypes.ExporterImageDigestKey)
err = json.Unmarshal(metadata[exptypes.ExporterImageDigestKey], &digest)
require.NoError(t, err)
require.NotEmpty(t, digest)

require.Contains(t, metadata, exptypes.ExporterImageDescriptorKey)
var desc *ocispecs.Descriptor
err = json.Unmarshal(metadata[exptypes.ExporterImageDescriptorKey], &desc)
require.NoError(t, err)
require.NotEmpty(t, desc.MediaType)
require.NotEmpty(t, desc.Digest.String())

require.Contains(t, metadata, exptypes.ExporterImageDescriptorsKey)
var descList []*ocispecs.Descriptor
require.NoError(t, err)
err = json.Unmarshal(metadata[exptypes.ExporterImageDescriptorsKey], &descList)
require.NoError(t, err)
for _, desc := range descList {
require.NotEmpty(t, desc.MediaType)
require.NotEmpty(t, desc.Digest.String())
}

cdAddress := sb.ContainerdAddress()
if cdAddress == "" {
t.Log("no containerd worker, skipping digest verification")
} else {
client, err := containerd.New(cdAddress, containerd.WithTimeout(60*time.Second))
require.NoError(t, err)
defer client.Close()

ctx := namespaces.WithNamespace(context.Background(), "buildkit")

img, err := client.GetImage(ctx, imageName)
require.NoError(t, err)

require.Equal(t, img.Metadata().Target.Digest.String(), digest)
}
})
}
}

Expand Down

0 comments on commit ba57483

Please sign in to comment.