Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentGoderre committed Nov 28, 2024
1 parent 858ebe8 commit 25ffd37
Showing 1 changed file with 87 additions and 51 deletions.
138 changes: 87 additions & 51 deletions cmd/buildctl/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,59 +125,95 @@ func testBuildMetadataFile(t *testing.T, sb integration.Sandbox) {
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 architrecture",
buildCmd: []string{
"build", "--progress=plain",
"--output type=image,name=" + imageName + ",push=false",
},
},
{
name: "multiple architrecture",
buildCmd: []string{
"build", "--progress=plain",
"--output type=image,name=" + imageName + ",push=false",
"--platform", "linux/amd64,linux/arm64",
},
},
{
name: "attestation",
buildCmd: []string{
"build", "--progress=plain",
"--output type=image,name=" + imageName + ",push=false",
"--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) {
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 167 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_architrecture

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

Check failure on line 167 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/attestation

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

Check failure on line 167 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_architrecture

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

Check failure on line 167 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/attestation

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

Check failure on line 167 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_architrecture

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

Check failure on line 167 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/attestation

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

Check failure on line 167 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_architrecture

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

Check failure on line 167 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/attestation

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

Check failure on line 167 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_architrecture

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

Check failure on line 167 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/attestation

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

Check failure on line 167 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_architrecture

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

Check failure on line 167 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/attestation

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

Check failure on line 167 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_architrecture

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

Check failure on line 167 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/attestation

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

Check failure on line 167 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_architrecture

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

Check failure on line 167 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/attestation

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

Check failure on line 167 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_architrecture

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

Check failure on line 167 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/attestation

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

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"])

Check failure on line 178 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_architrecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd/single_architrecture build_test.go:178: Error Trace: /src/cmd/buildctl/build_test.go:178 Error: Not equal: expected: string("example.com/moby/metadata:test") actual : json.RawMessage(json.RawMessage{0x22, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x6f, 0x62, 0x79, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x74, 0x65, 0x73, 0x74, 0x22}) Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd/single_architrecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd/single_architrecture (1.98s)

Check failure on line 178 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_architrecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/single_architrecture build_test.go:178: Error Trace: /src/cmd/buildctl/build_test.go:178 Error: Not equal: expected: string("example.com/moby/metadata:test") actual : json.RawMessage(json.RawMessage{0x22, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x6f, 0x62, 0x79, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x74, 0x65, 0x73, 0x74, 0x22}) Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/single_architrecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-rootless/single_architrecture (1.95s)

Check failure on line 178 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_architrecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/single_architrecture build_test.go:178: Error Trace: /src/cmd/buildctl/build_test.go:178 Error: Not equal: expected: string("example.com/moby/metadata:test") actual : json.RawMessage(json.RawMessage{0x22, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x6f, 0x62, 0x79, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x74, 0x65, 0x73, 0x74, 0x22}) Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/single_architrecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.6/single_architrecture (1.90s)

Check failure on line 178 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_architrecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/single_architrecture build_test.go:178: Error Trace: /src/cmd/buildctl/build_test.go:178 Error: Not equal: expected: string("example.com/moby/metadata:test") actual : json.RawMessage(json.RawMessage{0x22, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x6f, 0x62, 0x79, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x74, 0x65, 0x73, 0x74, 0x22}) Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/single_architrecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-1.7/single_architrecture (1.45s)

Check failure on line 178 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_architrecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/single_architrecture build_test.go:178: Error Trace: /src/cmd/buildctl/build_test.go:178 Error: Not equal: expected: string("example.com/moby/metadata:test") actual : json.RawMessage(json.RawMessage{0x22, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x6f, 0x62, 0x79, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x74, 0x65, 0x73, 0x74, 0x22}) Test: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/single_architrecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=containerd-snapshotter-stargz/single_architrecture (2.54s)

Check failure on line 178 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_architrecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci/single_architrecture build_test.go:178: Error Trace: /src/cmd/buildctl/build_test.go:178 Error: Not equal: expected: string("example.com/moby/metadata:test") actual : json.RawMessage(json.RawMessage{0x22, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x6f, 0x62, 0x79, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x74, 0x65, 0x73, 0x74, 0x22}) Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci/single_architrecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci/single_architrecture (1.29s)

Check failure on line 178 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_architrecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/single_architrecture build_test.go:178: Error Trace: /src/cmd/buildctl/build_test.go:178 Error: Not equal: expected: string("example.com/moby/metadata:test") actual : json.RawMessage(json.RawMessage{0x22, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x6f, 0x62, 0x79, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x74, 0x65, 0x73, 0x74, 0x22}) Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/single_architrecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless/single_architrecture (0.87s)

Check failure on line 178 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_architrecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/single_architrecture build_test.go:178: Error Trace: /src/cmd/buildctl/build_test.go:178 Error: Not equal: expected: string("example.com/moby/metadata:test") actual : json.RawMessage(json.RawMessage{0x22, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x6f, 0x62, 0x79, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x74, 0x65, 0x73, 0x74, 0x22}) Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/single_architrecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci-rootless-slirp4netns-detachnetns/single_architrecture (1.14s)

Check failure on line 178 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_architrecture

=== RUN TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/single_architrecture build_test.go:178: Error Trace: /src/cmd/buildctl/build_test.go:178 Error: Not equal: expected: string("example.com/moby/metadata:test") actual : json.RawMessage(json.RawMessage{0x22, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x6f, 0x62, 0x79, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x74, 0x65, 0x73, 0x74, 0x22}) Test: TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/single_architrecture --- FAIL: TestCLIIntegration/TestBuildMetadataFile/worker=oci-snapshotter-stargz/single_architrecture (1.27s)

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)
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 25ffd37

Please sign in to comment.