Skip to content

Comments

BuildTest - show differences between two images.#1816

Open
smoser wants to merge 1 commit intochainguard-dev:mainfrom
smoser:feat/better-test-build-changes-output
Open

BuildTest - show differences between two images.#1816
smoser wants to merge 1 commit intochainguard-dev:mainfrom
smoser:feat/better-test-build-changes-output

Conversation

@smoser
Copy link
Contributor

@smoser smoser commented Aug 13, 2025

This will provide much more verbose and possibly more useful output of a 'TestBuild' failure.

The TestBuild test is there to show reproducibility, so verifying differences between the images are expected is needed to make decisions.

claude authored this, I'm sure it could be cleaner, but I was only after the result.

@smoser smoser force-pushed the feat/better-test-build-changes-output branch from 1adffed to 463a9ef Compare August 13, 2025 16:12
@smoser
Copy link
Contributor Author

smoser commented Aug 13, 2025

I came to wanting this when #1811 made changes and it was non-trivial to see them. I made a really crappy shell script there to show the differences, but this is more easily used.

here is the output that would be seen by #1811 if i hadn't updated the golden.

+ go test -v ./internal/cli/ --run=TestBuild
=== RUN   TestBuild
2025/08/13 12:10:52 INFO installing pretend-baselayout (1.0.0-r0) arch=aarch64
2025/08/13 12:10:52 INFO installing replayout (1.0.0-r0) arch=aarch64
2025/08/13 12:10:52 INFO installing pretend-baselayout (1.0.0-r0) arch=x86_64
2025/08/13 12:10:52 INFO installing replayout (1.0.0-r0) arch=x86_64
2025/08/13 12:10:52 WARN /etc/group is missing arch=aarch64
2025/08/13 12:10:52 WARN /etc/group is missing arch=x86_64
2025/08/13 12:10:52 INFO layer digest: sha256:53ac09950a84b6a7e42051773c3aa3c1b138dd3f21937468e337e65b418cdfc0 arch=aarch64
2025/08/13 12:10:52 INFO layer diffID: sha256:8910b9d90c4916c388dd73617dd1d558a0e51f7445cc1ea6a80379ca5d82f179 arch=aarch64
2025/08/13 12:10:52 INFO layer digest: sha256:9eabb85591b31baef9775807813b51708321c03b281f70aeb1c88476d190aa5f arch=x86_64
2025/08/13 12:10:52 INFO layer diffID: sha256:d39fc061734cb58a0e734e93250752fc741218d9cadfcf86f8764ecf1c90d1c2 arch=x86_64
2025/08/13 12:10:52 INFO built index file as /tmp/apko-temp-1655498355/index.json
=== Image Index Manifest Diff ===
  (
  	"""
  	... // 5 identical lines
  	      "mediaType": "application/vnd.oci.image.manifest.v1+json",
  	      "size": 476,
- 	      "digest": "sha256:13233c203a5e591839f93061a9153446bc2ac0355710f0e80b2a7a47923e8fcd",
+ 	      "digest": "sha256:08add62f39aefa7be337e13d54c801981506bed0c5ec9d317c22a886972d2302",
  	      "platform": {
  	        "architecture": "amd64",
  	... // 4 identical lines
  	      "mediaType": "application/vnd.oci.image.manifest.v1+json",
  	      "size": 476,
- 	      "digest": "sha256:80121a5654f4a873b122ddb556aba614296b156ac3856e102dbf8a33711e23ab",
+ 	      "digest": "sha256:97f908cd70e44ddb88d54d4a2467b87ed1aced90e0de1186a2065cbe4fa44562",
  	      "platform": {
  	        "architecture": "arm64",
  	... // 8 identical lines
  	"""
  )


=== Platform linux/amd64 ===

--- Image Config Diff ---
  (
  	"""
  	... // 14 identical lines
  	    "type": "layers",
  	    "diff_ids": [
- 	      "sha256:33c4bd8677e3684ac4b9dbfdd5c8cc258e84c0460d5edc7147bbbd8b4d752076"
+ 	      "sha256:d39fc061734cb58a0e734e93250752fc741218d9cadfcf86f8764ecf1c90d1c2"
  	    ]
  	  },
  	... // 14 identical lines
  	"""
  )


--- Layer Comparison ---

--- Layer 1 ---
Layer digests differ:
  FROM: sha256:6db738b7b040fcbc8d58cd6a09ac06d3a1ccbd132e29cffe33f7e0499b080d03
    TO: sha256:9eabb85591b31baef9775807813b51708321c03b281f70aeb1c88476d190aa5f
Layer file listing diff:
--rw-r--r-- 0/0          780 1969-12-31 19:00 usr/lib/apk/db/installed
+-rw-r--r-- 0/0          797 1969-12-31 19:00 usr/lib/apk/db/installed

File content diffs:
File content differs: usr/lib/apk/db/installed
  FROM: 780 bytes
  TO:   797 bytes
  Text diff:
  (
  	"""
  	... // 15 identical lines
  	k:0
  	C:Q1DRtLIHolxOMB++9L4ZjkeUFaKYc=
+ 	F:etc
+ 	M:0:0:0775
  	F:var
  	F:var/lib
  	... // 38 identical lines
  	"""
  )


=== Platform linux/arm64 ===

--- Image Config Diff ---
  (
  	"""
  	... // 14 identical lines
  	    "type": "layers",
  	    "diff_ids": [
- 	      "sha256:fd94a07c216012e0e61da443be98b8d6a094824d914c5d094e8fd3faa34566d0"
+ 	      "sha256:8910b9d90c4916c388dd73617dd1d558a0e51f7445cc1ea6a80379ca5d82f179"
  	    ]
  	  },
  	... // 14 identical lines
  	"""
  )


--- Layer Comparison ---

--- Layer 1 ---
Layer digests differ:
  FROM: sha256:5dc95810fb12276e75b696b9bce59966c34483797baca0518e3aa6417fe06700
    TO: sha256:53ac09950a84b6a7e42051773c3aa3c1b138dd3f21937468e337e65b418cdfc0
Layer file listing diff:
--rw-r--r-- 0/0          782 1969-12-31 19:00 usr/lib/apk/db/installed
+-rw-r--r-- 0/0          799 1969-12-31 19:00 usr/lib/apk/db/installed

File content diffs:
File content differs: usr/lib/apk/db/installed
  FROM: 782 bytes
  TO:   799 bytes
  Text diff:
  (
  	"""
  	... // 15 identical lines
  	k:0
  	C:Q1URAMn9SfiCvjs6C812GovkgRgVo=
+ 	F:etc
+ 	M:0:0:0775
  	F:var
  	F:var/lib
  	... // 38 identical lines
  	"""
  )

    build_test.go:587: 
        	Error Trace:	/home/scott_moser_chainguard_dev/src/apko/internal/cli/build_test.go:587
        	Error:      	Not equal: 
        	            	expected: v1.Hash{Algorithm:"sha256", Hex:"0c08557a42192f07ca2aeb2bc66c7fff6fd67301515c85eade860e40609d1c85"}
        	            	actual  : v1.Hash{Algorithm:"sha256", Hex:"2373c0d94ce26cdb27457cb0cf9b5040bcdf0bba4a3639a9e108383ec2995d2c"}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -2,3 +2,3 @@
        	            	  Algorithm: (string) (len=6) "sha256",
        	            	- Hex: (string) (len=64) "0c08557a42192f07ca2aeb2bc66c7fff6fd67301515c85eade860e40609d1c85"
        	            	+ Hex: (string) (len=64) "2373c0d94ce26cdb27457cb0cf9b5040bcdf0bba4a3639a9e108383ec2995d2c"
        	            	 }
        	Test:       	TestBuild
--- FAIL: TestBuild (0.02s)
=== RUN   TestBuildWithBase
2025/08/13 12:10:52 INFO installing replayout (1.0.0-r0) arch=x86_64
2025/08/13 12:10:52 INFO installing replayout (1.0.0-r0) arch=aarch64
2025/08/13 12:10:52 WARN /etc/passwd is missing arch=x86_64
2025/08/13 12:10:52 WARN /etc/group is missing arch=x86_64
2025/08/13 12:10:52 WARN /etc/passwd is missing arch=aarch64
2025/08/13 12:10:52 WARN /etc/group is missing arch=aarch64
2025/08/13 12:10:52 INFO layer digest: sha256:81168b5de29746299ae4cdb269544f6dff75d8f0e6b03b314cee06723c7e2f6b arch=x86_64
2025/08/13 12:10:52 INFO layer diffID: sha256:f95c9a2c33d0677226db00b3890b5f89efe1e12819aca4396971620e6fd679dd arch=x86_64
2025/08/13 12:10:52 INFO layer digest: sha256:10a1a18309374068005a73edacbd06b17fe67378c95d1e66e0cc2be1270c0328 arch=aarch64
2025/08/13 12:10:52 INFO layer diffID: sha256:bbee945b3496e2f8493351721e2a99b8855871828825448e239663afa9a9f887 arch=aarch64
2025/08/13 12:10:52 INFO built index file as /tmp/TestBuildWithBase178919766/002/index.json
--- PASS: TestBuildWithBase (0.01s)
FAIL
FAIL	chainguard.dev/apko/internal/cli	0.041s
FAIL

@smoser
Copy link
Contributor Author

smoser commented Aug 13, 2025

Bugger. I do not think the fails here are related.

@smoser smoser force-pushed the feat/better-test-build-changes-output branch from 463a9ef to f62d67d Compare August 14, 2025 15:35
This will provide much more verbose and possibly more useful
output of a 'TestBuild' failure.

The TestBuild test is there to show reproducibility, so
verifying differences between the images are expected is
needed to make decisions.
@smoser smoser force-pushed the feat/better-test-build-changes-output branch from f62d67d to fb56453 Compare August 14, 2025 15:51
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.

1 participant